If you’ve done any amount of heavy UNIX systems administration work, you’ve undoubtedly written several big ugly Bash scripts.
for i in `more standard_package_list.txt `
apt-get install $i
This simple code example will read a txt file with a list of required packages, and then install all packages.
So how can Puppet help us with this task?
$package_list = ['apache2','php5','screen']
ensure => 'latest',
provider => 'apt',
Then make sure to chown this file:
$ chmod +x packages.pp
Now, when you run this file, Puppet will use the built in ‘apt’ package provider to install the list of packages defined at the top of the file.
It’s actually much easier to write a complex script using a high-level language such as Puppet, rather than Bash, despite this example that requires more code to accomplish the same task using Puppet than Bash.
Using Puppet instead of Bash for basic system scripting gives you many advantages such as better debugging, better error handling, standard formatting, better readability, and is generally much easier to perform complicated tasks than Bash or perl.
It also is a great introduction if you’re just getting your feet wet in the Puppet world. Good luck, and check back soon for more Puppet tutorials.