Greetings !

Actually we need to do this before nagios set up so that host names do not change.

As of now you can stop the running instances and create 2 new instances for Puppet master and Puppet Agent and perform the below steps.

1) Login to both the instances 
2) Create a root password for both
3) Edit /etc/hostname file for both instances as below :
  •    Instance 1 : puppetmaster.edureka.com
  •    Instance 2 : puppetclient.edureka.com
4) Edit /etc/hosts file for both instances :
  • Instance 1 : Add the private ip of puppetclient and hostname of puppetclient and this word "puppet client "
  • Instance 2 : Add the private ip of puppetmaster and hostname of puppetmaster and these words " puppetmaster" "puppet"
So, /etc/hosts file in both the machines should have details of both master and slave like shown below :

192.168.1.17 puppetclient.edureka.com puppetclient
192.168.1.16 puppetmaster.edureka.com puppetmaster puppet

6) Login as root on both instances and reboot the machines

7) Instance 1 : sudo apt-get update
                        sudo apt install puppetmaster
   
    Instance 2 : sudo apt-get update
                        sudo apt install puppet

8) Now we will set the example to check :

 sudo mkdir -p /etc/puppet/modules/apache2/manifests
 
 sudo nano /etc/puppet/modules/apache2/manifests/init.pp

Enter below lines in init.pp file we created above

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

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

sudo nano /etc/puppet/manifests/site.pp 

Enter below lines in the created site.pp file above

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

Restart master daemon

sudo systemctl restart puppetmaster.service

On Instance 2 run below command :

sudo systemctl start puppet.service

sudo puppet agent --fingerprint

On Instance 1 Run below command :

sudo puppet cert list
sudo puppet cert sign puppetclient.edureka.com

On Instance 2 Run below command

sudo puppet agent --test

This should install puppet successfully, create certificate and pass it to master and install the apache2 in your instance 2 successfully.

Let us know if you need any further help.







336999