diff --git a/lib/ansible/modules/source_control/hg.py b/lib/ansible/modules/source_control/hg.py index 7c538e6b4e9..9cb9e979827 100644 --- a/lib/ansible/modules/source_control/hg.py +++ b/lib/ansible/modules/source_control/hg.py @@ -157,7 +157,7 @@ class Hg(object): def get_remote_revision(self): (rc, out, err) = self._command(['id', self.repo]) if rc != 0: - self.module_fail_json(msg=err) + self.module.fail_json(msg=err) else: return to_native(out).strip('\n') diff --git a/test/integration/targets/hg/tasks/main.yml b/test/integration/targets/hg/tasks/main.yml index 03b3458ede6..f9c1b1494bf 100644 --- a/test/integration/targets/hg/tasks/main.yml +++ b/test/integration/targets/hg/tasks/main.yml @@ -72,3 +72,15 @@ assert: that: - "not hg_result2.changed" + +- name: Checkout non-existent repo clone + hg: repo=https://bitbucket.org/pyro46/pythonscript_1 clone=no update=no + register: hg_result3 + ignore_errors: true + +- name: Verify result of non-existent repo clone + assert: + that: + - hg_result3.msg + - "'abort: HTTP Error 404: Not Found' in hg_result3.msg" + - "not hg_result3.changed"