Add detailed-exitcodes to launch_node

We've got the logic elsewhere to properly deal with puppet bizarre exit
code strategy. Put it in launch_node too.

Change-Id: I4a414a27b58b2d4d890020f4b2aaed50f7c8f26b
This commit is contained in:
Monty Taylor 2014-10-21 12:13:18 -05:00 committed by Jeremy Stanley
parent aace25f971
commit 7a4e51d65e
2 changed files with 29 additions and 5 deletions

View File

@ -119,11 +119,14 @@ def bootstrap_server(server, admin_pass, key, cert, environment, name,
ssh_client.scp("/var/lib/puppet/ssl/certs/ca.pem",
"/var/lib/puppet/ssl/certs/ca.pem")
ssh_client.ssh("puppet agent "
(rc, output) = ssh_client.ssh(
"puppet agent "
"--environment %s "
"--server %s "
"--detailed-exitcodes "
"--no-daemonize --verbose --onetime --pluginsync true "
"--certname %s" % (environment, puppetmaster, certname))
utils.interpret_puppet_exitcodes(rc, output)
ssh_client.ssh("reboot")

View File

@ -205,3 +205,24 @@ def delete_server(server):
print "Deleting server", server.id
server.delete()
def interpret_puppet_exitcodes(rc, output):
if rc == 0:
# success
return
elif rc == 1:
# rc==1 could be because it's disabled
# rc==1 could also mean there was a compilation failure
disabled = "administratively disabled" in output
if disabled:
msg = "puppet is disabled"
else:
msg = "puppet did not run"
raise Exception(msg)
elif rc == 2:
# success with changes
return
elif rc == 124:
# timeout
raise Exception("Puppet timed out")