HewlettPackard / oneview-ansible

This project is no longer being developed and has limited support. Please use the newer Ansible Collection project: https://github.com/HewlettPackard/oneview-ansible-collection
Apache License 2.0
104 stars 65 forks source link

Idempotency issue with scope assignment #671

Closed ClaireHayard closed 3 years ago

ClaireHayard commented 3 years ago

Scenario/Intent

When creating a scope and then assigning resources to this scope, idempotency is not respected with OneView Appliance 5.40.

Environment Details

Steps to Reproduce

Here is the playbook used:

- hosts: localhost    
  vars:
    config: 'oneview.json'
    ansible_python_interpreter: '/usr/local/bin/python3.6'
    ooneviewscopeRessourceUris: ["/rest/server-hardware/33343538-3136-4332-3230-313531354752", "/rest/server-profile-templates/9842bd2b-170d-40d6-97f4-a56111c5b37b", "/rest/interconnects/6345fa30-ab52-4d6c-8019-bf6b1683508c", "/rest/logical-interconnects/f453392e-526c-4bd0-9a7c-0f2fd9bb0c8b"]
    ooneviewscopeName: "ScopeName"

  tasks:
    - name: "Create a scope"
      oneview_scope:
        config: "{{ config }}"
        state: present
        data:
          name: "{{ ooneviewscopeName }}"

    - name: "Assign ressource to scope"
      oneview_scope:
        config: "{{ config }}"
        state: present
        data:
          name: "{{ ooneviewscopeName }}"
          addedResourceUris: "{{ ooneviewscopeRessourceUris }}"

Expected Result

We expect idempotency when assigning the same resources two times to a scope (changed=0)

root@8f6bfa740627:/playbooks# ansible-playbook assign_scope.yml

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

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

TASK [Create a scope] *********************************************************************
ok: [localhost]

TASK [Assign ressource to scope] **********************************************************
ok: [localhost]

PLAY RECAP *************************************************************************************************************
localhost                  : ok=3    changed=0    unreachable=0    failed=0

Actual Result

When executing the playbook two times, the assignment of the same resources to a scope is not idempotent (changed=1)

First execution of the playbook:

root@8f6bfa740627:/playbooks# ansible-playbook assign_scope.yml

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

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

TASK [Create a scope] *********************************************************************
changed: [localhost]

TASK [Assign ressource to scope] **********************************************************
changed: [localhost]

PLAY RECAP *************************************************************************************************************
localhost                  : ok=3    changed=2    unreachable=0    failed=0

Second execution of the playbook:

root@8f6bfa740627:/playbooks# ansible-playbook assign_scope.yml

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

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

TASK [Create a scope] *********************************************************************
ok: [localhost]

TASK [Assign ressource to scope] **********************************************************
changed: [localhost]

PLAY RECAP *************************************************************************************************************
localhost                  : ok=3    changed=1    unreachable=0    failed=0
VenkateshRavula commented 3 years ago

Hi @ClaireHayard , we are not able to reproduce this issue in our environment using the above mentioned playbook, docker image v5.10.0 and OV 5.40 versions. Everything is working as expected for us and also idempotency is achieved when executed the same playbook again and again.

Can you please check and confirm this behavior again in your setup.

bigmagic commented 3 years ago

Hi Venkatesh,

To reproduce the issue, ensure that you have a drive enclosure uri into the array of resources :

ooneviewscopeRessourceUris: ["/rest/drive-enclosures/SN123100","/rest/server-hardware/30373737-3237-4D32-3230-333030354752", "/rest/server-profile-templates/e05480d1-28da-4192-90c9-6f8b0b3d0ace", "/rest/interconnects/f9523e4c-8737-4adf-9262-5febb171d599", "/rest/logical-interconnects/2ae7f948-bf27-40bc-81c3-fce12c780b1d"]

There is the same issue using the following resource types:

Best Regards, Nicolas

VenkateshRavula commented 3 years ago

Hi, Thanks for providing more and necessary information about this issue. The actual fix should be provided in python SDK and hence I have opened a new python issue for the same. We will fix this in our next python release.

VenkateshRavula commented 3 years ago

I have reproduced the issue in our environment and also provided the necessary fix to python library. You can pull the latest master branch from python SDK and retry this issue or wait for the next python & ansible SDK release and try with that. Assuming the fix will resolve this issue, I will be closing the issue. Please feel free to reopen if the issue still exists for you.