Ticket #183: Create Node Resources and Develop Basic Module - SupaHotBall/OE2-Group-D GitHub Wiki

Task

  • Create Node Resources:
  • Define node resources for each host in the Puppet manifest.
  • Test node-specific configurations.
  • Create Your First Basic Module:
  • Follow Lab 3.2 instructions for module creation.
  • Test the connection by applying a sample manifest.

Steps Taken

Create directories under /etc/puppetlabs/code/modules

sudo mkdir /etc/puppetlabs/code/modules/sudo

image

Follow the same process to create the remaining directories

sudo mkdir /etc/puppetlabs/code/modules/sudo/files
sudo mkdir /etc/puppetlabs/code/modules/sudo/templates
sudo mkdir /etc/puppetlabs/code/modules/sudo/manifests

image

Create the file init.pp in the directory /etc/puppetlabs/code/modules/sudo/manifests

sudo nano init.pp

image

Edit the init.pp file with the following code

class sudo {
    package { 'sudo':
        ensure => present,
    }

    file { '/etc/sudoers':
        owner   => 'root',
        group   => 'root',
        mode    => '0440',
        source  => 'puppet:///modules/sudo/etc/sudoers',
        require => Package['sudo'],
    }
}

image

Create the directory sudo mkdir -p /etc/puppetlabs/code/modules/sudo/files/etc/

Then copy the sudoers file into that directory with

sudo cp /etc/sudoers /etc/puppetlabs/code/modules/sudo/files/etc/sudoers

image

Edit the site.pp file in the manifests to include sudo under the node resource for the DB server

image

Set the ownership of the files/directory and all contents to the Puppet user to ensure there are no permission issues.

sudo chown -R puppet:puppet /etc/puppetlabs/code/modules/sudo/files/

image

Restart the puppet server so that the changes apply.

sudo systemctl restart puppetserver

In the (agent) DB server, start the configuration manually

sudo puppet agent --server=mgmt-d --no-daemonize --verbose --onetime

image

To configure for the remaining servers, edit the site.pp file to include sudo in all of them.

image

Ensure that all ca certificates are signed by the management server.

sudo puppetserver ca list
sudo puppetserver ca sign --all

Backup Server:

image

Apps Server:

image


Challenges

I had permission issues when trying to access the puppet directories but found the command to change the ownership to Puppet which resolved the permission issues.


External Resources

N/A


Ticket Reference

https://rt.dataraster.com/Ticket/Display.html?id=183