Killer R10K

Workflow
Automating the Killer
Robots, all 10K of Them

Who Am I
@phil_zimmerman

Early Days
R10K Workflow Awesomeness
Demo Time

.

The Journey of A Thousand Miles Begins With A Single. Monolithic Repo .

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

Why Put Everything in a Single Repo? Simplify Development Easy Jenkins Flow Puppet Code and Hiera Data Together .

Just Starting Out .

.

Single CI Job • • • rspec-puppet syntax check lint For All Modules Single Release Job • create/push tag Single Deploy Job • Capistrano tasks • poor man’s dynamic environments • kludgy git logic w/conditionals in Capfile .

Forge M o dules Capistrano -> Puppet Module Tool e k r o W t ’ n d i D t I l i t n U … l l e dW .

Did I mention the KLUDGY Capistrano tasks? .

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

task "create_puppet_env". fi" else puts "Please provide a valid git branch name as an argument" end end . :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} .

s e l u d o M e g r o F e d Upgra Version Management == Face Palm Upgradin g Affects a ll Environ ments! .

Simple Comes at a Price Let Me Count the Other Ways… This Started to Fail .

“I only changed one module…. You mean I have to wait for tests to run for ALL modules before I know if my changes are good?” .

.

I have to deploy everything in order to get my changes on the masters? Sigh” .“I only changed one module….

I have to deploy everything just to get my hiera data on the masters?” .“I need to change some hiera data….

I’m Losing My Patience! .

and that little production… Stop the Madness !! .problem where upgrading forge modules can break Oh .

.

Recap of Early Days: Monolithic Repo Long CI Cycles All-Or-Nothing Deploys Upgrading Forge Modules .

.

Tools Can Be Awesome (we just needed a couple more) .

Make Them Work For You .

R10K .

R10K .

R10K! https://github.com/ adrienthebo/r10k .

Deploys Puppet Code Handles Is Git/Svn Fu Awesome .

R10K and Puppetfile ) d n a l t r o P r o ( n e v a e H n i e d a M h c t a M Manage Modul e Versi ons Inventory of Puppet Environment .

Puppetfile Format .

Puppetfile
lives in its
own
repository
Inventory of
Modules
and Their
Versions

Puppetfile
lives in its own
Repository

Inventory of
Modules and
Their Versions

own repository AND r10k Each module in its .

R10K Deploy .

r10k deploy environment test -p deploys all modules in Puppetfile for the test branch r10k deploy module tomcat deploys a single module! .

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 .

desc "for specified branch in puppetfile repo." 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 . use r10k to deploy all modules for the specified environment.

Puppetfile Manipulation and Branch Creation .

rr.Tomcat Example mod 'tomcat'.13' .git'. :ref => 'RELEASE_1.com:fylgia/tomcat.webapps. :git => 'git@github.0.

go to tomcat dir (production branch) ! ‘git checkout -b dev_change_foo’ ‘git push origin dev_change_foo’ .

Create the ‘dev_change_foo’ branch in Puppetfile repo .

Change the :ref for tomcat to ‘dev_change_foo’ .

Call r10k to deploy ‘dev_change_foo’ Notify Me When It’s Finished .

.

Explain the Magics Hint: .

Create Branch r10k deploy environment .

Modify Branch r10k deploy module .

Delete Branch auto-delete Puppetfile branch .

Testing Multiple Modules in the Same Environment .

go to profile dir (production branch) ! ‘git checkout -b dev_change_foo’ ‘git push origin dev_change_foo’ .

git'. :git => 'git@github.rr.com:fylgia/tomcat. :ref => 'RELEASE_1.com:fylgia/profile. :ref => 'dev_change_foo' .124' mod 'tomcat'.rr.git'. dev_change_foo :ref => ‘dev_change_foo’ mod 'tomcat'.webapps.com:fylgia/tomcat.13' mod 'profile'.com:fylgia/profile.mod 'profile'. :git => 'git@github.rr.git'.git'.1.webapps.webapps. production :ref => 'RELEASE_0.webapps. :git => 'git@github.0.rr. :git => 'git@github.

Truly Dynamic Environments! .

The Post-Receive Hook reaktor .

Default Setup GitHub or GitHub Enterprise Hipchat Just provide some config! .

REAKTOR_PUPPET_MASTERS_FILE PUPPETFILE_GIT_URL REAKTOR_HIPCHAT_TOKEN REAKTOR_HIPCHAT_ROOM REAKTOR_HIPCHAT_FROM .

Other Chat Providers Campfire. it’s pluggable! . etc If it has an API. Slack.

Other Git Providers Gitlab. Bitbucket. etc Need to Determine Best Approach .

Shi p It! .e r C e s a e l e R e t a Deploy .

Create Release Modulefile versionfile (hieradata) RELEASE_1.13 -> RELEASE_1.0.14 .0.

Deploy Parameterized Job environment version to deploy .

Puppetfile Manipulation (again) change :ref to selected version commit/push updated Puppetfile r10k deploy selected environment .

One-Click Production Deploy .

.

Workflow Recap: R10K and Puppetfile Each Module in Own Repo Post-Receive Hook Goodness Production Deployments .

.

.

.

Conclusion: Early Days R10K Workflow Awesomeness Demos .

Helpful Links and References https://github.com/blog/2014/03/07/puppet-workflow-part-3b/ http://philzim.com/blog/2014/02/18/puppet-workflow-part-3/ http://garylarizza.com/pzim/reaktor .com/adrienthebo/r10k http://garylarizza.com/2014/05/02/an-automated-r10k-workflow-that-works/ https://github.

Sign up to vote on this title
UsefulNot useful