Puppet Module - KeegMitch/Operations-Engineering-group-c GitHub Wiki

Creating the Module

BEFORE you get to this stage, make sure the puppet servers and puppet agents are configured properly and can communicate with each other

  1. Create the following directories, all under /etc/puppetlabs/code/modules on your mgmt server.
sudo
sudo/files
sudo/templates
sudo/manifests
  1. Inside the sudo/manifests directory, create this file: init.pp Every module must have this basic structure.

  2. Add the following contents init.pp file using sudo vim init.pp:

class sudo {
package { ’sudo’:
ensure => present,
}
file { ’/etc/sudoers’:
owner => ’root’,
group => ’root’,
mode => ’0440’,
source => ’puppet:///modules/sudo/etc/sudoers’,
require => Package[’sudo’],
}
}
  1. Place a copy of a sudoers file in the module. Copy the sudoers file using sudo cp /etc/sudoers /etc/puppetlabs/code/modules/sudo/files/etc/sudoers

5.Change permissions to chmod 755

Apply the module to a node

  1. Add one line to the end of the site.pp file,which is located in this path: /etc/puppetlabs/code/environments/production/manifests/site.pp , include sudo

image

  1. Watch the agent apply configuration: sudo /opt/puppetlabs/puppet/bin/puppet agent --server=mgmt-c --no-daemonize --verbose --onetime

You can now use the alias test_puppet_agent and connect_puppet_agent

Note: To access the puppet modules directory, I have now added an alias called puppet_modules , which directs us to the directory where we configure our own modules