Skip to content

Commit dbed896

Browse files
committed
Merge pull request #62 from yfried-redhat/playbook_exception
[execute] Raise IRPlaybookFailedException
2 parents 2e710e8 + d0566c1 commit dbed896

2 files changed

Lines changed: 8 additions & 5 deletions

File tree

cli/exceptions.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,10 @@ def __init__(self, env_var):
3535

3636

3737
class IRPlaybookFailedException(IRException):
38-
def __init__(self, playbook):
39-
super(self.__class__, self).__init__(
40-
'Playbook "%s" failed!' % playbook)
38+
def __init__(self, playbook, message=""):
39+
msg = 'Playbook "%s" failed!' % playbook
40+
msg = msg + message if message else msg
41+
super(self.__class__, self).__init__(msg)
4142

4243

4344
class IRYAMLConstructorError(IRException):

cli/execute.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,11 @@ def execute_ansible(playbook, args):
136136

137137
print ""
138138
if len(failed_hosts) > 0:
139-
raise Exception(2)
139+
raise exceptions.IRPlaybookFailedException(
140+
playbook, "Failed hosts: %s" % failed_hosts)
140141
if len(unreachable_hosts) > 0:
141-
raise Exception(3)
142+
raise exceptions.IRPlaybookFailedException(
143+
playbook, "Unreachable hosts: %s" % unreachable_hosts)
142144

143145

144146
def ansible_wrapper(args):

0 commit comments

Comments
 (0)