forked from ungleich-public/cdist
		
	begin support for sensible exit codes of cdist
Signed-off-by: Nico Schottelius <nico@brief.schottelius.org>
This commit is contained in:
		
					parent
					
						
							
								53ca7e7aca
							
						
					
				
			
			
				commit
				
					
						d3b9aa6769
					
				
			
		
					 1 changed files with 15 additions and 8 deletions
				
			
		
							
								
								
									
										23
									
								
								bin/cdist
									
										
									
									
									
								
							
							
						
						
									
										23
									
								
								bin/cdist
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -91,13 +91,13 @@ def commandline():
 | 
			
		|||
        logging.root.setLevel(logging.DEBUG)
 | 
			
		||||
 | 
			
		||||
    log.debug(args)
 | 
			
		||||
    args.func(args)
 | 
			
		||||
    return args.func(args)
 | 
			
		||||
 | 
			
		||||
def config(args):
 | 
			
		||||
    configinstall(args, mode=cdist.config.Config)
 | 
			
		||||
    return configinstall(args, mode=cdist.config.Config)
 | 
			
		||||
 | 
			
		||||
def install(args):
 | 
			
		||||
    configinstall(args, mode=cdist.install.Install)
 | 
			
		||||
    return configinstall(args, mode=cdist.install.Install)
 | 
			
		||||
 | 
			
		||||
def configinstall(args, mode):
 | 
			
		||||
    """Configure or install remote system"""
 | 
			
		||||
| 
						 | 
				
			
			@ -140,6 +140,7 @@ def configinstall(args, mode):
 | 
			
		|||
        if len(failed_hosts) > 0:
 | 
			
		||||
            log.warn("Failed to deploy to the following hosts: " + 
 | 
			
		||||
                " ".join(failed_hosts))
 | 
			
		||||
            exit_code = 1
 | 
			
		||||
 | 
			
		||||
        time_end = time.time()
 | 
			
		||||
        log.info("Total processing time for %s host(s): %s", len(args.host),
 | 
			
		||||
| 
						 | 
				
			
			@ -203,6 +204,8 @@ if __name__ == "__main__":
 | 
			
		|||
    # Sys is needed for sys.exit()
 | 
			
		||||
    import sys
 | 
			
		||||
 | 
			
		||||
    exit_code = 0
 | 
			
		||||
 | 
			
		||||
    try:
 | 
			
		||||
        import logging
 | 
			
		||||
        import os
 | 
			
		||||
| 
						 | 
				
			
			@ -226,11 +229,15 @@ if __name__ == "__main__":
 | 
			
		|||
        logging.basicConfig(format='%(levelname)s: %(message)s')
 | 
			
		||||
 | 
			
		||||
        if re.match("__", os.path.basename(sys.argv[0])):
 | 
			
		||||
            emulator()
 | 
			
		||||
            run = emulator()
 | 
			
		||||
        else:
 | 
			
		||||
            commandline()
 | 
			
		||||
 | 
			
		||||
        sys.exit(0)
 | 
			
		||||
            run = commandline()
 | 
			
		||||
 | 
			
		||||
    except KeyboardInterrupt:
 | 
			
		||||
        sys.exit(0)
 | 
			
		||||
        pass
 | 
			
		||||
 | 
			
		||||
    # Determine exit code by return value of function
 | 
			
		||||
    if not run:
 | 
			
		||||
        exit_code = 1
 | 
			
		||||
 | 
			
		||||
    sys.exit(exit_code)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue