Puppet is a well-known software configuration utility. I use it to prepare Vagrant boxes. It can be seen as an abstraction layer, that helps one to define resources in a platform independent way.
A resource can be almost anything that you deal with when you set up a new server or reconfigure an existing one. It can be:
- a file (e.g.
- a single line in a file
- a deamon (e.g.
- a software package (e.g.
- a command (e.g.
If you don’t know any software configuration solution Puppet is definitely worth trying.
2. First step: resources
The first step to master Puppet is to get acquainted with resources.
The complete documentation for resources is available on Puppet’s site
3. How to use the examples?
The examples I prepared are mostly trivial and self documented. To run them, one by one, create a local clone:
$ git clone firstname.lastname@example.org:by-examples/puppet-by-examples.git $ cd puppet-by-examples
Then you need to boot the VM.
You can change the system within
- Ubuntu 12.04
- Ubuntu 14.04
- CentOS 6.5
- CentOS 7.0
The instruction that follows was written for Ubuntu 14.04 (this is the default setting).
# Host OS $ vagrant up $ vagrant ssh
Once in guest, change the current directory to
# Guest OS $ cd /vagrant
Now, you can run the Puppet examples that I have prepared.
$ puppet apply 01-resources/notify/notify-1.pp
will execute the example
To learn basics of Puppet:
- run the example
- take a look at the source code
4. The Examples
I suggest you to work in the following order:
- notify (directory
- file (directory
- array (directory
- package (directory
- define (directory
- download-file (directory
- ordering (directory
- stdlib (directory
- well-known-modules (directory
Some of the examples need root privileges and additional software.
Take a look at the example
You will find in this example the following comment:
# Ubuntu # sudo puppet module install puppetlabs-apache --version 1.2.0 # sudo puppet apply puppetlabs-apache-1.pp # sudo apt-get install lynx-cur -y # lynx by-examples.lh
It means, that in order to run the example in Ubuntu, you have to execute the following commands:
# Guest OS $ sudo puppet module install puppetlabs-apache --version 1.2.0 $ sudo puppet apply puppetlabs-apache-1.pp $ sudo apt-get install lynx-cur -y $ lynx by-examples.lh
$ sudo puppet apply puppetlabs-apache-1.pp
will work only in
You have to proceed it with:
5. The Examples
You will find the source code of the example on GitHub.