From ac7e62ec08d10df30b76ffd035b8d449a1a097d9 Mon Sep 17 00:00:00 2001 From: Colins-Git <34700833+Colins-Git@users.noreply.github.com> Date: Tue, 30 Jan 2018 15:03:35 -0800 Subject: [PATCH] open_iscsi fails to login when discovery returns multiple portals #29309 (#35262) --- lib/ansible/modules/system/open_iscsi.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) 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)