Fetching and applying changes automatically
In a stand-alone Puppet architecture, each node needs to automatically fetch any changes from the Git repo at regular intervals, and apply them with Puppet. We can use a simple shell script for this, and there's one in the example repo (/examples/files/run-puppet.sh
):
#!/bin/bash cd /etc/puppetlabs/code/environments/production && git pull /opt/puppetlabs/bin/puppet apply manifests/
We will need to install this script on the node to be managed by Puppet, and create a cron job to run it regularly (I suggest every 15 minutes). Of course, we could do this work manually, but isn't this book partly about the advantages of automation? Very well, then: let's practice what we're preaching.
Writing a manifest to set up regular Puppet runs
In this section, we'll create the necessary Puppet manifests to install the run-puppet
script on a node and run it regularly from cron:
- Run the following commands to create the required directories...