No matter if you are using the Puppet master or Puppet Server, at this point you are ready to connect a node to your server. Let’s review this process one step at a time.
The easiest way to create a key pair for a node is to attempt to connect to a server. The Puppet agent will create the private and public TLS keys, and then submit a certificate signing request (CSR) to the server for authorization.
The default hosts file associates the name puppet.example.com with the puppetserver node. If you are using the deprecated Puppet master, you will need to edit /etc/hosts to look like this:
192.168.250.5puppetmaster.example.compuppet.example.com192.168.250.6puppetserver.example.com
If you are testing the Puppet Server, then you’ll want that name associated with the puppetserver instance’s IP address.
Once you have confirmed that this is correct, attempt a connection to the server using this command:
[vagrant@client~]$puppetagent--test--server=puppet.example.comInfo:CreatinganewSSLkeyforclient.example.comInfo:CachingcertificateforcaInfo:csr_attributesfileloadingfrom/etc/puppetlabs/puppet/csr_attributes.yamlInfo:CreatinganewSSLcertificaterequestforclient.example.comInfo:CertificateRequestfingerprint(SHA256):C3:37:C8:76:CE:3A:D7:81:64:DF:80Info:CachingcertificateforcaExiting;nocertificatefoundandwaitforcertisdisabled
There’s a lot of information here, so let’s review it. The client has done all of the following:
The client cannot proceed until it is authorized. You can run the command again and you’ll see the same output. This is security for your environment—a node may not connect and download information that it has not been authorized for:
[vagrant@client~]$puppetagent--test--server=puppet.example.comExiting;nocertificatefoundandwaitforcertisdisabled
At this point, you’ll need to return to the Puppet server and sign the client’s CSR in order to authorize it. First, let’s see what requests are waiting to be signed:
[vagrant@puppetserver~]$puppetcert--list"client.example.com"(SHA256)C3:37:C8:76:CE:3A:D7:81:64:DF:80
Compare the CSR’s fingerprint with the request you made earlier to ensure that it is the request you created. Sign the request in order to authorize the client:
[vagrant@puppetserver~]$puppetcert--signclient.example.comNotice:Signedcertificaterequestforclient.example.comNotice:RemovingfilePuppet::SSL::CertificateRequestclient.example.comat'/var/opt/puppetlabs/puppetserver/ssl/ca/requests/client.example.com.pem'
The next time the client connects, it will be given the signed certificate and a Puppet catalog will be built for it.
Now that the request has been signed, you can return to the client node and retry the connection attempt:
[vagrant@client~]$puppetagent--test--server=puppet.example.comInfo:Cachingcertificateforclient.example.comInfo:Cachingcertificate_revocation_listforcaInfo:Cachingcertificateforclient.example.comInfo:RetrievingpluginfactsInfo:RetrievingpluginInfo:Cachingcatalogforclient.example.comInfo:Applyingconfigurationversion'1438539603'Notice:Appliedcatalogin0.01seconds
The Puppet agent has received the signed certificate for the node and stored it. Then it performed all the steps listed in “Understanding the Catalog Builder”:
How did we know that the catalog was built in 0.28 seconds? You can find this in the syslog logfile:
[vagrant@puppetmaster~]$grepclient.example.com/var/log/messagesAug218:20:03puppetmasterpuppet:Notice:Compiledcatalogforclient.example.cominenvironmentproductionin0.28seconds
You’ll probably be thinking two things right now:
You are absolutely correct. At this moment in time, the catalog given back to the node was completely empty. Let’s go on to configure the server with your Hiera data and modules.
If you are building a new Puppet environment, install the Hiera data, environments, and modules you built in Part II. You can simply copy these from the client instance used earlier in the book.
On the client instance, give the vagrant user a password:
[vagrant@client~]$sudopasswdvagrantChangingpasswordforuservagrant.Newpassword:agoodpasswordRetypenewpassword:agoodpasswordpasswd:allauthenticationtokensupdatedsuccessfully.
On the puppetserver instance, recursively copy over the entire code-dir path:
[vagrant@puppetserver~]$rsync-aHclient:/etc/puppetlabs/code/etc/puppetlabs/vagrant@client.example.com'spassword:
With this simple process you have installed the Hiera data and modules built and tested earlier with puppet apply for use on the Puppet server.
At this time, you can now test your manifests, exactly as you did in Part II. The only difference is that this time the Puppet server will evaluate the manifest and build the catalog, instead of the local Puppet agent. On the client node, run this command:
$sudopuppetagent--test--server=puppet.example.com--environment=testInfo:RetrievingpluginfactsInfo:RetrievingpluginInfo:LoadingfactsInfo:Cachingcatalogforclient.example.comInfo:Applyingconfigurationversion'1438557124'Notice:ClientisusingcatalogfromtheTestenvironment.Notice:/Stage[main]/Main/Notify[UsingTest]/message:defined'message'as'Client is using catalog from the Test environment.'Notice:/Stage[main]/Puppet::Agent/Service[puppet]/ensure:ensurechanged'stopped'to'running'Info:/Stage[main]/Puppet::Agent/Service[puppet]:UnschedulingrefreshonService[puppet]Notice:Appliedcatalogin0.65seconds$psauwx|greppuppetroot136150.07.425677637340?Ssl22:520:00ruby/bin/puppetagent--server=puppet.example.com--environment=test
As you can see, the agent has configured the node exactly the same as when Puppet was run with the local manifests.
The absolute best way to expand on what you have learned in this chapter is to build out a Puppet server. Configure the client to use it, and test the process. Once you have this working, do all of the following:
client instance to connect to the server.puppetserver instance.client instance.client instance to the puppetserver instance.client instance again to observe the module convergence.For extra credit, go on to perform advanced configuration changes: