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
TASK [Create a User] ***
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: HPOneViewException: (u'Did not retrieve user: testUser.', {u'errorSource': None, u'recommendedActions': [u'Supply a valid user name.'], u'data': {}, u'errorCode': u'USER_NOT_FOUND_ERROR', u'details': u'', u'message': u'Did not retrieve user: testUser.', u'nestedErrors': []})
fatal: [localhost -> localhost]: FAILED! => {"changed": false, "module_stderr": "Traceback (most recent call last):\n File \"/home/chris/.ansible/tmp/ansible-tmp-1544559099.82-156103145785834/AnsiballZ_oneview_user.py\", line 113, in \n _ansiballz_main()\n File \"/home/chris/.ansible/tmp/ansible-tmp-1544559099.82-156103145785834/AnsiballZ_oneview_user.py\", line 105, in _ansiballz_main\n invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n File \"/home/chris/.ansible/tmp/ansible-tmp-1544559099.82-156103145785834/AnsiballZ_oneview_user.py\", line 48, in invoke_module\n imp.load_module('main', mod, module, MOD_DESC)\n File \"/tmp/ansible_oneview_user_payload_SIVR58/main.py\", line 181, in \n File \"/tmp/ansible_oneview_user_payload_SIVR58/main.py\", line 177, in main\n File \"/tmp/ansible_oneview_user_payload_SIVR58/ansible_oneview_user_payload.zip/ansible/module_utils/oneview.py\", line 430, in run\n File \"/tmp/ansible_oneview_user_payload_SIVR58/main.py\", line 128, in execute_module\n File \"build/bdist.linux-x86_64/egg/hpOneView/resources/security/users.py\", line 146, in get_by\n return self._client.get(self.URI + '/' + value)\n File \"build/bdist.linux-x86_64/egg/hpOneView/resources/resource.py\", line 294, in get\n return self._connection.get(uri)\n File \"build/bdist.linux-x86_64/egg/hpOneView/connection.py\", line 338, in get\n raise HPOneViewException(body)\nHPOneViewException: (u'Did not retrieve user: testUser.', {u'errorSource': None, u'recommendedActions': [u'Supply a valid user name.'], u'data': {}, u'errorCode': u'USER_NOT_FOUND_ERROR', u'details': u'', u'message': u'Did not retrieve user: testUser.', u'nestedErrors': []})\n", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}
When the user is not found (which should be the case since we're trying to create the user), the exception that is raised straight from the Python OneView library is of type HPOneViewException, not OneViewModuleException. Therefore the except clause is not executed, the exception is raised up the stack and the execution stops.
Scenario/Intent
Create a user
Environment Details
Steps to Reproduce
Run playbook https://github.com/HewlettPackard/oneview-ansible/blob/master/examples/oneview_user.yml
Expected Result
The first task should create a user testUser
Actual Result
TASK [Create a User] *** An exception occurred during task execution. To see the full traceback, use -vvv. The error was: HPOneViewException: (u'Did not retrieve user: testUser.', {u'errorSource': None, u'recommendedActions': [u'Supply a valid user name.'], u'data': {}, u'errorCode': u'USER_NOT_FOUND_ERROR', u'details': u'', u'message': u'Did not retrieve user: testUser.', u'nestedErrors': []}) fatal: [localhost -> localhost]: FAILED! => {"changed": false, "module_stderr": "Traceback (most recent call last):\n File \"/home/chris/.ansible/tmp/ansible-tmp-1544559099.82-156103145785834/AnsiballZ_oneview_user.py\", line 113, in\n _ansiballz_main()\n File \"/home/chris/.ansible/tmp/ansible-tmp-1544559099.82-156103145785834/AnsiballZ_oneview_user.py\", line 105, in _ansiballz_main\n invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n File \"/home/chris/.ansible/tmp/ansible-tmp-1544559099.82-156103145785834/AnsiballZ_oneview_user.py\", line 48, in invoke_module\n imp.load_module('main', mod, module, MOD_DESC)\n File \"/tmp/ansible_oneview_user_payload_SIVR58/main.py\", line 181, in \n File \"/tmp/ansible_oneview_user_payload_SIVR58/main.py\", line 177, in main\n File \"/tmp/ansible_oneview_user_payload_SIVR58/ansible_oneview_user_payload.zip/ansible/module_utils/oneview.py\", line 430, in run\n File \"/tmp/ansible_oneview_user_payload_SIVR58/main.py\", line 128, in execute_module\n File \"build/bdist.linux-x86_64/egg/hpOneView/resources/security/users.py\", line 146, in get_by\n return self._client.get(self.URI + '/' + value)\n File \"build/bdist.linux-x86_64/egg/hpOneView/resources/resource.py\", line 294, in get\n return self._connection.get(uri)\n File \"build/bdist.linux-x86_64/egg/hpOneView/connection.py\", line 338, in get\n raise HPOneViewException(body)\nHPOneViewException: (u'Did not retrieve user: testUser.', {u'errorSource': None, u'recommendedActions': [u'Supply a valid user name.'], u'data': {}, u'errorCode': u'USER_NOT_FOUND_ERROR', u'details': u'', u'message': u'Did not retrieve user: testUser.', u'nestedErrors': []})\n", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}
The problem is in https://github.com/HewlettPackard/oneview-ansible/blob/master/library/oneview_user.py In execute_module() there is this code:
When the user is not found (which should be the case since we're trying to create the user), the exception that is raised straight from the Python OneView library is of type HPOneViewException, not OneViewModuleException. Therefore the except clause is not executed, the exception is raised up the stack and the execution stops.