diff --git a/launch/launch-node.py b/launch/launch-node.py index a750be323b..439f953b2c 100755 --- a/launch/launch-node.py +++ b/launch/launch-node.py @@ -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 " - "--environment %s " - "--server %s " - "--no-daemonize --verbose --onetime --pluginsync true " - "--certname %s" % (environment, puppetmaster, certname)) + (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") diff --git a/launch/utils.py b/launch/utils.py index a9f8d01bab..85d7b86c12 100644 --- a/launch/utils.py +++ b/launch/utils.py @@ -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")