#182: Create Node Resources and Develop Basic Module - Rmhibbert/oe2-group-c GitHub Wiki
Step by step
Creating the module
Description: Navigate to the Puppet modules directory on your management server.
Command: cd /etc/puppetlabs/code/modules
Creating Required Directories
Description: Create the necessary directory structure for the sudo module.
Command: mkdir -p sudo/files sudo/templates sudo/manifests
Creating the init.pp Manifest File
Description: Every Puppet module requires an init.pp file inside the manifests directory.
Command: cd manifests
then sudo touch init.pp
Editing init.pp
Description: Open init.pp in a text editor and add the following Puppet class definition.
Command: nano sudo/manifests/init.pp
Content of 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'], } }
Add include sudo
Description: Add include sudo into the site.pp file in management server
Command: include sudo
Adding the sudoers Configuration File
Description: Copy a verified sudoers file into the module’s files directory.
Command: cp /etc/sudoers /etc/puppetlabs/code/modules/sudo/files/etc/sudoers
Change Ownership of the sudoers File
Description: Ensure that the sudoers file is owned by the puppet user and group
Command: sudo chown -R puppet:puppet /etc/puppetlabs/code/modules/sudo/files/
Restart the puppetserver
Description: Restart the puppetserver on management server
Command: sudo systemctl restart puppetserver
Run the Puppet Agent
Description: Execute the following command on the node to apply the configuration
Command: sudo /opt/puppetlabs/bin/puppet agent --server=mgmt-c --no-daemonize --verbose --onetime
Challenges
I was having trouble applying the configuration as it kept giving me errors. Additionally, the command provided for applying the configuration was incorrect—I only needed to use the server name mgmt-c instead of the full mgmt-c.oe2.org.nz.