Run Puppet agent as a service

The puppet agent command can start a long-lived daemon process that does configuration runs at a set interval.

If you are running Puppet agent as a non-root user, use a cron job instead.

  1. Start the service.

    The best method is with Puppet agent’s init script / service configuration. When you install Puppet with packages, included is an init script or service configuration for controlling Puppet agent, usually with the service name puppet (for both open source and Puppet Enterprise).

    In open source Puppet, enable the service by running this command:

    sudo puppet resource service puppet ensure=running enable=true

    You can also run the sudo puppet agent command with no additional options which causes the Puppet agent to start running and daemonize, however you won’t have an interface for restarting or stopping it. To stop the daemon, use the process ID from the agent’s pidfile:

    sudo kill $(puppet config print pidfile --section agent)

  2. (Optional) Configure the run interval.

    The Puppet agent service defaults to doing a configuration run every 30 minutes. You can configure this with the runinterval setting in puppet.conf:

    # /etc/puppetlabs/puppet/puppet.conf
    [agent]
      runinterval = 2h

    If you don’t need frequent configuration runs, a longer run interval lets your primary Puppet server handle many more agent nodes.