Although Puppet is inherently cross-platform and works with many different operating systems, for the purposes of this book I'm going to focus on just one operating system, the Ubuntu 16.04 LTS distribution of Linux, and the most recent version of Puppet, Puppet 4. However, all the examples in the book should work on any recent operating system or Puppet version with only minor changes.
You will probably find that the best way to read this book is to follow along with the examples using a Linux machine of your own. It doesn't matter whether this is a physical server, desktop or laptop, cloud instance, or a virtual machine (VM). I'm going to use the popular Vagrant software to run a virtual machine on my own computer, and you can do the same. The public GitHub repository for this book contains a Vagrantfile which you can use to get up and running with Puppet in just a few steps.
To get a copy of the repository that accompanies this book, follow these steps:
git clone https://github.com/bitfield /puppet-beginners-guide.git
If you already have a Linux machine or cloud server you'd like to use for working through the examples, skip this section and move on to Installing Puppet. If you'd like to use Virtualbox and Vagrant to run a local VM on your computer to use with the examples, follow these instructions:
Once you have installed Vagrant, you can start the Puppet Beginner's Guide virtual machine:
cd puppet-beginners-guide vagrant plugin install vagrant-vbguest vagrant up
vagrant ssh
y
to any prompts):curl https://apt.puppetlabs.com/DEB-GPG-KEY-puppet |sudo apt-key add
sudo apt-get update sudo apt-get install -y puppetlabs-release-pc1 sudo apt-get install -y puppet-agent
sudo /opt/puppetlabs/bin/puppet --version
4.10.1
If you're using Windows, you may need to install the PuTTY software to connect to your VM. There is some helpful advice about using Vagrant on Windows at http://tech.osteel.me/posts/2015/01/25/how-to-use-vagrant-on-windows.html.
The Vagrant configuration file (known as a Vagrantfile) in the example repository for this book specifies a particular Vagrant box, or downloadable machine image. If this box is no longer available, for whatever reason, you may see an error on running the vagrant up
command, like the following:
The box 'puppetlabs/ubuntu-16.04-64-puppet' could not be found or could not be accessed in the remote catalog.
If you get this error, browse to the following URL to see the available Puppet Vagrant boxes:
https://atlas.hashicorp.com/puppetlabs/Look for Ubuntu images ending in -puppet
(these have Puppet pre-installed). For example, puppetlabs/ubuntu-16.04-64-puppet
is an Ubuntu 16.04 image for 64-bit systems with Puppet pre-installed. Find the latest available such image and edit the Vagrantfile in the puppet-beginners-guide
directory to change the config.vm.box
setting appropriately:
config.vm.box = "puppetlabs/ubuntu-16.04-64-puppet"
Then try running the vagrant up
command again.
We need to perform one more step which will make it easier for us to run Puppet on the node without having to specify the full path each time. Run the following command:
sudo visudo
An editor will start with the contents of the /etc/sudoers
file. Look for the following line:
Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
Add :/opt/puppetlabs/puppet/bin
to this set of paths, so that it reads:
Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/puppetlabs/puppet/bin"
Save the file and exit the editor. The system is now setup to find the puppet
executable without specifying the full path to it. To test this, run the following command:
sudo puppet —version
4.10.1
If you have any problems running the VM, look for help on the Virtualbox or Vagrant websites. In particular, if you have an older machine, you may see a message like the following:
VT-x/AMD-V hardware acceleration is not available on your system. Your 64-bit guest will fail to detect a 64-bit CPU and will not be able to boot.
Your computer may have a BIOS setting to enable 64-bit hardware virtualization (depending on the manufacturer, the trade name for this is either
VT-x or
AMD-V). Enabling this feature may fix the problem. If not, you can try the 32-bit version of the Vagrant box instead. Edit the file named Vagrantfile
in the Git repository, and comment out the following line with a leading #
:
config.vm.box = "puppetlabs/ubuntu-16.04-64-puppet"
Uncomment the following line by removing the leading #
character:
# config.vm.box = "puppetlabs/ubuntu-16.04-32-puppet"
Now rerun the vagrant up
command.
18.226.180.161