Puppet

Puppet is a cross platform framework enabling system administrators to perform common tasks using code. The code can do a variety of tasks from installing new software, to checking file permissions, or updating user accounts. Puppet is great not only during the initial installation of a system, but also throughout the system’s entire life cycle. In most circumstances puppet will be used in a client/fun88体育 configuration.

This section will cover installing and configuring Puppet in a client/fun88体育 configuration. This simple example will demonstrate how to install Apache using Puppet.

Preconfiguration

Prior to configuring puppet you may want to add a DNS CNAME record for puppet.example.com, where example.com is your domain. By default Puppet clients check DNS for puppet.example.com as the puppet fun88体育 name, or Puppet Master. See Domain Name fun88体育 for more details.

If you do not wish to use DNS, you can add entries to the fun88体育 and client /etc/hosts file. For example, in the Puppet fun88体育’s /etc/hosts file add:

127.0.0.1 localhost.localdomain localhost puppet
192.168.1.17 puppetclient.example.com puppetclient

On each Puppet client, add an entry for the fun88体育:

192.168.1.16 puppetmaster.example.com puppetmaster puppet

Note

Replace the example IP addresses and domain names above with your actual fun88体育 and client addresses and domain names.

Installation

To install Puppet, in a terminal on the fun88体育 enter:

sudo apt install puppetmaster

On the client machine, or machines, enter:

sudo apt install puppet

Configuration

Create a folder path for the apache2 class:

  sudo mkdir -p /etc/puppet/modules/apache2/manifests

Now setup some resources for apache2. Create a file /etc/puppet/modules/apache2/manifests/init.pp containing the following:

class apache2 {
  package { 'apache2':
    ensure => installed,
  }

  service { 'apache2':
    ensure  => true,
    enable  => true,
    require => Package['apache2'],
  }
}

Next, create a node file /etc/puppet/code/environments/production/manifests/site.pp with:

node 'puppetclient.example.com' {
   include apache2
}

Note

Replace puppetclient.example.com with your actual Puppet client’s host name.

The final step for this simple Puppet fun88体育 is to restart the daemon:

sudo systemctl restart puppetmaster.service

Now everything is configured on the Puppet fun88体育, it is time to configure the client.

First, configure the Puppet agent daemon to start. Edit /etc/default/puppet, changing START to yes:

START=yes

Then start the service:

sudo systemctl start puppet.service

View the client cert fingerprint

sudo puppet agent --fingerprint

Back on the Puppet fun88体育, view pending certificate signing requests:

sudo puppet cert list

On the Puppet fun88体育, verify the fingerprint of the client and sign puppetclient’s cert:

sudo puppet cert sign puppetclient.example.com

On the Puppet client, run the puppet agent manually in the foreground. This step isn’t strictly speaking necessary, but it is the best way to test and debug the puppet service.

sudo puppet agent --test

Check /var/log/syslog on both hosts for any errors with the configuration. If all goes well the apache2 package and it’s dependencies will be installed on the Puppet client.

Note

This example is very simple, and does not highlight many of Puppet’s features and benefits. For more information see Resources.

Resources

  • See the web site.

  • See the , online repository of puppet modules.

  • Also see .

Last updated 1 year, 4 months ago. Help improve this document in the forum.