Mcollective mco Cheat Sheet
MCollective is a server orchestration tool that is built by Puppet Labs.
Finding/listing hosts
List all
mco find
With specific puppet classes
mco find --with-class apache
mco find --with-class postgres::server
With specific fact values
mco find --with-fact is_virtual=true --with-fact 'processorcount >= 12'
Ping
mco ping
You can use the same filters as shown above with mco find.
Ping all servers containing "test" in their name
mco ping -I /test/
Service
Who's running apache?
mco service httpd status
Restart a service on all, but avoid thundering herd by splaying in batches, e.g. 3 at a time
mco service puppet restart --batch 3 --batch-sleep 3
Process
mco process list elasticsearch
mco process list jboss
mco process list httpd
File
Create a file /tmp/fooj on test12
mco puppet resource file /tmp/fooj ensure=file mode=0440 owner=root -I test12
The filemgr command is probably more suited for file management tasks. See https://github.com/puppetlabs/mcollective-filemgr-agent
Directory listing
mco rpc filemgr status dirlist=true file=/usr/local/java
Yum
See https://github.com/slaney/mcollective-plugins
sudo mco rpc yum install package=telnet
sudo mco rpc yum update package=rkhunter
Puppet
If you care about the graphs displayed in summary, you'll need to set your putty encoding to utf-8 and use a font like DejaVu.
mco puppet summary
mco puppet count
mco puppet status
Invoke a puppet run on a specific server
mco puppet runonce -I test02
It's OK to do puppet runonce on multiple hosts. By default, puppet will splay its runs to avoid a thundering herd.