Modules

Install module on Puppet master

/opt/puppetlabs/bin/puppet module install <name of module>

Uninstall module on Puppet master

/opt/puppetlabs/bin/puppet module uninstall <name of module>

Resource: https://www.puppetcookbook.com/posts/installing-modules-from-the-puppet-forge.html

List installed Modules

puppet module list

Resource: https://puppet.com/docs/puppet/5.3/modules_installing.html

Show module path

Run this on the puppet master:

puppet config print modulepath

Resource: https://puppet.com/docs/puppet/5.5/dirs_modulepath.html

Change module install path

By default, puppet module install installs modules into the first directory in the Puppet modulepath, which defaults to $codedir/environments/production/modules.

To change this, set the modulepath in /etc/puppetlabs/code/environments/{environment_name}/environment.conf

Resource: https://serverfault.com/questions/705623/install-a-puppet-module-to-the-global-modules-directory-by-default

Manifests

Validate syntax of manifest

puppet parser validate /etc/puppetlabs/code/environments/production/modules/hello_world/manifests/init.pp

Do a dry run of a manifest

puppet apply --noop /etc/puppetlabs/code/environments/production/modules/hello_world/manifests/init.pp

List all agents connected to server

puppetserver ca list --all

For puppermasters (older):

puppet cert list --all

Get the information from site.pp:

grep -io 'node .* ' /etc/puppet/manifests/site.pp

Resources: https://www.linuxnix.com/puppet-list-all-the-nodes-in-puppet-master/

Remove agent from server

puppetserver ca clean --certname <name of node>

Install multiple dependencies

init.pp:

class base (){
  class{'::base::config':}
}

packages.pp:

class base::packages inherits base {
 [
    'cmake',
    'jdk',
    'vim',
  ].each |$pkg| {
    package { $pkg:
      ensure   => latest,
      name     => $pkg,
      provider => 'yum'
    }
  }
}

Output machine info

notify { 'Machine Information':
  name     => 'mach_info',
  message  => "Running on ${::hostname} in the ${::environment} environment",
  withpath => true,
}

Show the run interval for a puppet agent

puppet agent --configprint runinterval

Resource: https://ask.puppet.com/question/2451/how-do-you-change-the-runinterval/

Provision with development environment

puppet agent -t --environment development