Skip to content
This repository has been archived by the owner on Jun 29, 2022. It is now read-only.

Commit

Permalink
Check the exit code and signal status of ansible playbook process to …
Browse files Browse the repository at this point in the history
…determine final output or error message.
  • Loading branch information
chambridge committed Aug 3, 2017
1 parent f9cae98 commit 3494c6d
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions rho/scancommand.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ def run_ansible_with_vault(cmd_string, vault_pass, ssh_key_passphrase=None,
child.sendline(ssh_key_passphrase)
child.logfile = logfile
child.expect(pexpect.EOF)
return child.before
return child
except pexpect.EOF:
print(str(result))
print('pexpect unexpected EOF')
Expand Down Expand Up @@ -396,9 +396,13 @@ def _do_command(self):
# process finally runs ansible on the
# playbook and inventories thus created.
print('Running:', cmd_string)
run_ansible_with_vault(cmd_string, vault_pass)

print(_("Scanning has completed. The mapping has been"
" stored in file 'data/" + self.options.profile +
"_host_auth_mapping'. The facts have been stored in '" +
report_path + "'"))
process = run_ansible_with_vault(cmd_string, vault_pass)
process.close()
if process.exitstatus == 0 and process.signalstatus is None:
print(_("Scanning has completed. The mapping has been"
" stored in file 'data/" + self.options.profile +
"_host_auth_mapping'. The facts have been stored in '" +
report_path + "'"))
else:
print(_("An error has occurred during the scan. Please review" +
" the output to resolve the given issue."))

0 comments on commit 3494c6d

Please sign in to comment.