Skip to content

Conversation

gmicol
Copy link
Collaborator

@gmicol gmicol commented Aug 19, 2025

This module is only supported on ND v.4.1.0 or higher.

@gmicol gmicol self-assigned this Aug 19, 2025
@gmicol gmicol added enhancement New feature or request jira-sync Sync this issue to Jira labels Aug 19, 2025
@gmicol gmicol force-pushed the add_nd_local_user branch from 2585919 to 60f2d00 Compare August 19, 2025 16:52
@lhercot lhercot added jira-sync Sync this issue to Jira and removed jira-sync Sync this issue to Jira labels Aug 19, 2025
@github-actions github-actions bot changed the title Add a new module nd_local_user for local users on Nexus Dashboard Add a new module nd_local_user for local users on Nexus Dashboard (DCNE-524) Aug 19, 2025
- name: Query all local users
cisco.nd.nd_local_user:
state: query
register: all_keys
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
register: all_keys
register: query_all

- ansible_local_user
- ansible_local_user_2

#CREATE
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#CREATE
# CREATE

Fix all other places.

elif state == "absent":
if nd.existing:
if not module.check_mode:
nd.request(path="{0}/{1}".format(path, login_id), method="DELETE")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you use updated_path instead of formatting the path again?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you're right, forgot to fix that

---
module: nd_local_user
version_added: "1.4.0"
short_description: Manage local users on Nexus Dashboard
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
short_description: Manage local users on Nexus Dashboard
short_description: Manage local users on Cisco Nexus Dashboard

@gmicol gmicol requested a review from sajagana August 20, 2025 14:36
state: query
register: query_all
- name: Delete an local user
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we change to?
Delete a local user


if not module.check_mode:
if nd.existing:
nd.existing = nd.request(path=updated_path, method="PUT", data=payload)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is PUT op called even for the same configuration?
If yes, shall we leverage get_diff()?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added get_diff() function for pre-checking PUT operation

},
}
if reuse_limitation or time_interval_limitation:
payload["passwordPolicy"] = sanitize_dict(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is sanitize_dict() required here when we sanitize the entire payload in the next step?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's required as nd.sanitize() is not recursive and just sanitize one level deep which is not enough in this case. Maybe, we should address this issue in the future so that the nd.sanitize() can be recursive as well

suboptions:
name:
description:
- The name of the Security Domain to which give the local user access.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we please change this to... if it's more meaningful?

  • The name of the Security Domain to which the local user is given access.

@gmicol gmicol requested a review from shrsr August 21, 2025 16:39
Copy link
Collaborator

@shrsr shrsr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

state: present
register: result
- name: Create local user with minimal configuration
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a new standard? It's not that I disagree with it, but should we then track this as new thing we want to introduce to all our modules?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is something that was introduced with the new nd_api_key module. So I thought this has become the new standard but if not, we should discuss if we should add this creation task with minimum config in the EXAMPLES section.
I think this is interesting to have as it makes visually clearer what attributes are required when creating a new object.
@sajagana, @shrsr, @samiib, @lhercot, @anvitha-jain what do you think?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no preference on this


path = "/api/v1/infra/aaa/localUsers"
if login_id:
updated_path = "{0}/{1}".format(path, login_id)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we rename this to login_id_path or something? think updated is to generic

payload["rbac"] = {
"domains": {
security_domain.get("name"): {
"roles": [USER_ROLES_MAPPING.get(role) for role in security_domain["roles"]] if isinstance(security_domain.get("roles"), list) else [],
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is empty list required to be set in roles, or should we also sanitize this part?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the only way I found to provide an empty list of roles assigned to a security domain. Assigning an None value to "roles" or sanitizing the key will result in an API error.
Also, as providing an empty list works, I wonder if this is a normal behavior or a bug as it seems weird to not assign any role to a local user for a security domain.

@gmicol gmicol requested review from akinross and shrsr August 22, 2025 16:33
Copy link
Collaborator

@shrsr shrsr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Collaborator

@sajagana sajagana left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Copy link
Collaborator

@anvitha-jain anvitha-jain left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Collaborator

@akinross akinross left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

short_description: Manage local users on Cisco Nexus Dashboard
description:
- Manage local users on Cisco Nexus Dashboard (ND).
- It supports creating, updating, querying, and deleting local users.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- It supports creating, updating, querying, and deleting local users.
- This module supports creating, updating, querying, and deleting local users.

- cisco.nd.modules
- cisco.nd.check_mode
notes:
- This module is only supported on Nexus Dashboard having version 4.1.0 or higher.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this note be in the module description instead?

- This module is only supported on ND v4.1.0 and later.

Our ansible-mso modules are worded like this, should we keep it similar?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request jira-sync Sync this issue to Jira
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants