|
|
|
@ -18,7 +18,7 @@
|
|
|
|
|
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
|
|
########################################################
|
|
|
|
|
from __future__ import (absolute_import)
|
|
|
|
|
from __future__ import (absolute_import, print_function)
|
|
|
|
|
__metaclass__ = type
|
|
|
|
|
|
|
|
|
|
__requires__ = ['ansible']
|
|
|
|
@ -38,10 +38,17 @@ import sys
|
|
|
|
|
from ansible.errors import AnsibleError, AnsibleOptionsError, AnsibleParserError
|
|
|
|
|
from ansible.utils.display import Display
|
|
|
|
|
|
|
|
|
|
########################################################
|
|
|
|
|
########################################
|
|
|
|
|
### OUTPUT OF LAST RESORT ###
|
|
|
|
|
class LastResort(object):
|
|
|
|
|
def error(self, msg):
|
|
|
|
|
print(msg, file=sys.stderr)
|
|
|
|
|
|
|
|
|
|
########################################
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
|
|
|
|
|
|
display = LastResort()
|
|
|
|
|
cli = None
|
|
|
|
|
me = os.path.basename(sys.argv[0])
|
|
|
|
|
|
|
|
|
@ -70,21 +77,24 @@ if __name__ == '__main__':
|
|
|
|
|
|
|
|
|
|
except AnsibleOptionsError as e:
|
|
|
|
|
cli.parser.print_help()
|
|
|
|
|
display.display(str(e), stderr=True, color='red')
|
|
|
|
|
display.error(str(e))
|
|
|
|
|
sys.exit(5)
|
|
|
|
|
except AnsibleParserError as e:
|
|
|
|
|
display.display(str(e), stderr=True, color='red')
|
|
|
|
|
display.error(str(e))
|
|
|
|
|
sys.exit(4)
|
|
|
|
|
# TQM takes care of these, but leaving comment to reserve the exit codes
|
|
|
|
|
# except AnsibleHostUnreachable as e:
|
|
|
|
|
# display.display(str(e), stderr=True, color='red')
|
|
|
|
|
# display.error(str(e))
|
|
|
|
|
# sys.exit(3)
|
|
|
|
|
# except AnsibleHostFailed as e:
|
|
|
|
|
# display.display(str(e), stderr=True, color='red')
|
|
|
|
|
# display.error(str(e))
|
|
|
|
|
# sys.exit(2)
|
|
|
|
|
except AnsibleError as e:
|
|
|
|
|
display.display(str(e), stderr=True, color='red')
|
|
|
|
|
display.error(str(e))
|
|
|
|
|
sys.exit(1)
|
|
|
|
|
except KeyboardInterrupt:
|
|
|
|
|
display.error("interrupted")
|
|
|
|
|
display.error("User interrupted execution")
|
|
|
|
|
sys.exit(99)
|
|
|
|
|
except Exception as e:
|
|
|
|
|
display.error("Unexpected Exception: %s" % str(e))
|
|
|
|
|
sys.exit(250)
|
|
|
|
|