Thursday, September 14, 2023

DEVCOR - Infrastructure as Code - Puppet Commands

 Over the next series of blog posts I'm going to set out the commands required in order is install and run Infrastructure as Code solutions - Puppet, Chef, Ansible, Terraform.

I'm not going to go in to any depth on explanations per say, these are meant to be command guide posts allowing you to ensure you have correct sequence of events in mind and can easily identify answers if they ask 'Which command do you use to execute XYZ' or perhaps a drag and drop type question stating 'Put these commands in the correct order'

So lets start with Puppet.

Assume we are installing the server and agent on Ubuntu servers. 

1) Download Puppet using wget:
 $ wget

2) Install Puppet with dpkg utility:
 $ sudo dpkg -i puppet7-release-focal.deb

3) Run an update to ensure you have all the latest package information:
 $ sudo apt-get update

4) Install the Puppet Server:
$ sudo apt-get install puppetserver

5a) Start the Puppet Server service:
$ sudo systemctl start puppetserver
$ sudo systemctl enable puppetserver

5b) Check the Puppet Service is running:
$ sudo systemctl status puppetserver

Puppet Server is now installed.

Now lets install the Puppet Agent, go to your server/destination that will be running the agent.

1) Install the Puppet Agent
$ sudo apt-get install puppet-agent

2a) Add the package binaries to the Ubuntu executable path, first run the Puppet Agent profile script
$ source /etc/profile.d/

2b) Next, check the executable path is as expected:
$ echo $PATH
      *Note output should contain - : /opt/puppetlabs/bin - at the end of the line.

3) Confirm Puppet is install correctly and check the version is as expected:*
$ puppetserver -v
$ puppet -V
$ puppet agent -V

       * Note - the lowercase v for the puppetserver cmd and the uppercase V for the puppet cmds.

4a) Configure the Puppet Server destination that the Puppet Agent targets:
$ sudo puppet config set server
* obviously set this to whatever your server FQDN is

4b) Confirm this is correct by checking the puppet.conf file:
$ cat /etc/puppetlabs/puppet/puppet.conf

5) Start the Puppet Agent service:
$ sudo puppet reseource service puppet state-running

6) Test the Puppet Agent connectivity
$ sudo puppet agent --test

No comments:

Post a Comment