Manually updating R10K after changes are pushed to git is a major pain.
There are a few ways this can be made to work transparently and this article discusses one possible option: Using a post-receive hook to publish an R10K update request to MCollective.
All of the scripts and software to do this task already exists on the Internet, so all we have to do is plug things together to get it working.
There's a Forge Module that does all the work.
While researching this article, I did the steps the puppet module does manually so that I could better understand what was going on. The Steps to get R10K updates working with Puppet Enterprise are:
In my case, I was running my stash server as a user called 'stash' so I had to change the MCollective configuration file and accordingly.
mco
command ('stash' in my case) and then typing 'mco ping'.If you get output that looks like this, it's working:
[root@git ~]# sudo -u stash /opt/puppet/bin/mco ping
puppet.puppetlabs.vm time=123.93 ms
git.puppetlabs.vm time=125.38 ms
---- ping statistics ----
2 replies max: 125.38 min: 123.93 avg: 124.66
# cp files/agent /opt/puppet/libexec/mcollective/mcollective/ -r
# cp files/application /opt/puppet/libexec/mcollective/mcollective/ -r
The module can of-course do this automatically but this is a learning exercise ;-)
Note that this must be done on both the puppet master and the git server! There is no mechanism to automatically distribute MCollective plugins unless you get the module to manually copy the files for you.
Once you've installed the plugins you must restart both MCollective servers:
# /etc/init.d/pe-mcollective restart
Running the synchronize command manually looks like this:
# sudo -u stash /opt/puppet/bin/mco r10k synchronize
* [ ============================================================> ] 2 / 2
git.puppetlabs.vm:
puppet.puppetlabs.vm:
Finished processing 2 / 2 hosts in 1138.35 ms
hooks/post-receive.d
directory. If doing this, start your filename with a number to control execution order.You can find a complete hook script inside the R10K module in the file files/post-receive
I had to comment line 5 (repository=...) to get the hook to work on my system
PuppetFile
in git and push the changes to your git server. After a few minutes your changes should be live on the puppet master (it can take a while to update if you have a few modules to download)If things don't work, test the components individually until you find the fault:
# /opt/puppet/bin/r10k deploy environment -pv
r10k
command in the search path ($PATH
variable). I had to symlink the r10k
executable from /opt/puppet/bin/r10
to /usr/bin/r10k
to get the plugin to workmco ping
command. If there are problems try restarting the pe-mcollective
daemon and ensure clocks are synchronized.chmod +x
)/usr/bin/env ruby
. You may need a symlink if not