Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

open-iscsi: adding mutual authentication support and updating authentication parameters description #3422

Merged
merged 9 commits into from
Sep 26, 2021
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
minor_changes:
- open-iscsi - Adding support for mutual authentication between target and initiator (https://github.com/ansible-collections/community.general/pull/3422).
ricsanfre marked this conversation as resolved.
Show resolved Hide resolved
29 changes: 25 additions & 4 deletions plugins/modules/system/open_iscsi.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,27 @@
aliases: [ state ]
node_auth:
description:
- The value for C(discovery.sendtargets.auth.authmethod).
- The value for C(node.session.auth.authmethod).
type: str
default: CHAP
node_user:
description:
- The value for C(discovery.sendtargets.auth.username).
- The value for C(node.session.auth.username).
type: str
node_pass:
description:
- The value for C(discovery.sendtargets.auth.password).
- The value for C(node.session.auth.password).
type: str
node_user_in:
description:
- The value for C(node.session.auth.username_in).
type: str
ricsanfre marked this conversation as resolved.
Show resolved Hide resolved
version_added: 3.8.0
node_pass_in:
description:
- The value for C(node.session.auth.password_in).
type: str
version_added: 3.8.0
auto_node_startup:
description:
- Whether the target node should be automatically connected at startup.
Expand Down Expand Up @@ -191,6 +201,8 @@ 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']
node_user_in = module.params['node_user_in']
node_pass_in = module.params['node_pass_in']

if node_user:
params = [('node.session.auth.authmethod', node_auth),
Expand All @@ -200,6 +212,13 @@ def target_login(module, target, portal=None, port=None):
cmd = [iscsiadm_cmd, '--mode', 'node', '--targetname', target, '--op=update', '--name', name, '--value', value]
module.run_command(cmd, check_rc=True)

if node_user_in:
params = [('node.session.auth.username_in', node_user_in),
('node.session.auth.password_in', node_pass_in)]
for (name, value) in params:
cmd = '%s --mode node --targetname %s --op=update --name %s --value %s' % (iscsiadm_cmd, target, name, value)
module.run_command(cmd, check_rc=True)

cmd = [iscsiadm_cmd, '--mode', 'node', '--targetname', target, '--login']
if portal is not None and port is not None:
cmd.append('--portal')
Expand Down Expand Up @@ -277,6 +296,8 @@ def main():
node_auth=dict(type='str', default='CHAP'),
node_user=dict(type='str'),
node_pass=dict(type='str', no_log=True),
node_user_in=dict(type='str'),
node_pass_in=dict(type='str', no_log=True),

# actions
login=dict(type='bool', aliases=['state']),
Expand All @@ -286,7 +307,7 @@ def main():
show_nodes=dict(type='bool', default=False),
),

required_together=[['node_user', 'node_pass']],
required_together=[['node_user', 'node_pass'], ['node_user_in', 'node_pass_in']],
required_if=[('discover', True, ['portal'])],
supports_check_mode=True,
)
Expand Down