Installing Puppet Server
We will start with the installation of the operating system of the Puppet Server. From now on, the Puppet Server will be called Puppet Master. We will use the Ubuntu server 14.04 LTS. Some users may prefer Enterprise Linux such as Red Hat or CentOS. If you prefer another flavor of Linux, this is also fine. Following are the server requirements. The requirements are fine for 500 to 1000 nodes. These requirements will change according to the number of your nodes:
- Ubuntu Server 14.04 LTS
- At least 4 GB RAM
- At least 2 Core CPU
- At least 40 GB of hard disk space
You can download the Ubuntu Server 14.04 LTS ISO from http://www.ubuntu.com/download/server. Using Long Term Support (LTS) versions, ensure that you do not have to upgrade your server for a long time and that there will be few issues about upgrading the distribution. If you want to test it first locally on your computer, you can also download and install VirtualBox from https://www.virtualbox.org/wiki/Downloads. All the examples in this book have been created in VirtualBox.
You should have a new installation with the OpenSSH server. We will use SSH to connect to the server.
Connecting your server with SSH
We will use SSH to connect to our server. The installation is very easy. You can use the following command to install:
$ sudo apt-get install ssh -y
sudo
: This enables you to run a command with root privileges.apt-get
: The APT package handling utility is used to install and uninstall software.install
: This option is used withapt-get
to install a package.ssh
: This is thessh
server package name that will be installed.-y
: Theapt-get
installation asks, "Do you want to continue[Y/n]
?". This flag gives the answer as yes and the command runs without interruption.
If you use Windows as your operating system, you can connect using PuTTY. Download this from the link http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html.
If you use Linux, you can connect from the terminal by the ssh
command. For example,
$ sshusername@serverip
From now on, we will use ssh
to connect to our server.
Installing Puppet
Puppet installation usually follows the following steps:
- Set the hostname
- Set FQDN
- Set the static IP, gateway and DNS
- Add the Puppet repositories
- Install Puppet
Let's have a look at each of them.
Setting the hostname
I will use puppetmaster
as the hostname. You can use either vim
or nano
for text editing. If you have never used vim
before, it will be easier for you to use nano
.
$ sudonano /etc/hostname
sudo
: For configuration changes, we will need the root privileges. If we do not run the command withsudo
, we cannot save our changes to the configuration file.nano
: This is the command to run the nano text editor./etc/hostname
: This is the filename for the hostname configuration.
Use CTRL + X and Y to save.
Setting FQDN
I will use puppetmaster.example.com.
. Use the following command to edit the /etc/hosts
file:
$ sudonano /etc/hosts
Change the contents as follows. Use your own IP according to your network.
127.0.0.1 localhost 127.0.1.1 puppetmaster.example.com 10.10.10.10 puppetmaster.example.com puppetmaster
To verify that the changes are effective, use the hostname
and hostname -f
commands.
Note
You also need to add the IP and fully qualified domain name (FQDN) to your company DNS, so that the other computers can find your server. I assume that, as a Windows system administrator, you already know how to do this. The IPs used here may not suit your network and IP ranges, so please change all the IP details throughout the book according to your needs.
Setting static IP, gateway, and DNS
For your server, give a static IP and define your gateway and nameserver IPs.
First, define your IP gateway and subnet mask. For this, we will edit the /etc/network/interfaces
file. Following is the sample detail I have added for my Puppet Master:
$ sudonano /etc/network/interfaces
As you can see, the details are self-explanatory:
eth0
: This is the network interface nameaddress
: This is your server's IPnetmask
: This is the subnetmaskbroadcast
: This is the broadcast IPgateway
: This is the gateway IP
Now, let's set the nameserver IPs. To set NS records, we need to edit /etc/resolvconf/resolv.conf.d/base
, as follows:
$ nano /etc/resolvconf/resolv.conf.d/base
The sample contents of this file are shown in the following screenshot. In our example, we are using the Google DNS IPs. Here, you can use your company's DNS IPs.
Tip
Downloading the example code
You can download the example code files from your account at http://www.packtpub.com for all the Packt Publishing books you have purchased. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.
After saving the file, reboot the server. After rebooting, you can check using the following command whether you have the correct IP, netmask, and broadcast:
$ ifconfig
ifconfig
: This command is used to get info and make the changes in the network interfaceseth0
: This is the network interface nameinet addr:10.10.10.10
: This is the IP address of our serverBcast:10.10.10.255
: This is the broadcast IPMask:255.255.255.0
: This is the netmask IP
Check whether the gateway is correct using the following command:
$ route -n
route
: This command shows and manipulates the IP routing table-n
: This flag is to show the address details in numeric format instead of hostnames
Lastly, check whether nameserver works correctly. Run the nslookup
command and enter any address, as follows:
$ nslookup
nslookup
: This is the command to interactively query the Internet names servers. If no nameserver is provided, this will use the default one.google.com
: When we enter any hostname, this will provide the details about itexit
: This command endsnslookup
As you can see in the preceding screenshot, it checks from 8.8.8.8
. Now we can say that our network settings are correct. To exit nslookup
, you can use the exit
command.
Adding the Puppet repositories
We will first add the Puppet repositories for installation. Secondly, we will update the repositories. Lastly, we will update our server before installing Puppet.
Here are the details to add the Puppet repositories:
$ sudowget https://apt.puppetlabs.com/puppetlabs-release-trusty.deb $ sudodpkg -ipuppetlabs-release-trusty.deb
wget
: This is a utility for non-interactive downloads of files from the Web. We use this here to download thepuppetlabs-release-trusty.deb file
.dpkg
: This is the package manager for Linux Debian. The option-i
is used for installation.
Now, update the repository info, as follows:
$ sudo apt-get update
Lastly, install the updates, as follows:
$ sudo apt-get upgrade -y
update
: This option is used to resynchronize the package index files from their resourcesupgrade
: This option is used to upgrade to the newest version of the already installed software
Installing Puppet
Now, it is time to install Puppet Master and its agent on your server. We will also do some configurations. The command to install Puppet is as follows:
$ sudo apt-get install -y puppetmaster puppet
Now, let's make sure that Puppet Master starts automatically. For this purpose, we need to edit /etc/default/puppetmaster
. You need to change the START=no
value to START=yes
. If it is already yes
, you can leave this as it is and continue. You also need to enable puppet agent
on the server. We will edit the /etc/default/puppet
file. Again, we need to make sure that START=yes
exists. We also need to change the server details for the puppet agent. Change the /etc/puppet/puppet.conf
file and enter the server details. Just after [main]
, add the line server=puppetmaster.example.com
.
After making the changes, we will restart the services as shown here:
$ sudo service puppetmaster restart $ sudo service puppet restart
Check whether they are running using the following commands:
$ sudo service puppetmaster status $ sudo service puppet status
As you can see in the preceding screenshot, the services are running without any problem. So we completed the installation of Puppet Master and Puppet agent on our server.