HewlettPackard / oneview-ansible-collection

Ansible Collection and Sample Playbooks for HPE OneView

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unassign server profile

dobey-xx opened this issue · comments

Hi,

I've been trying to use this task:

  • name: Unassign Server Hardware from Server Profile
    oneview_server_profile:
    config: "{{ config }}"
    sessionID: "{{ session.ansible_facts.session }}"

    This is required for unassigning a SH, or creating a SP and not auto-assigning a SH

    auto_assign_server_hardware: False
    data:
    name: "{{ contents.server_profile.inventory_hostname }}"
    # Specify a blank serverHardwareName or serverHardwareUri when auto_assign_server_hardware is False to unassign a SH
    serverHardwareName:
    delegate_to: localhost

But it doesn't seem to update the server profile in any way. The return message is: "Server Profile is already present", which makes sense because it is :)..

In the output I can see the connection settings with the data as following:
"invocation": {
"module_args": {
"hostname": "",
"username": "",
"password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
"auth_login_domain": "Local",
"api_version": 3200,
"auto_assign_server_hardware": false,
"data": {
"name": "profile"
},

As you can see the option "serverHardwareName" isn't posted in the data section. So it seems it's not passing that through with the task.

Hi,

We will look into this issue.

Hi
We understood the issue and will be fixing it per priority. Kindly try using 'serverHardwareUri' instead of 'serverHardwareName'
and let us know if you still face any issues.

Hi,
I have tried that already but that doesn't unassign the serverhardware from the serverprofile

Hi
Below is the playbook which I tried to check the issue.

- name: Fetch Session Id
  oneview_get_session_id:
    config: "{{ config }}"
    name: "Test_Session"
  delegate_to: localhost
  register: session

- name: Gather facts about all Scopes
  oneview_scope_facts:
    config: "{{ config }}"
    sessionID: "{{ session.ansible_facts.session }}"
  delegate_to: localhost

- name: Create a Server Profile from a Server Profile Template
  oneview_server_profile:
    config: "{{ config }}"
    sessionID: "{{ session.ansible_facts.session }}"
    data:
      serverProfileTemplateName: "{{ contents.server_profile.ov_template }}"
      name: "{{ contents.server_profile.inventory_hostname }}"
      description: "{{ contents.server_profile.server_profile_description }}"
      # User should set initialScopeUris in case of scoped user
      # Otherwise collects scopeUris from OV when its not given
      # explicitly
      initialScopeUris:
        - "{{ scopes[0].uri }}"
    params: # Supported only in API version >= 600
      force: True
  delegate_to: localhost
  register: result

- name: Unassign Server Hardware from Server Profile
  oneview_server_profile:
    config: "{{ config }}"
    sessionID: "{{ session.ansible_facts.session }}"
    # This is required for unassigning a SH, or creating a SP and not auto-assigning a SH
    auto_assign_server_hardware: False
    data:
      name: "{{ contents.server_profile.inventory_hostname }}"
      # Specify a blank serverHardwareName or serverHardwareUri when auto_assign_server_hardware is False to unassign a SH
      serverHardwareUri:
  delegate_to: localhost

Kindly check the same and share your playbook and appliance/SDK details if it does not help you .

This is what i've used:

  • name: Unassign server hardware from a server profile
    hpe.oneview.oneview_server_profile:
    hostname: "{{ oneview_appl }}"
    username: "{{ ONEVIEW_USR }}"
    password: "{{ ONEVIEW_PASSWD }}"
    auth_login_domain: "Local"
    api_version: 3200
    auto_assign_server_hardware: true
    data:
    name: "{{ profile_name }}profile"
    serverHardwareUri: ""
    delegate_to: localhost

The output says:
{
"changed": true,
"msg": "Server profile updated",

But when i check the profile in OneView, the hardware is still assigned

Kindly try keeping the serverHardwareUri blank as in example. We are working on fixing this issue.

serverHardwareUri:

Yes that seems to work, i missed removing the "". Thanks

Hi,
We have merged the fix and changes are available in master branch. It will be released as part of OV8.1 release.