dell / ansible-powerstore

Ansible Modules for Dell PowerStore
GNU General Public License v3.0
31 stars 24 forks source link

[BUG]: powerstore.host cannot manage state #29

Open jason-technology opened 1 year ago

jason-technology commented 1 year ago

Describe the bug powerstore.host works fine to create hosts. If the playbook is run a second time to confirm / validate state, it errors out that the port name is already in use.

To Reproduce Steps to reproduce the behavior:

  1. Step 1 run playbook to configure a new host
  2. Step 2 run playbook again to verify state
  3. Step 3 observe error ... n. Step n See error

Expected behavior I expect that if the host exists as described that the module would return "OK" rather than error out.

Screenshots If applicable, add screenshots to help explain your problem.

Logs If applicable, submit logs or stack traces from the affected services

System Information (please complete the following information):

Additional context Actual Error: Bad request: One of ther provided poret names is already registered with another host

Jennifer-John commented 1 year ago

Hi @jason-technology ,

I tried to reproduce the issue and idempotency seems to work for the ports registered to the host, the error seems to be displayed only when the port is already registered to a different host. Could you please share the playbook and the log trace from ansible_powerstore.log, generated in same location as playbook for us to debug further?

Thanks, Jennifer

glin-s6 commented 6 months ago

Hey! I'm running into this as well. I've noticed that it's not host creation but rather when adding initiators to a host. I've tried adding the initiator in the same block that I'm creating the host and also tried adding the initiator after the host has been created. The host creation is idempotent but the initiator adding isn't.

This is an example of the latter.

- name: Create host
  delegate_to: 127.0.0.1
  register: iscsi_host
  dellemc.powerstore.host:
    array_ip: "{{powerstore_ip}}"
    validate_certs: false
    user: "{{powerstore_username}}"
    password: "{{powerstore_password}}"
    host_name: "{{inventory_hostname}}"
    os_type: "Windows"
    state: "present"

- name: Attach iSCSI initiator to host
  delegate_to: 127.0.0.1
  dellemc.powerstore.host:
    array_ip: "{{powerstore_ip}}"
    validate_certs: false
    user: "{{powerstore_username}}"
    password: "{{powerstore_password}}"
    host_name: "{{inventory_hostname}}"
    os_type: "Windows"
    initiators:
      - "iqn.1991-05.com.microsoft:{{inventory_hostname}}"
    initiator_state: "present-in-host"
    state: "present"

I get the following error message

"msg": "Adding initiators ['iqn.1991-05.com.microsoft:colo-HOST2-compile-executor-0'] to host colo-HOST2-compile-executor-0 failed with error HTTP code: 400, Bad Request [{'messages': [{'code': '0xE0A01001002D', 'severity': 'Error', 'message_l10n': 'One of the provided port names is already registered with another host. Please use port names unique to all hosts.'}]}]", "status_code": "400".

I'm confirmed that the initiator I'm attempting to add is the same initiator that's already added to the host. In fact, the ansible output from the create host shows that the initiator is the same.

"initiators": [
            {
                "active_sessions": [
                    {
                        "appliance_id": "A1",
                        "bond_id": null,
                        "eth_port_id": "bbf150c4220b4ca0b268ec61a420fca2",
                        "fc_port_id": null,
                        "node_id": "446869f28a9b40038bb54f4c49c67bf8",
                        "nvme_transport_addresses": null,
                        "nvme_transport_type": null,
                        "port_name": "iqn.2015-10.com.dell:dellemc-powerstore-apx00234306700-a-2a9eb685",
                        "veth_id": null
                    }
                ],
                "chap_mutual_username": null,
                "chap_single_username": null,
                "id": "fd4b8ced-542c-4fa2-9475-2cd4d5d5646d",
                "port_name": "iqn.1991-05.com.microsoft:colo-host2-compile-executor-0",
                "port_type": "iSCSI"
            }
        ],