Puppet scratch pad

This page is basically a scratch pad for simple but useful puppet commands. The more I take notes of these things the more prepared I'll be for the exam. This post will continue to grow.

  • Install a package at command line without a manifest
puppet apply -e 'package { "chrony": ensure => installed }'

We could just use yum/apt to install, but there is also the puppet way

  • Export manifest code (package, service examples)
puppet resource service chronyd

service { 'chronyd':
  ensure    => 'running',
  enable    => 'true',
  provider  => 'systemd',
}
puppet resource package chronyd

package { 'chrony':
  ensure    => '3.5-1.el8',
  provider  => 'dnf',
}

The output above can be pulled out as is and used to add/update manifests. It's a quick way to get some code written, rather than manually typing it all from memory. In the above examples we would take out provider as we don't want to limit the usefulness and in the package section we'd want to change that version to "installed", unless we wanted to specifically stick to one version.