From e9f092d8ef58f1205f9f5f5c5a6ec0a9ac3e3593 Mon Sep 17 00:00:00 2001 From: Lorin Hochstein Date: Tue, 10 Jan 2017 23:00:45 -0800 Subject: [PATCH] Fix syntax error Remove trailing digits in module --- ch10/playbooks/library/can_reach | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/ch10/playbooks/library/can_reach b/ch10/playbooks/library/can_reach index fbfe520..3c78849 100644 --- a/ch10/playbooks/library/can_reach +++ b/ch10/playbooks/library/can_reach @@ -1,29 +1,29 @@ #!/usr/bin/python def can_reach(module, host, port, timeout): - nc_path = module.get_bin_path('nc', required=True) 1 + nc_path = module.get_bin_path('nc', required=True) args = [nc_path, "-z", "-w", str(timeout), host, str(port)] - (rc, stdout, stderr) = module.run_command(args) 2 + (rc, stdout, stderr) = module.run_command(args) return rc == 0 def main(): - module = AnsibleModule( 3 - argument_spec=dict( 4 - host=dict(required=True), 5 + module = AnsibleModule( + argument_spec=dict( + host=dict(required=True), port=dict(required=True, type='int'), - timeout=dict(required=False, type='int', default=3) 6 + timeout=dict(required=False, type='int', default=3) ), - supports_check_mode=True 7 + supports_check_mode=True ) # In check mode, we take no action # Since this module never changes system state, we just # return changed=False - if module.check_mode: 8 - module.exit_json(changed=False) 9 + if module.check_mode: + module.exit_json(changed=False) - host = module.params['host'] 10 + host = module.params['host'] port = module.params['port'] timeout = module.params['timeout'] @@ -31,7 +31,7 @@ def main(): module.exit_json(changed=False) else: msg = "Could not reach %s:%s" % (host, port) - module.fail_json(msg=msg) 11 + module.fail_json(msg=msg) -from ansible.module_utils.basic import * 12 +from ansible.module_utils.basic import * main() -- 2.44.0