Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Puppet 4.10 Beginner???s Guide, Second Edition

You're reading from   Puppet 4.10 Beginner???s Guide, Second Edition From newbie to pro with Puppet 4.10

Arrow left icon
Product type Paperback
Published in May 2017
Publisher Packt
ISBN-13 9781787124004
Length 268 pages
Edition 2nd Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
John Arundel John Arundel
Author Profile Icon John Arundel
John Arundel
Arrow right icon
View More author details
Toc

Table of Contents (14) Chapters Close

Preface 1. Getting started with Puppet FREE CHAPTER 2. Creating your first manifests 3. Managing your Puppet code with Git 4. Understanding Puppet resources 5. Variables, expressions, and facts 6. Managing data with Hiera 7. Mastering modules 8. Classes, roles, and profiles 9. Managing files with templates 10. Controlling containers 11. Orchestrating cloud resources 12. Putting it all together Index

Getting ready for Puppet

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.

Installing Git and downloading the repository

To get a copy of the repository that accompanies this book, follow these steps:

  1. Browse to https://git-scm.com/downloads.
  2. Download and install the right version of Git for your operating system.
  3. Run the following command:
    git clone https://github.com/bitfield
    /puppet-beginners-guide.git
    

Installing Virtualbox and Vagrant

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:

  1. Browse to https://www.virtualbox.org/.
  2. Download and install the right version of Virtualbox for your operating system.
  3. Browse to https://www.vagrantup.com/downloads.html.
  4. Select the right version of Vagrant for your operating system: OS X, Windows, and so on.
  5. Follow the instructions to install the software.

Running your Vagrant VM

Once you have installed Vagrant, you can start the Puppet Beginner's Guide virtual machine:

  1. Run the following commands:
    cd puppet-beginners-guide
    vagrant plugin install vagrant-vbguest
    vagrant up
    
  2. Vagrant will begin downloading the base box, which is an Ubuntu 16.04 image pre-installed with Puppet. This may take a while, but once the download is complete, the virtual machine will start.
  3. Connect to the VM with the following command:
    vagrant ssh
    
  4. You now have a command line shell on the VM. To make sure you have the latest version of Puppet installed, run the following commands (answer 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
    
  5. Check that Puppet is installed and working (you may get a different version number, which is fine):
    sudo /opt/puppetlabs/bin/puppet --version
    4.10.1

Tip

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.

Alternative Vagrant VMs

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.

Adding Puppet to your path

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

Troubleshooting Vagrant

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.

You have been reading a chapter from
Puppet 4.10 Beginner???s Guide, Second Edition - Second Edition
Published in: May 2017
Publisher: Packt
ISBN-13: 9781787124004
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €18.99/month. Cancel anytime