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

The OneView Ansible Collection doesn't permit to update user password #159

Closed
bigmagic opened this issue Nov 22, 2021 · 2 comments · Fixed by #160
Closed

The OneView Ansible Collection doesn't permit to update user password #159

bigmagic opened this issue Nov 22, 2021 · 2 comments · Fixed by #160
Assignees

Comments

@bigmagic
Copy link

Hi,

We are using OneView 6.1 and the latest OneView SDK Collection version 6.4.

We have an issue to update user password using the SDK: no modification is performed.

We have tested witth others SDK : It is working as expected using the POSH-HPOneView SDK and with also using the REST API.

Version used;

  • OneView 6.10.00-0436703
  • OneView Ansible SDK Collection version 6.4

You will find below an example code:

- hosts: localhost
  vars:
    config: 'oneview.json'
    ansible_python_interpreter: '/usr/bin/python3.6'
    userName: "test-user"
    roleName: "Infrastructure administrator"
    password1: "LONG1234@passwd1234"
    password2: "password67654#AZEDF"

  collections:
    - hpe.oneview

  tasks:

    - name: "Create a user"
      hpe.oneview.oneview_user:
        config: "{{ config }}"
        state: present
        data:
          userName: "{{ userName }}"
          password: "{{ password1 }}"
          enabled: True
          fullName: "User Name"
          mobilePhone: "+33600000000"
          officePhone: "+33600000000"
          permissions:
            - roleName: "{{ roleName }}"

    - name: "Update User password"
      hpe.oneview.oneview_user:
        config: "{{ config }}"
        state: present
        data:
          userName: "{{ userName }}"
          password: "{{ password2 }}"

The update of the password returns an "User is already present" error message.

PLAY [localhost] ********************************************************************************************************************************************

TASK [Gathering Facts] **************************************************************************************************************************************
ok: [localhost]

TASK [Create a user] ****************************************************************************************************************************************
changed: [localhost] => {"ansible_facts": {"user": {"category": "users", "created": "2021-11-22T15:01:23.226Z", "description": null, "eTag": "994312728", "emailAddress": "", "enabled": true, "fullName": "User Name", "mobilePhone": "+33600000000", "modified": "2021-11-22T15:01:23.226Z", "name": null, "officePhone": "+33600000000", "permissions": [{"roleName": "Infrastructure administrator", "scopeUri": null}], "state": null, "status": null, "type": "UserAndPermissions", "uri": "/rest/users/test-user", "userName": "test-user"}}, "changed": true, "msg": "User created successfully."}

TASK [Update User password] *********************************************************************************************************************************
ok: [localhost] => {"ansible_facts": {"user": {"category": "users", "created": "2021-11-22T15:01:23.226Z", "description": null, "eTag": "994312728", "emailAddress": "", "enabled": true, "fullName": "User Name", "mobilePhone": "+33600000000", "modified": "2021-11-22T15:01:23.226Z", "name": null, "officePhone": "+33600000000", "permissions": [{"roleName": "Infrastructure administrator", "scopeUri": null}], "state": null, "status": null, "type": "UserAndPermissions", "uri": "/rest/users/test-user", "userName": "test-user"}}, "changed": false, "msg": "User is already present."}

PLAY RECAP **************************************************************************************************************************************************
localhost                  : ok=3    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0

As I can see into the source code:
https://github.com/HewlettPackard/oneview-ansible-collection/blob/master/plugins/modules/oneview_user.py

The password field is removed line 330 :

            # remove password, it cannot be used in comparison
            if 'password' in merged_data:
                del merged_data['password']

The Ansible Collection SDK should be able to update the user password.

Best Regards,
Nicolas Portais

@chebroluharika chebroluharika self-assigned this Nov 23, 2021
@chebroluharika chebroluharika linked a pull request Nov 23, 2021 that will close this issue
5 tasks
@chebroluharika chebroluharika mentioned this issue Nov 23, 2021
5 tasks
@chebroluharika
Copy link
Contributor

Hi @bigmagic ,
We have merged fix into master and please check if your requirement is satisfied.

@bigmagic
Copy link
Author

bigmagic commented Dec 7, 2021

Hi @chebroluharika
Yes It is working. Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants