Tuesday, 21 June 2016

Mcollective and Regexp Host filters

Again another post just to remind me how things work with Mcollective.
We can provide the mco command with a host identity filter that would direct it to execute commands on certain hosts only.
Mcollective supports ruby regular expressions.
check them at: http://ruby-doc.org/core-2.3.1/Regexp.html

The command looks like this:

mco puppet runonce -I "/^myserv.*/"

This will match any host within the puppert resources that has a hostname starting with the string "myserv".
The key here is that when working on large scale projects this command would be able to save me a loop on all the affected nodes.

The command will of course run puppet once, but again this can be used with any mcollective plugin.



No comments:

Post a Comment