diff --git a/README.md b/README.md index 4458f2c..77b5086 100644 --- a/README.md +++ b/README.md @@ -162,5 +162,179 @@ Congratulations! Your Puppet Master and Puppet Agent are now set up and running.  -Happy learning! +# script and instructions for setting up a Puppet manifest on the Master node and applying it on the Slave node. Here's a cleaned-up version of your instructions: + +### Master Node: + +1. **Navigate to the Puppet directory:** + ```bash + cd /etc/puppetlabs + ``` + +2. **List the contents:** + ```bash + ls + ``` + +3. **Navigate to the code directory:** + ```bash + cd code + ``` + +4. **List the contents:** + ```bash + ls + ``` + +5. **Create the necessary directories:** + ```bash + sudo mkdir -p environments/production/manifests/ + ``` + +6. **Navigate to the manifests directory:** + ```bash + cd environments/production/manifests/ + ``` + +7. **Create a new manifest file (`site.pp`):** + ```bash + sudo nano site.pp + ``` + +8. **Add the following content to the `site.pp` file:** + ```puppet + node default { + # 1st resource: Install Nginx + package { 'nginx': + ensure => installed, + } + + # 2nd resource: Create a status file + file { '/tmp/status.txt': + content => 'Nginx has been installed successfully', + mode => '0644', + } + } + ``` + +9. **Save and exit the editor:** + - Press `Ctrl + X` to exit. + - Press `Y` to confirm saving. + - Press `Enter` to save the file with the same name. + +### Slave Node: + +1. **Apply the Puppet catalog:** + ```bash + sudo /opt/puppetlabs/bin/puppet agent --test + ``` + +2. **Verify Nginx installation:** + - Copy the public IP of the slave node. + - Open a web browser and paste the IP. + - Hit `Enter` to check if it shows the Nginx default page. + +3. **Check the content of the status file:** + ```bash + cat /tmp/status.txt + ``` + - It should display: `Nginx has been installed successfully`. + +This should guide you through setting up your Puppet manifest and verifying its application on the slave node. + +# an example of a simple Puppet module that manages the installation and configuration of the Apache web server on a Linux system. + +### On the Puppet Master Server + +1. **Create the Module Directory Structure**: + ```bash + sudo mkdir -p /etc/puppetlabs/code/environments/production/modules/apache_example/{manifests,templates} + ``` + +2. **Create the `init.pp` Manifest**: + ```bash + sudo nano /etc/puppetlabs/code/environments/production/modules/apache_example/manifests/init.pp + ``` + + Add the following content: + ```puppet + class apache_example { + package { 'apache2': + ensure => 'installed', + } + + service { 'apache2': + ensure => 'running', + enable => true, + require => Package['apache2'], + } + + file { '/var/www/html/index.html': + ensure => 'file', + content => template('apache_example/index.html.erb'), + require => Package['apache2'], + } + } + ``` + +3. **Create the `index.html.erb` Template**: + ```bash + sudo nano /etc/puppetlabs/code/environments/production/modules/apache_example/templates/index.html.erb + ``` + + Add the following content: + ```html + +
+