Category Archives: Puppet

Puppet – Restart a service after a file has changed

After we have used Puppet to update a service config file, we would like to restart the service so as to apply the new changes to the service.

Say for example, we want to keep the SSH service alive and whenever the /etc/ssh/sshd_config is synchronized from the Puppet server, restart the SSH service. This can be done as follow.
Continue reading Puppet – Restart a service after a file has changed

Puppet – Get the IP address of your Puppet Agent by Facts

In Puppet, there are a bunch of core facts which are are available for developer to get the Puppet Agent information such as the IP address of a specific network interface card and the free memory. The following piece of code snippet is a very good example on using facts in the manifest.

file {'puppet_facts_example':
  ensure  => file,
  path    => '/tmp/puppet_facts_example.txt',
  mode    => 0644,
  content => "This Learning Puppet VM's IP address is ${ipaddress}. It thinks its
    hostname is ${fqdn}, but you might not be able to reach it there
    from your host machine. It is running ${operatingsystem} ${operatingsystemrelease} and
    Puppet ${puppetversion}.
    Web console login:
    URL: https://${ipaddress_eth0}
    User: puppet@example.com
    Password: learningpuppet",
}

 

You can find the list of Puppet core facts in the reference link below.

Done =)

Reference:

Puppet – Check agent certname

Puppet allows you to serve files from any mount points which is configured in <puppet root>/fileserver.conf.

 

We can use 3 placeholders when setting up the mount points as stated in the comment.

# ...
# Mount points may also use three placeholders as part of their path:
#
# %H - The node's certname.
# %h - The portion of the node's certname before the first dot. (Usually the
#      node's short hostname.)
# %d - The portion of the node's certname after the first dot. (Usually the
#      node's domain name.)
# ...

Continue reading Puppet – Check agent certname