Sei sulla pagina 1di 74

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 mans dynamic environments
kludgy git logic w/conditionals in Capfile

Forge M
o

dules

Capistrano -> Puppet Module Tool

e
k
r
o
W

n
d
i
D
t
I
l
i
t
n
U

l
l
e
dW

Did I mention the

KLUDGY
Capistrano tasks?

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

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

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 only changed one module.


I have to deploy

everything in order to

get my changes on the masters?


Sigh

I need to change some hiera


data. I have to deploy

everything just to get

my hiera data on the masters?

Im
Losing
My
Patience!

problem where
upgrading forge modules can break
Oh - and that little

production

Stop the Madness !!

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, 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

Puppetfile
Manipulation and
Branch Creation

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

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 Its
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

mod 'profile',
:git => 'git@github.webapps.rr.com:fylgia/profile.git',

production

:ref => 'RELEASE_0.1.124'


mod 'tomcat',
:git => 'git@github.webapps.rr.com:fylgia/tomcat.git',
:ref => 'RELEASE_1.0.13'
mod 'profile',
:git => 'git@github.webapps.rr.com:fylgia/profile.git',

dev_change_foo

:ref => dev_change_foo


mod 'tomcat',
:git => 'git@github.webapps.rr.com:fylgia/tomcat.git',
:ref => 'dev_change_foo'

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, Slack, etc

If it has an API, its


pluggable!

Other Git Providers


Gitlab, Bitbucket, etc

Need to Determine Best


Approach

e
r
C

e
s
a
e
l
e
R
e
t
a

Deploy - Shi

p It!

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

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/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

Potrebbero piacerti anche