Skip to content

Bootstrap the Master

Rob Nelson edited this page Feb 9, 2016 · 3 revisions

The puppet master must be bootstrapped. Create a new node (vm, vagrant box, bare metal, docker, etc) called puppet (suggested IP 10.0.1.5). The entire bootstrap section will all be performed on this node. DNS should point the short name puppet to this IP (i.e. puppet.example.com resolves to this node). If you do not have DNS configured (we will set up DNS later in this lab), then an /etc/hosts entry on nodes will suffice for the moment.

Log in as root. Generate ssh keys for root and add them as deploy keys to your repos, or as ssh keys for your Github account. Set up Git with the correct user.name and user.email.

Reminder: You should mostly be using forks of the puppetinabox repos, but the documentation will refer to the original repos. Replace the URI with the URI of your fork.

Clone the control repository and cd to its directory:

git clone git@github.com:example/controlrepo.git
cd controlrepo

Automated Install

If you know what you are doing or you are not interested in the details of bootstrapping the master, you may run a script to perform the bootstrap install.

./bootstrap.sh

If the script encounters any issues, proceed step by step with the remaining instructions and identify the error. Otherwise, you may skip to [Creating Your First Managed Node] (#creating-your-first-managed-node).

Manual Install

The manual install is intended for those who want a better understanding of the bootstrapping process itself, and anyone who encounters issues with the automated bootstrap script.

Install some modules for the bootstrap process in a temporary location. zack/r10k installs r10k; hunner/hiera creates the hiera configuration and directories; jlambert121/puppet manages the puppetserver and puppet agents; stahnma/epel installs the Extra Packages for Enterprise Linux repos.

mkdir -p /root/bootstrap/modules
puppet module install --modulepath=/root/bootstrap/modules jlambert121/puppet --version 0.7.0
puppet module install --modulepath=/root/bootstrap/modules zack/r10k --version 3.2.0
puppet module install --modulepath=/root/bootstrap/modules stahnma/epel --version 1.2.2
puppet module install --modulepath=/root/bootstrap/modules hunner/hiera --version 1.4.1

Apply the puppet configuration

puppet apply --modulepath=/root/bootstrap/modules master.pp

Apply the hiera configuration:

puppet apply --modulepath=/root/bootstrap/modules hiera.pp

Apply the configuration with with:

puppet apply --modulepath=/root/bootstrap/modules r10k_installation.pp

This will install r10k and configure it to use your defined controlrepo. You can then run r10k as root:

r10k deploy environment -p

This will create a puppet environment called production at /etc/puppetlabs/code/environments/production with all of the modules specified in the controlrepo Puppetfile, including the other repos that you forked. The hiera data is located at /etc/puppetlabs/code/environments/%{environment}/hiera.

Restart the puppetserver service to re-read the hiera config that we changed above.

systemctl restart puppetserver

Puppet is now ready for its first run. You may preview what will be applied to the puppet master with the noop flag:

puppet agent -t --noop

You can then apply the catalog by dropping the noop flag:

puppet agent -t

You may have to run the above command twice. The initial setup involves creating a database, populating it, and starting the database service, which can sometimes take longer than the puppet's timeout. If it does, don't worry, just run the command again and it will complete on the second try. You can usually avoid this by increasing the CPU/RAM of the node.

Lastly, ensure that the puppet service (the agent) is running and set to run at startup. On an EL linux, use the following commands:

systemctl enable puppet
systemctl start puppet

Congratulations! You now have a fully functioning puppet server that supports puppet via puppetserver, hiera for external data, and puppetdb for exported resources and reporting.