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

Creating Server Profile Template with localAccounts is reporting syntax error. #606

Closed harishkalyanpur closed 3 years ago

harishkalyanpur commented 3 years ago

Scenario/Intent

Creating Server Profile Template with localAccounts is reporting syntax error.

Environment Details

Steps to Reproduce

When i add below to the yaml code to update the server profile template, i get syntax error.

Expected Result

To accept the localAccounts block of code and update the server profile template.

Actual Result

An exception occurred during task execution. To see the full traceback, use -vvv. The error was: hpeOneView.exceptions.HPEOneViewException: ('Invalid JSON data type.', {'errorCode': 'INVALID_JSON_DATA_TYPE', 'message': 'Invalid JSON data type.', 'details': 'The JSON sent in the request contained a unknown type where a different unknown type is required on line 1 near column 3,662.', 'messageParameters': [], 'recommendedActions': ['Correct the content of the JSON and retry the request.'], 'errorSource': None, 'nestedErrors': [], 'data': {}})

yuvirani commented 3 years ago

@harishkalyanpur, We are looking into this issue and will update you with the solution as soon as possible.

yuvirani commented 3 years ago

@harishkalyanpur, I could reproduce the error with the given playbook and noticed that settingType was given as localAccounts instead of "LocalAccounts".

Here is the working playbook, please let us know if this helps.

         mpSettings:
              - settingType: "LocalAccounts"
                args:
                  localAccounts:
                    - userName: "testuser"
                      displayName: "iLO user"
                      password: "testuser123"
                      userConfigPriv: true
                      remoteConsolePriv: true
                      virtualMediaPriv: true
                      virtualPowerAndResetPriv: true
                      iLOConfigPriv: true
harishkalyanpur commented 3 years ago

Issue still persists. Below is the complete list of ILO settings. without the LocalAccounts block, the rest of the settings are working fine, but when i add the LocalAccounts i get syntax errors that i reported.

Can you test again?

mpSettings:

harishkalyanpur commented 3 years ago

Looks like the issues is only when you want to update the existing server profile template. When creating a new SPT it is working fine.

yuvirani commented 3 years ago

@harishkalyanpur, We have retested the playbook with create and update operations on Server Profile Template with LocalAccounts. Its working fine in our environment, could you please try with this working playbook?

- hosts: all
  vars:
    config: "{{ playbook_dir }}/oneview_config.json"
    server_profile_template: Test_Local_settings
    server_hardware_type: SY 480 Gen9 2
    enclosure_group: EG
  tasks:
    - name: Create a server profile template
      oneview_server_profile_template:
        config: "{{ config }}"
        state: present
        data:
          name: "{{ server_profile_template }}"
          serverHardwareTypeName: "{{ server_hardware_type }}"
          enclosureGroupName: "{{ enclosure_group }}"
          connectionSettings:
            manageConnections: true
            connections:
              - id: 1
                name: network2
                functionType: Ethernet
                portId: Auto
                requestedMbps: 2600
                networkName: "mgmt_untagged"
          managementProcessor:
            manageMp: true
            mpSettings:
              - settingType: LocalAccounts
                args:
                  localAccounts:
                    - userName: "OneViewAdminUpdate11"
                      displayName: "One View Administrator"
                      password: "testuser1234"
                      userConfigPriv: true
                      remoteConsolePriv: true
                      virtualMediaPriv: true
                      virtualPowerAndResetPriv: true
                      iLOConfigPriv: true
              - settingType: Directory
                args:
                        directoryAuthentication: defaultSchema
                        directoryGenericLDAP: true
                        directoryServerAddress: ldap.xyz.com
                        directoryServerPort: 636
                        directoryUserContext:
                                 - "XXXXXXX"
                                - "XXXXXXX"
                        iloObjectDistinguishedName: "XXXXXXXXX-YYYYYYYYY"
                        kerberosAuthentication: false
                        password: "password1234"
      delegate_to: localhost
harishkalyanpur commented 3 years ago

I am getting below error when i use -vvv switch. This is happening only when we are updating the existing profile. If the same code when it runs to create a new SPT, we dont get this error. Also this is specific to the ILO settings.

hpeOneView.exceptions.HPEOneViewTaskError: The iLO settings are invalid: Argument "deleteAdministratorAccount" is not recognized for iLO setting "Manage local accounts". Argument "password" is not recognized for iLO setting "Manage local accounts". Argument "localAccounts" is not recognized for iLO setting "Manage administrator account".

harishkalyanpur commented 3 years ago

fatal: [localhost -> localhost]: FAILED! => { "changed": false, "module_stderr": "Traceback (most recent call last):\n File \"/root/.ansible/tmp/ansible-tmp-1608103895.3504324-72181544990486/AnsiballZ_oneview_server_profile_template.py\", line 113, in \n _ansiballz_main()\n File \"/root/.ansible/tmp/ansible-tmp-1608103895.3504324-72181544990486/AnsiballZ_oneview_server_profile_template.py\", line 105, in _ansiballz_main\n invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n File \"/root/.ansible/tmp/ansible-tmp-1608103895.3504324-72181544990486/AnsiballZ_oneview_server_profile_template.py\", line 48, in invoke_module\n imp.load_module('main', mod, module, MOD_DESC)\n File \"/usr/local/lib/python3.6/imp.py\", line 235, in load_module\n return load_source(name, filename, file)\n File \"/usr/local/lib/python3.6/imp.py\", line 170, in load_source\n module = _exec(spec, sys.modules[name])\n File \"\", line 618, in _exec\n File \"\", line 678, in exec_module\n File \"\", line 219, in _call_with_frames_removed\n File \"/tmp/ansible_oneview_server_profile_template_payload_59eubcms/main.py\", line 226, in \n File \"/tmp/ansible_oneview_server_profile_template_payload_59eubcms/main.py\", line 222, in main\n File \"/tmp/ansible_oneview_server_profile_template_payload_59eubcms/ansible_oneview_server_profile_template_payload.zip/ansible/module_utils/oneview.py\", line 475, in run\n File \"/tmp/ansible_oneview_server_profile_template_payload_59eubcms/main.py\", line 153, in execute_module\n File \"/tmp/ansible_oneview_server_profile_template_payload_59eubcms/main.py\", line 167, in present\n File \"/tmp/ansible_oneview_server_profile_template_payload_59eubcms/main.py\", line 202, in update\n File \"/usr/local/lib/python3.6/site-packages/hpeOneView/resources/resource.py\", line 67, in wrap\n return obj(*args, **kwargs)\n File \"/usr/local/lib/python3.6/site-packages/hpeOneView/resources/servers/server_profile_templates.py\", line 137, in update\n self.data = self._helper.update(resource, uri, force, timeout)\n File \"/usr/local/lib/python3.6/site-packages/hpeOneView/resources/resource.py\", line 479, in update\n return self.do_put(uri, resource, timeout, custom_headers)\n File \"/usr/local/lib/python3.6/site-packages/hpeOneView/resources/resource.py\", line 785, in do_put\n return self._task_monitor.wait_for_task(task, timeout)\n File \"/usr/local/lib/python3.6/site-packages/hpeOneView/resources/task_monitor.py\", line 82, in wait_for_task\n task_response = self.__get_task_response(task)\n File \"/usr/local/lib/python3.6/site-packages/hpeOneView/resources/task_monitor.py\", line 142, in __get_task_response\n raise HPEOneViewTaskError(msg, error_code)\nhpeOneView.exceptions.HPEOneViewTaskError: The iLO settings are invalid:\nArgument \"deleteAdministratorAccount\" is not recognized for iLO setting \"Manage local accounts\".\nArgument \"password\" is not recognized for iLO setting \"Manage local accounts\".\nArgument \"localAccounts\" is not recognized for iLO setting \"Manage administrator account\".\n", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1 }

yuvirani commented 3 years ago

@harishkalyanpur, Just to confirm, did you copy the playbook provided above and got the same error? Because I haven't provided 'deleteAdministratorAccount' type above. If this works fine, please provide the entire playbook you are trying.

harishkalyanpur commented 3 years ago

@yuvirani, It worked with few modifications, like network name, enclosure name and hardware type also the update worked. I will send the entire playbook with few data masking.

harishkalyanpur commented 3 years ago

@yuvirani, here is the entire playbook.

- hosts: all
  vars:
    config: "{{ playbook_dir }}/oneview_config.json"
    server_profile_template_name: TestProfile
    server_hardware_type_name: SY 480 Gen10 1
    enclosure_group_name: Demo
  tasks:
    - name: Crate and Update server profile template
      oneview_server_profile_template:
        config: "{{ config }}"
        state: present
        data:
          name: "{{ server_profile_template_name }}"
          serverHardwareTypeName: "{{ server_hardware_type_name }}"
          enclosureGroupName: "{{ enclosure_group_name }}"
          description: "Test Server Profile Template created using Ansible Playbook"
          boot:
            manageBoot: true
            order:
              - HardDisk
          bootMode:
            manageMode: true
            mode: UEFIOptimized
            pxeBootPolicy: Auto
            secureBoot: Enabled
          affinity: BayAndServer
          bios:
            manageBios: true
            overriddenSettings:
              - id: WorkloadProfile
                value: Virtualization-MaxPerformance
              - id: MinProcIdlePower
                value: NoCStates
              - id: IntelUpiPowerManagement
                value: Disabled
              - id: AdvancedMemProtection
                value: FastFaultTolerantADDDC
              - id: MinProcIdlePkgState
                value: NoState
              - id: EnergyPerfBias
                value: MaxPerf
              - id: UncoreFreqScaling
                value: Maximum
              - id: AsrStatus
                value: Disabled
              - id: TimeZone
                value: UtcP10
              - id: PowerRegulator
                value: StaticHighPerf
              - id: EnergyEfficientTurbo
                value: Disabled
              - id: NumaGroupSizeOpt
                value: Clustered
              - id: SubNumaClustering
                value: Enabled
              - id: CollabPowerControl
                value: Disabled
          firmware:
            firmwareActivationType: Immediate
            firmwareBaselineUri: /rest/firmware-drivers/Synergy_Custom_SPP_2020_07_02_Z7550-97031
            firmwareInstallType: FirmwareOnlyOfflineMode
            forceInstallFirmware: false
            manageFirmware: true
          serverProfileDescription: "Test Server Profile"
          serialNumberType: "Physical"
          wwnType: Virtual
          connectionSettings:
            connections:
              - boot:
                  bootVlanId: null
                  priority: NotBootable
                functionType: Ethernet
                id: 1
                isolatedTrunk: false
                lagName: null
                managed: true
                name: Host Management
                networkName: null
                networkUri: /rest/ethernet-networks/682b97be-7577-4c94-b4b5-sfadsfasdfsa
                portId: abcd 3:1-x
                requestedMbps: 2500
                requestedVFs: 0
              - boot:
                  bootVlanId: null
                  priority: NotBootable
                functionType: FibreChannel
                id: 2
                isolatedTrunk: false
                lagName: null
                managed: true
                name: SAN X
                networkName: null
                networkUri: /rest/fc-networks/57a6865f-ec8e-4a74-81fe-adfdasfasdfsda
                portId: abcd 3:1-y
                requestedMbps: 2500
                requestedVFs: null
              - boot:
                  bootVlanId: null
                  priority: NotBootable
                functionType: FibreChannel
                id: 3
                isolatedTrunk: false
                lagName: null
                managed: true
                name: SAN Y
                networkName: null
                networkUri: /rest/fc-networks/5a77bf06-8981-4238-98e5-sdfadsfadfsadf
                portId: abcd 3:2-y
                requestedMbps: 2500
                requestedVFs: null
              - boot:
                  bootVlanId: null
                  priority: NotBootable
                functionType: Ethernet
                id: 4
                isolatedTrunk: false
                lagName: null
                managed: true
                name: Host Mgmt Set
                networkName: null
                networkUri: /rest/ethernet-networks/682b97be-7577-4c94-b4b5-adfsdfasdfsa
                portId: abcd 3:2-x
                requestedMbps: 2500
                requestedVFs: 0
            manageConnections: true
          managementProcessor:
            manageMp: true
            mpSettings:
              - settingType: "LocalAccounts"
                args:
                  localAccounts:
                    - userName: "OneViewAdmin"
                      displayName: "One View Administrator"
                      password: "{{ oneview_profile_account_pw }}"
                      userConfigPriv: true
                      remoteConsolePriv: true
                      virtualMediaPriv: true
                      virtualPowerAndResetPriv: true
                      iLOConfigPriv: true
              - settingType: AdministratorAccount
                args:
                  deleteAdministratorAccount: false
                  password: "{{ oneview_profile_account_pw }}"
              - settingType: Directory
                args:
                  directoryAuthentication: defaultSchema
                  directoryGenericLDAP: true
                  directoryServerAddress: ldap.xyz.com
                  directoryServerPort: 636
                  directoryUserContext:
                    - "XXXXXX"
                    - "XXXXXX"
                  iloObjectDistinguishedName:  "XXXXXXXXX\YYYYYYYYY"
                  kerberosAuthentication: false
                  password: "{{ oneview_profile_account_pw }}"
              - settingType: DirectoryGroups
                args:
                  directoryGroupAccounts:
                    - groupDN: " XXXXXX "
                      groupSID: ""
                      iLOConfigPriv: true
                      remoteConsolePriv: true
                      userConfigPriv: true
                      virtualMediaPriv: true
                      virtualPowerAndResetPriv: true
                    - groupDN: " XXXXXX "
                      groupSID: ""
                      iLOConfigPriv: true
                      remoteConsolePriv: true
                      userConfigPriv: false
                      virtualMediaPriv: true
                      virtualPowerAndResetPriv: true
              - settingType: Hostname
                args:
                  hostName: "{serverProfileName}-ilo"
        params:
          force: True # Supprted only for API version >= 600
      delegate_to: localhost
harishkalyanpur commented 3 years ago

@yuvirani, sorry not sure how to preserve the yaml formatting.

yuvirani commented 3 years ago

@harishkalyanpur, The above playbook also works fine with create and update operations on SPT. Hence, closing this issue.