diff --git a/lib/ansible/modules/system/open_iscsi.py b/lib/ansible/modules/system/open_iscsi.py index 7e9be9b4f91..e7830d68ff5 100644 --- a/lib/ansible/modules/system/open_iscsi.py +++ b/lib/ansible/modules/system/open_iscsi.py @@ -171,7 +171,7 @@ def target_loggedon(module, target): module.fail_json(cmd=cmd, rc=rc, msg=err) -def target_login(module, target): +def target_login(module, target, portal=None, port=None): node_auth = module.params['node_auth'] node_user = module.params['node_user'] node_pass = module.params['node_pass'] @@ -187,6 +187,9 @@ def target_login(module, target): module.fail_json(cmd=cmd, rc=rc, msg=err) cmd = '%s --mode node --targetname %s --login' % (iscsiadm_cmd, target) + if portal is not None and port is not None: + cmd += ' --portal %s:%s' % (portal, port) + (rc, out, err) = module.run_command(cmd) if rc > 0: @@ -333,7 +336,7 @@ def main(): result['devicenodes'] = target_device_node(module, target) elif not check: if login: - target_login(module, target) + target_login(module, target, portal, port) # give udev some time time.sleep(1) result['devicenodes'] = target_device_node(module, target)