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
					Monty Taylor
				
			
				
					committed by
					
						 Jeremy Stanley
						Jeremy Stanley
					
				
			
			
				
	
			
			
			 Jeremy Stanley
						Jeremy Stanley
					
				
			
						parent
						
							aace25f971
						
					
				
				
					commit
					7a4e51d65e
				
			| @@ -119,11 +119,14 @@ def bootstrap_server(server, admin_pass, key, cert, environment, name, | |||||||
|     ssh_client.scp("/var/lib/puppet/ssl/certs/ca.pem", |     ssh_client.scp("/var/lib/puppet/ssl/certs/ca.pem", | ||||||
|                    "/var/lib/puppet/ssl/certs/ca.pem") |                    "/var/lib/puppet/ssl/certs/ca.pem") | ||||||
|  |  | ||||||
|     ssh_client.ssh("puppet agent " |     (rc, output) = ssh_client.ssh( | ||||||
|                    "--environment %s " |         "puppet agent " | ||||||
|                    "--server %s " |         "--environment %s " | ||||||
|                    "--no-daemonize --verbose --onetime --pluginsync true " |         "--server %s " | ||||||
|                    "--certname %s" % (environment, puppetmaster, certname)) |         "--detailed-exitcodes " | ||||||
|  |         "--no-daemonize --verbose --onetime --pluginsync true " | ||||||
|  |         "--certname %s" % (environment, puppetmaster, certname)) | ||||||
|  |     utils.interpret_puppet_exitcodes(rc, output) | ||||||
|  |  | ||||||
|     ssh_client.ssh("reboot") |     ssh_client.ssh("reboot") | ||||||
|  |  | ||||||
|   | |||||||
| @@ -205,3 +205,24 @@ def delete_server(server): | |||||||
|  |  | ||||||
|     print "Deleting server", server.id |     print "Deleting server", server.id | ||||||
|     server.delete() |     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") | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user