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
- Create the following directories, all under
/etc/puppetlabs/code/moduleson yourmgmtserver.
sudo
sudo/files
sudo/templates
sudo/manifests
-
Inside the
sudo/manifestsdirectory, create this file:init.ppEvery module must have this basic structure. -
Add the following contents
init.ppfile usingsudo 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’],
}
}
- 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
- Add one line to the end of the
site.ppfile,which is located in this path:/etc/puppetlabs/code/environments/production/manifests/site.pp,include sudo
- 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