Last active
February 20, 2018 08:37
-
-
Save ripienaar/b57bcd5081e2de73d438f4e220d333df to your computer and use it in GitHub Desktop.
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
# playbook to find all puppet servers via PQL discovery | |
# disable puppet on them and wait for them to idle | |
# up to 200 seconds, if any fail to idle by then | |
# an error is raised | |
# | |
# this is run via: | |
# | |
# mco playbook run acme::test --modulepath /path/to/modules | |
# | |
plan acme::disable_and_wait { | |
$r = acme::puppet::disable_and_wait(acme::puppet::nodes()) | |
notice(sprintf("%d nodes have been disabled and completed their catalogs", $r.count)) | |
} |
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
# Disables Puppet on given nodes | |
# | |
# @param nodes which nodes to act on | |
function acme::puppet::disable ( | |
Choria::Nodes $nodes | |
) >> Choria::TaskResults { | |
choria::task( | |
"action" => "puppet.disable", | |
"nodes" => $nodes, | |
"fail_ok" => true, | |
"silent" => true | |
) | |
} |
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
# Disables Puppet on given nodes and wait for it to complete any in-progress catalog applies | |
# | |
# @param nodes which nodes to act on | |
# @param wait how long to wait for puppet nodes to idle, check will happen 10 times | |
function acme::puppet::disable_and_wait ( | |
Choria::Nodes $nodes, | |
Integer $wait = 200 | |
) >> Choria::TaskResults { | |
acme::puppet::disable($nodes) | |
choria::task( | |
"action" => "puppet.status", | |
"nodes" => $nodes, | |
"assert" => "idling=true", | |
"tries" => 10, | |
"try_sleep" => $wait / 10, | |
"silent" => true | |
) | |
} |
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
# Discovers all nodes running the Puppet agent | |
# | |
# @param method the discovery method to use | |
function acme::puppet::nodes ( | |
String $method = "choria" | |
) >> Choria::Nodes { | |
choria::discover( | |
discovery_method => $method, | |
agents => ["puppet"], | |
uses => { | |
puppet => "> 1.0.0" | |
} | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment