HewlettPackard / oneview-ansible-collection

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

Creation of external repository - Idempotency fails #172

Closed ClaireHayard closed 2 years ago

ClaireHayard commented 2 years ago

Scenario/Intent

Hello,

I am using the oneview_repositories plugin to create an external repository on OneView, however running the code a second time doesn't garantee idempotency.

main.yml

- name: Create an external repository
  hpe.oneview.oneview_repositories:
    state: present
    config: "{{ config }}"
    data:
      repositoryName: "{{ repository_name }}"
      userName: "{{ repository_username }}"
      password: "{{ repository_password }}"
      repositoryURI: "{{ repository_uri }}"
      repositoryType: "{{ repository_type }}"
  delegate_to: localhost

Environment Details

Expected Result

Idempotency is respected when running the playbook a second time. I understand that only one external repository can be present on a given OneView but the second execution should not throw an error, only ignore the task as there was no changes.

Actual Result

Result of the first ansible-playbook command:

TASK [external_fw_repo : Create an external repository] *********************************************************************************************

changed: [localhost -> localhost] => [...]
    "msg": "Repository created successfully.",
    "param": {
        "repository_name": "extRepo",
        "repository_password": "Apassword",
        "repository_type": "FirmwareExternalRepo",
        "repository_uri": "<external_repo_uri>",
        "repository_username": "user"
    }
}
META: ran handlers
META: ran handlers

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

Result of the second ansible-playbook command:

raise HPEOneViewException(body)\nhpeOneView.exceptions.HPEOneViewException: ('Adding multiple external repository is currently not supported.', {'errorCode': 'MULTIPLE_REPOSITORY_NOT_SUPPORTED_ERROR', 'message': 'Adding multiple external repository is currently not supported.', 'details': '', 'messageParameters': [], 'recommendedActions': ['Remove the existing external repository and retry the operation.'], 'errorSource': None, 'nestedErrors': [], 'data': {}})\n",
    "module_stdout": "",
    "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
    "param": {
        "repository_name": "extRepo",
        "repository_password": "Apassword",
        "repository_type": "FirmwareExternalRepo",
        "repository_uri": "<external_repo_uri>",
        "repository_username": "user"
    },
    "rc": 1
}

PLAY RECAP ******************************************************************************************************************************************
localhost                  : ok=3    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0
ClaireHayard commented 2 years ago

Hello @nabhajit-ray, any news on this ?

alisha-k-kalladassery commented 2 years ago

Hi Claire,

This issue has been fixed and will be available in v7.1 release. This is now available in Master branch also.