Search code examples
puppetmcollective

How can I run Puppet 6 on-demand against multiple remote Linux nodes?


On Puppet 3, I used to use sudo mco puppet runonce -I /hostname-pattern-1/ -I /hostname-pattern-2/ to run Puppet agents on-demand against any node matching one of the hostname patterns.

As of Puppet 5.5.4, MCollective is deprecated, so I can no longer use the mco command.

With Puppet 6, how can I do what I used to be able to do with the mco command?

My server and all my nodes are running Ubuntu 20 (Linux). I'm specifically using Puppet 6.19.1 and Puppet Server 6.14.1.

I know puppet agent -t can be used to run Puppet on-demand, but that has to be done locally on each node, so how can I apply that command (or something equivalent) from the Puppet server to any node matching a pattern?

I know I could hardcode a bunch of hostnames in a Bash script and use SSH to remotely execute the command, but hardcoding hostnames is not as convenient as specifying hostname patterns.


Solution

  • Have you checked choria?

    Puppet Bolt might be another alternative, you could write a task to do something more complex, or just run ad-hoc commands

    e.g.

    bolt command run 'puppet agent -t' --targets servers
    

    You connect bolt to your puppetdb so you won't have to create and update a static inventory