Thursday, November 7, 2013

Adding a node to the puppet master.

This post will go over how to set up a machine so that the newly installed puppet master can control the system.

Step 1:
Install the puppet application on the local machine.
rpm -ivh http://yum.puppetlabs.com/el/6/products/i386/puppetlabs-release-6-7.noarch.rpm
yum install puppet

Step 2:
Make necessary config changes to the system.

Edit the hosts file
192.168.1.10 node
192.168.1.15 puppetmaster

Edit the puppet.conf file
server = puppetmaster
report = true
pluginsync = true

chkconfig puppet on
puppet agent --daemonize

Step 3:
Add the certs.
puppet agent --server=puppetmaster -t --waitforcert 15
Notice: Did not receive certificate
Notice: Did not receive certificate
Notice: Did not receive certificate
Notice: Did not receive certificate
Notice: Did not receive certificate
Info: Caching certificate for server1.node
Info: Caching certificate_revocation_list for ca
Info: Retrieving plugin
Info: Caching catalog for server1.node
Info: Applying configuration version '1382998929'
Info: Creating state file /var/lib/puppet/state/state.yaml
Notice: Finished catalog run in 0.02 seconds

Sign the cert on the puppetmaster.
puppet cert list
  "server1.node" (SHA256) 8E:09:B0:E9:9C:76:99:4A:94:53:5C:39:FD:3A:32:DA:D3:FF:7C:64:F4:BF:6A:83:40:8F:97:E5:FA:5F:BF:87
puppet cert --sign server1.node
Notice: Signed certificate request for server1.node
Notice: Removing file Puppet::SSL::CertificateRequest server1.node at '/var/lib/puppet/ssl/ca/requests/server1.node.pem'

Step 4:
Create and test a manifest for the configured nodes
The canonical example, installing ntp.
Adding to site.pp
package { 'ntp':
        ensure => installed,
}
file { '/etc/ntp.conf':
        path       => '/etc/ntp.conf',
        ensure     => file,
        require    => Package['ntp'],
}
service { 'ntpd':
        name       => 'ntpd',
        ensure     => running,
        enable     => true,
        require    => Package['ntp'],
        subscribe  => File['/etc/ntp.conf'],
}

On the new node:

rpm -q ntp
package ntp is not installed
puppet agent --server=puppetmaster --test
Info: Retrieving plugin
Info: Caching catalog for server1.node
Info: Applying configuration version '1382999615'
Notice: /Stage[main]//Package[ntp]/ensure: created
Notice: Finished catalog run in 5.41 seconds
rpm -q ntp
ntp-4.2.4p8-3.el6.centos.i686


No comments:

Post a Comment