Puppet - Combining Resource Types in a Single Manifest

 

Exercise 5 - Combining Puppet Resource Types

 Create a file apache.pp in master terminal window and add the following text to it. In this file we add 3 resources to our system

cd /etc/puppet/manifests

nano apache.pp

package {“apache2”:

ensure => installed,

}

file {“/etc/apache2/sites-enabled/000-default.conf”:

ensure => file,

content => ‘<VirtualHost *:80>

DocumentRoot /var/www/html

ErrorLog ${APACHE_LOG_DIR}/error.log

CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>’,

notify => Service[“apache2”],

}

service {“apache2”:

ensure => running,

require => Package[“apache2”],

}

 Go to the master terminal and run this command.

puppet apply apache.pp

 Go to the master terminal and update apache.pp to add the following

package {“apache2”:

ensure => installed,

}

file {“/etc/apache2/sites-enabled/000-default.conf”:

ensure => file,

content => ‘<VirtualHost *:80>

DocumentRoot /var/www/html

ErrorLog /var/log/apache2/error.log

CustomLog /var/log/apache1/access.log combined

</VirtualHost>’,

notify => Service[“apache2”],

}

service {“apache2”:

ensure => running,

require => Package[“apache2”],

}

 Go to the master terminal and run this command.

puppet apply apache.pp

 This will trigger a restart of apache service because of the dependency defined in your manifest file. Check that the apache service has been restarted and is running

ps aux | grep apache

Comments

Popular posts from this blog

Different Types of Reports in Scrum - Agile

Terraform

Scrum Master Interview help - Bootcamp