Chapter 8. Controlling Puppet Agent

In the previous chapter, we showed how to use Puppet to install and configure MCollective. In this chapter, we’re going to show you how MCollective can:

  • Use the Puppet classes applied to the node in filters

  • Use facts known by Puppet in filters

  • Query, start, stop, and restart the Puppet agent

  • Run the Puppet agent with special command-line options

  • Query and make changes to the node using Puppet resources

If you are using Puppet, you will be quite happy with the level of control MCollective gives you. MCollective allows new ways of using Puppet that simply aren’t possible from agent, cron-run, or even command-line usage of Puppet.

Install the Puppet Agent

The first thing we need to do is install the MCollective Puppet agent. Installation of this is identical to the agents we installed in Chapter 5. Since we know you have Puppet installed, we’ll dispense with the command-line installation and show you to do it with Puppet: 

node nodename {
  mcollective::plugin::agent  { 'puppet': }  # for servers
  mcollective::plugin::client { 'puppet': }  # for clients
}

If you use Hiera, you can install the agent with a simple listing of the Puppet agent in the mcollective::plugin::agents array. In this example, we’re going to show you an example where we set the Puppet agent dependencies to ensure that the Puppet client is installed on the host:

 mcollective::plugin::agents: puppet: version: latest dependencies: - Package[%{puppet::client::package_name}] ...

Get Learning MCollective now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.