After learning how to install Puppet – Foreman and Provisioning in Vagrant we will give here an example. In this example we will create two virtual machines:
– One of them will be the Puppet server with Foreman and the other will be a computer with Puppet agent.
– After everything is completed we will go to Foreman and check if everything works as intended.
In the example above we define
– Two machines,
– A host only network for the two machines to interact,
– Their hostnames
– Port forwarding to connect to Foreman
– RAM and CPU details of the Puppet server
– Provisioning files of the machines
This is the code to install Puppet and Foreman. Refer to “Puppet and Foreman Installation” if you need more details.
This code install the puppet agent and makes the necessary configuration:
– First 4 lines installs the agent.
– 5. line adds the IP and FQDN of the server to hosts file
– 6. line adds the server details to the puppet.conf file
– 7. line enables the puppet agent service
– 8. line restart the service
– 9. line run puppet agent in test mode. This will ensure that it tries to connect to server and a certificate will be issued.
After creating all of the files. Run “
vagrant up” and take a cup of coffee.
After all of the setup finishes: run “
vagrant ssh box1” command and “
cat /tmp/foreman.log” to see the foreman password. And go to https://localhost:4443 in your host machine. Use admin and the password in the log file to login.
After logging in check the smart proxy configuration under “
Infrastructure --> Smart Proxies ” and click “
There you will see a list of connected agents. The agents that are not signed yet will be seen with “
Click “Sign” and goto “
Hosts --> All hosts” if you do not see the newly signed client it will be available when it connects to server. If you one to see immediately. ssh to box2 and run “
sudo puppet agent --test” after that refresh the hosts list and you will see the new client.
If there are any certificate mismatch errors:
– Delete the certificate from smart proxy and also from client machine.
– To delete from client in our example use “
sudo find /var/lib/puppet/ssl -name ubuntutest.pem -delete“.
– Lastly run “
sudo puppet agent --test” in client again, sign it again in smart proxy. Run “
sudo puppet agent --test” one last time in box2 and see if you see the screen below:
This post is completed here.