HewlettPackard / oneview-ansible-collection

Ansible Collection and Sample Playbooks for HPE OneView
Apache License 2.0
26 stars 22 forks source link

SNMPv3 users - Idempotency issue #179

Closed ClaireHayard closed 2 years ago

ClaireHayard commented 2 years ago

Scenario/Intent

Hello,

I am creating SNMPv3 users via an Ansible task however running the same code twice with the same user input leads to an error.

main.yml

- name: Create snmpv3 users
  oneview_appliance_device_snmp_v3_users:
    config: "{{ config }}"
    state: present
    data:
        userName: "{{ username }}"
        securityLevel: "{{ security_level }}"
        authenticationProtocol: "{{ authentication_protocol }}"
        authenticationPassphrase: "{{ authentication_passphrase }}"
        privacyProtocol: "{{ privacy_protocol }}"
        privacyPassphrase: "{{ privacy_passphrase }}"
  delegate_to: localhost

Environment Details

Expected Result

We have idempotency when we run the same playbook with the same SNMPv3 user input data multiple times.

Actual Result

TASK [snmpv3 : Create snmpv3 users] ******************************************************************************************
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: hpeOneView.exceptions.HPEOneViewException: ('The supplied user name already exists.', {'errorCode': 'USER_ALREADY_EXIST', 'message': 'The supplied user name already exists.', 'details': '', 'messageParameters': [None], 'recommendedActions': ['Provide a different SNMPv3 user name and retry the operation.'], 'errorSource': None, 'nestedErrors': [], 'data': {}})

PLAY RECAP *******************************************************************************************************************
localhost                  : ok=2    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0  
alisha-k-kalladassery commented 2 years ago

Hi Claire, I ran the same code multiple times (oneview_appliance_device_snmp_v3_users) and I am not running in to any errors. Below is the output I got. TASK [hpe.oneview.oneview_appliance_device_snmp_v3_users : Creating the SNMPv3 user for automation] **** ok: [localhost -> localhost]

TASK [hpe.oneview.oneview_appliance_device_snmp_v3_users : Creating another SNMPv3 user for automation] **** ok: [localhost -> localhost]

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

Please let me know more details to help you on this.

ClaireHayard commented 2 years ago

Hello @alisha-k-kalladassery,

What information do you need ?

alisha-k-kalladassery commented 2 years ago

Hi Claire,

This issue is fixed and should be available in oneview v7.0 version.

ClaireHayard commented 2 years ago

Hello @alisha-k-kalladassery,

I tested the code again with the new provider version and it doesn't end with an error however we still have an idempotency issue it seems.

First run of the code:

TASK [create the user] *********************************************************
changed: [localhost] => (item={'username': 'user1', 'security_level': 'Authentication and privacy', 'authentication_protocol': 'SHA1', 'authentication_passphrase': '********', 'privacy_protocol': 'AES-128', 'privacy_passphrase': '*************'})

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

Second run of the code:

TASK [create the user] *********************************************************
changed: [localhost] => (item={'username': 'user1', 'security_level': 'Authentication and privacy', 'authentication_protocol': 'SHA1', 'authentication_passphrase': '********', 'privacy_protocol': 'AES-128', 'privacy_passphrase': '*************'})

PLAY RECAP *********************************************************************
localhost                  : ok=2    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0
nabhajit-ray commented 2 years ago

Reopening this as there is an issue with the fix

alisha-k-kalladassery commented 2 years ago

Hi Claire,

This issue is fixed and should be available in oneview v7.1 version.