74
Killer R10K Workflow Automating the Killer Robots, all 10K of Them

PuppetConf 2014 Killer R10K Workflow Without Notes

Embed Size (px)

DESCRIPTION

Slides (without notes) from my talk at PuppetConf 2014

Citation preview

Page 1: PuppetConf 2014 Killer R10K Workflow Without Notes

Killer R10K Workflow

Automating the KillerRobots, all 10K of Them

Page 2: PuppetConf 2014 Killer R10K Workflow Without Notes

Who Am I@phil_zimmerman

Page 3: PuppetConf 2014 Killer R10K Workflow Without Notes

Early Days

R10K Workflow Awesomeness

Demo Time

Page 4: PuppetConf 2014 Killer R10K Workflow Without Notes
Page 5: PuppetConf 2014 Killer R10K Workflow Without Notes

The Journey of A Thousand Miles Begins

With A Single, Monolithic Repo

Page 6: PuppetConf 2014 Killer R10K Workflow Without Notes

A Single Repo? What the F*@K?!!

Page 7: PuppetConf 2014 Killer R10K Workflow Without Notes

Why Put Everything in a Single Repo?

Simplify Development

Easy Jenkins Flow

Puppet Code and Hiera Data Together

Page 8: PuppetConf 2014 Killer R10K Workflow Without Notes

Just Starting

Out

Page 9: PuppetConf 2014 Killer R10K Workflow Without Notes
Page 10: PuppetConf 2014 Killer R10K Workflow Without Notes

Single CI Job • rspec-puppet • syntax check • lint

Single Release Job • create/push tag

Single Deploy Job • Capistrano tasks

• poor man’s dynamic environments • kludgy git logic w/conditionals in Capfile

For All Modules

Page 11: PuppetConf 2014 Killer R10K Workflow Without Notes

Forge Modules

Capistrano -> Puppet Module Tool

Worked Well… Until It Didn’t

Page 12: PuppetConf 2014 Killer R10K Workflow Without Notes

Did I mention the

Capistrano tasks?

KLUDGY

Page 13: PuppetConf 2014 Killer R10K Workflow Without Notes

task "create_puppet_env", :roles => :puppet_master do if exists?(:branchname) run "if [ -d #{environment_basedir}/#{branchname} ]; then cd #{environment_basedir}/#{branchname} && git pull origin #{branchname} ; else \ git clone #{module_repository} #{environment_basedir}/#{branchname} --branch #{branchname} ; fi" else puts "Please provide a valid git branch name as an argument" end end

Page 14: PuppetConf 2014 Killer R10K Workflow Without Notes

task "create_puppet_env", :roles => :puppet_master do if exists?(:branchname) run "if [ -d #{environment_basedir}/#{branchname} ]; then cd #{environment_basedir}/#{branchname} && git pull origin #{branchname} ; else \ git clone #{module_repository} #{environment_basedir}/#{branchname} --branch #{branchname} ; fi" else puts "Please provide a valid git branch name as an argument" end end

Page 15: PuppetConf 2014 Killer R10K Workflow Without Notes

Upgrade Forge Modules

Version Management == Face Palm

Upgrading Affects all Environments!

Page 16: PuppetConf 2014 Killer R10K Workflow Without Notes

Let Me Count the Other Ways…

This Started to Fail

Simple Comes at a Price

Page 17: PuppetConf 2014 Killer R10K Workflow Without Notes

You mean I have to wait for tests

to run for ALL modules before I know if my changes are good?”

“I only changed one module….

Page 18: PuppetConf 2014 Killer R10K Workflow Without Notes
Page 19: PuppetConf 2014 Killer R10K Workflow Without Notes

I have to deploy

everything in order to get my changes on the masters? Sigh”

“I only changed one module….

Page 20: PuppetConf 2014 Killer R10K Workflow Without Notes

everything just to get my hiera data on the masters?”

“I need to change some hiera data…. I have to deploy

Page 21: PuppetConf 2014 Killer R10K Workflow Without Notes

I’m Losing

My Patience!

Page 22: PuppetConf 2014 Killer R10K Workflow Without Notes

Oh - and that little problem where

upgrading forge modules can break production…

Stop the Madness !!

Page 23: PuppetConf 2014 Killer R10K Workflow Without Notes
Page 24: PuppetConf 2014 Killer R10K Workflow Without Notes

Recap of Early Days:Monolithic RepoLong CI CyclesAll-Or-Nothing DeploysUpgrading Forge Modules

Page 25: PuppetConf 2014 Killer R10K Workflow Without Notes
Page 26: PuppetConf 2014 Killer R10K Workflow Without Notes

Tools Can Be

Awesome

(we just needed a couple more)

Page 27: PuppetConf 2014 Killer R10K Workflow Without Notes

Make Them Work For You

Page 28: PuppetConf 2014 Killer R10K Workflow Without Notes

R10K

Page 29: PuppetConf 2014 Killer R10K Workflow Without Notes

R10K

Page 30: PuppetConf 2014 Killer R10K Workflow Without Notes

R10K!

https://github.com/adrienthebo/r10k

Page 31: PuppetConf 2014 Killer R10K Workflow Without Notes

Deploys Puppet Code

Handles Git/Svn Fu

Is Awesome

Page 32: PuppetConf 2014 Killer R10K Workflow Without Notes

R10K and Puppetfile

Match Made in Heaven (or Portland)

Manage Module Versions

Inventory of Puppet Environment

Page 33: PuppetConf 2014 Killer R10K Workflow Without Notes

Puppetfile

Format

Page 34: PuppetConf 2014 Killer R10K Workflow Without Notes

Inventory of Modules and Their Versions

Puppetfile lives in its

own repository

Page 35: PuppetConf 2014 Killer R10K Workflow Without Notes

Puppetfile lives in its own

Repository

Page 36: PuppetConf 2014 Killer R10K Workflow Without Notes

Inventory of Modules and Their Versions

Page 37: PuppetConf 2014 Killer R10K Workflow Without Notes

Each module in its own

repository AND r10k

Page 38: PuppetConf 2014 Killer R10K Workflow Without Notes

R10KDeploy

Page 39: PuppetConf 2014 Killer R10K Workflow Without Notes

r10k deploy environment test -p

deploys all modules in Puppetfile for the test branch

r10k deploy module tomcatdeploys a single module!

Page 40: PuppetConf 2014 Killer R10K Workflow Without Notes

CI Job Per Module • rspec-puppet • syntax check • lint

Release Job Per Module • create/push tag • select module from dropdown list

Deploy Job For Each Module And Hiera • simpler Capistrano tasks • wrap r10k calls to each master/node

Page 41: PuppetConf 2014 Killer R10K Workflow Without Notes

desc "for specified branch in puppetfile repo, use r10k to deploy all modules for the specified environment." task "update_environment", :roles => :puppet_master do if exists?(:branchname) run "r10k -v debug deploy environment #{branchname} -p" else puts "Please provide a valid git branch name as an argument" end end

Page 42: PuppetConf 2014 Killer R10K Workflow Without Notes

Puppetfile Manipulation and Branch Creation

Page 43: PuppetConf 2014 Killer R10K Workflow Without Notes

mod 'tomcat', :git => '[email protected]:fylgia/tomcat.git', :ref => 'RELEASE_1.0.13'

Tomcat Example

Page 44: PuppetConf 2014 Killer R10K Workflow Without Notes

go to tomcat dir (production branch) !

‘git checkout -b dev_change_foo’ ‘git push origin dev_change_foo’

Page 45: PuppetConf 2014 Killer R10K Workflow Without Notes

Create the ‘dev_change_foo’ branch

in Puppetfile repo

Page 46: PuppetConf 2014 Killer R10K Workflow Without Notes

Change the :ref for tomcat to

‘dev_change_foo’

Page 47: PuppetConf 2014 Killer R10K Workflow Without Notes

Call r10k to deploy ‘dev_change_foo’

Notify Me When It’s Finished

Page 48: PuppetConf 2014 Killer R10K Workflow Without Notes
Page 49: PuppetConf 2014 Killer R10K Workflow Without Notes

Explain the Magics

Hint:

Page 50: PuppetConf 2014 Killer R10K Workflow Without Notes

Create Branchr10k deploy environment

Page 51: PuppetConf 2014 Killer R10K Workflow Without Notes

Modify Branchr10k deploy module

Page 52: PuppetConf 2014 Killer R10K Workflow Without Notes

Delete Branchauto-delete Puppetfile branch

Page 53: PuppetConf 2014 Killer R10K Workflow Without Notes

Testing Multiple Modules in the

Same Environment

Page 54: PuppetConf 2014 Killer R10K Workflow Without Notes

go to profile dir (production branch) !

‘git checkout -b dev_change_foo’ ‘git push origin dev_change_foo’

Page 55: PuppetConf 2014 Killer R10K Workflow Without Notes

mod 'profile', :git => '[email protected]:fylgia/profile.git', :ref => 'RELEASE_0.1.124' mod 'tomcat', :git => '[email protected]:fylgia/tomcat.git', :ref => 'RELEASE_1.0.13'

production

mod 'profile', :git => '[email protected]:fylgia/profile.git', :ref => ‘dev_change_foo’ mod 'tomcat', :git => '[email protected]:fylgia/tomcat.git', :ref => 'dev_change_foo'

dev_change_foo

Page 56: PuppetConf 2014 Killer R10K Workflow Without Notes

Truly Dynamic Environments!

Page 57: PuppetConf 2014 Killer R10K Workflow Without Notes

The Post-Receive Hook

reaktor

Page 58: PuppetConf 2014 Killer R10K Workflow Without Notes

Default SetupGitHub or GitHub Enterprise

Hipchat

Just provide some config!

Page 59: PuppetConf 2014 Killer R10K Workflow Without Notes

REAKTOR_PUPPET_MASTERS_FILE

REAKTOR_HIPCHAT_TOKENREAKTOR_HIPCHAT_ROOMREAKTOR_HIPCHAT_FROM

PUPPETFILE_GIT_URL

Page 60: PuppetConf 2014 Killer R10K Workflow Without Notes

Other Chat ProvidersCampfire, Slack, etc

If it has an API, it’s pluggable!

Page 61: PuppetConf 2014 Killer R10K Workflow Without Notes

Other Git ProvidersGitlab, Bitbucket, etc

Need to Determine Best Approach

Page 62: PuppetConf 2014 Killer R10K Workflow Without Notes

Create Release

Deploy - Ship It!

Page 63: PuppetConf 2014 Killer R10K Workflow Without Notes

Create ReleaseModulefile

RELEASE_1.0.13 -> RELEASE_1.0.14

versionfile (hieradata)

Page 64: PuppetConf 2014 Killer R10K Workflow Without Notes

DeployParameterized Job

environment

version to deploy

Page 65: PuppetConf 2014 Killer R10K Workflow Without Notes

Puppetfile Manipulation (again)

change :ref to selected version

r10k deploy selected environment

commit/push updated Puppetfile

Page 66: PuppetConf 2014 Killer R10K Workflow Without Notes

One-Click Production

Deploy

Page 67: PuppetConf 2014 Killer R10K Workflow Without Notes
Page 68: PuppetConf 2014 Killer R10K Workflow Without Notes

Workflow Recap:R10K and PuppetfileEach Module in Own RepoPost-Receive Hook GoodnessProduction Deployments

Page 69: PuppetConf 2014 Killer R10K Workflow Without Notes
Page 70: PuppetConf 2014 Killer R10K Workflow Without Notes
Page 71: PuppetConf 2014 Killer R10K Workflow Without Notes
Page 72: PuppetConf 2014 Killer R10K Workflow Without Notes

Conclusion:Early DaysR10K Workflow AwesomenessDemos

Page 73: PuppetConf 2014 Killer R10K Workflow Without Notes

Helpful Links and References

https://github.com/adrienthebo/r10k

http://garylarizza.com/blog/2014/02/18/puppet-workflow-part-3/

http://garylarizza.com/blog/2014/03/07/puppet-workflow-part-3b/

http://philzim.com/2014/05/02/an-automated-r10k-workflow-that-works/

https://github.com/pzim/reaktor

Page 74: PuppetConf 2014 Killer R10K Workflow Without Notes