oneview_server_profile doesn't appear to be idempotent
See original GitHub issueWhen rerunning the following playbook receive an exception that “The error was: KeyError: ‘id’”
- name: Create a Server Profile
oneview_server_profile:
config: "{{ login }}"
state: "present"
data:
name: "{{ blade_item.name }}"
server_hardware: "{{ blade_item.hardware }}"
connections:
- name: 'side-a'
networkUri: "{{ network_sets.0.uri }}"
- name: 'side-b'
networkUri: "{{ network_sets.0.uri }}"
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: KeyError: ‘id’ fatal: [10.200.220.50]: FAILED! => {“changed”: false, “failed”: true, “module_stderr”: “Traceback (most recent call last):\n File "/tmp/ansible_lFY_NH/ansible_module_oneview_server_profile.py", line 544, in <module>\n main()\n File "/tmp/ansible_lFY_NH/ansible_module_oneview_server_profile.py", line 540, in main\n ServerProfileModule().run()\n File "/tmp/ansible_lFY_NH/ansible_module_oneview_server_profile.py", line 269, in run\n created, changed, msg, server_profile = self.__present(data, server_profile)\n File "/tmp/ansible_lFY_NH/ansible_module_oneview_server_profile.py", line 318, in __present\n merged_data = ServerProfileMerger().merge_data(resource, data)\n File "/usr/lib/python2.7/site-packages/hpOneView/extras/server_profile_utils.py", line 65, in merge_data\n merged_data = self._merge_connections(merged_data, resource, data)\n File "/usr/lib/python2.7/site-packages/hpOneView/extras/server_profile_utils.py", line 85, in _merge_connections\n merged_data[Keys.CONNECTIONS] = merge_list_by_key(existing_connections, params_connections, key=Keys.ID)\n File "/usr/lib/python2.7/site-packages/hpOneView/extras/mergers.py", line 63, in merge_list_by_key\n item_key = item[key]\nKeyError: ‘id’\n”, “module_stdout”: “”, “msg”: “MODULE FAILURE”}
When removing the server profile and running the playbook the server profile is created successfully. Library module should fit standards for Ansible to be idempotent.
Thanks.
Issue Analytics
- State:
- Created 7 years ago
- Comments:5 (3 by maintainers)
The
oneview_server_profile
module should be idempotent, but looks like there is an issue when you don’t set an ID to the connection.I suggest you change the connection list until we fix this issue, adding IDs to the items. For example:
Please let me know if this temporary fix has solved the issue.
We are looking into our server_profile module and we will update you once it is fixed.