Last active
December 10, 2021 16:51
-
-
Save snobear/831379a5c921e0da91e1 to your computer and use it in GitHub Desktop.
MCollective cheat sheet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# MCollective Cheat Sheet | |
MCollective is a server orchestration tool that is built by Puppet Labs and so is tightly integrated with the puppet infrastructure. Commands a run from the control aka "client" server. | |
## 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. | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment