Pure-Storage-Ansible / FlashArray-Collection

Ansible Collection for Pure Storage FlashArray
GNU General Public License v3.0
18 stars 23 forks source link

Error while changing interface #563

Closed Natscho2001 closed 5 months ago

Natscho2001 commented 5 months ago

Describe the bug I try to configure an interface but run into an error:

failed: [linpure18 -> localhost] (item={'name': 'ct0.eth2', 'address': '0.0.0.0/0', 'gateway': '0.0.0.0'}) => {
    "ansible_loop_var": "item",
    "changed": false,
    "item": {
        "address": "0.0.0.0/0",
        "gateway": "0.0.0.0",
        "name": "ct0.eth2"
    },
  .....
Traceback (most recent call last):
  File \"/home/.../.ansible/tmp/ansible-tmp-1714461797.5878756-3999730-101050925160799/AnsiballZ_purefa_network.py\", line 107, in <module>
    _ansiballz_main()
  File \"/home/.../.ansible/tmp/ansible-tmp-1714461797.5878756-3999730-101050925160799/AnsiballZ_purefa_network.py\", line 99, in _ansiballz_main
    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
  File \"/home/.../.ansible/tmp/ansible-tmp-1714461797.5878756-3999730-101050925160799/AnsiballZ_purefa_network.py\", line 47, in invoke_module
    runpy.run_module(mod_name='ansible_collections.purestorage.flasharray.plugins.modules.purefa_network', init_globals=dict(_module_fqn='ansible_collections.purestorage.flasharray.plugins.modules.purefa_network', _modlib_path=modlib_path),
  File \"<frozen runpy>\", line 226, in run_module
  File \"<frozen runpy>\", line 98, in _run_module_code
  File \"<frozen runpy>\", line 88, in _run_code
  File \"/tmp/ansible_purestorage.flasharray.purefa_network_payload_66vridq6/ansible_purestorage.flasharray.purefa_network_payload.zip/ansible_collections/purestorage/flasharray/plugins/modules/purefa_network.py\", line 769, in <module>
  File \"/tmp/ansible_purestorage.flasharray.purefa_network_payload_66vridq6/ansible_purestorage.flasharray.purefa_network_payload.zip/ansible_collections/purestorage/flasharray/plugins/modules/purefa_network.py\", line 739, in main
  File \"/tmp/ansible_purestorage.flasharray.purefa_network_payload_66vridq6/ansible_purestorage.flasharray.purefa_network_payload.zip/ansible_collections/purestorage/flasharray/plugins/modules/purefa_network.py\", line 342, in update_interface
  File \"/home/.../.local/lib/python3.11/site-packages/netaddr/strategy/ipv4.py\", line 99, in valid_str
    raise TypeError('Invalid type: %s' % type(addr))
TypeError: Invalid type: <class 'NoneType'>
",
    "module_stdout": "",
    "msg": "MODULE FAILURE
See stdout/stderr for the exact error",
    "rc": 1

To Reproduce Steps to reproduce the behavior:

Create a task:

- name: FlashArray > array_basic> Set array replication
  purestorage.flasharray.purefa_network:
    name: "{{ item.name }}"
    address: "{{ item.address | string }}"
    gateway: "{{ item.gateway | string }}"
    servicelist: "replication"
    mtu: "1500"
    state: present
    fa_url: "{{ inventory_hostname }}.domain.local"
    api_token: "{{ api_token_obj.result.Content }}"
  loop: "{{ replication | default([]) }}"

Add vars to inventory:

          replication:
            - name: "ct0.eth2"
              address: "0.0.0.0/0"
              gateway: "0.0.0.0"
            - name: "ct1.eth2"
              address: "0.0.0.0/0"
              gateway: "0.0.0.0"

Run the playbook

ansible-playbook playbook.yml -i inventories --check -vvv

Reference for task from the docs

 - name: Remove an IP address from iSCSI interface ct0.eth4
  purestorage.flasharray.purefa_network:
    name: ct0.eth4
    address: 0.0.0.0/0
    gateway: 0.0.0.0
    fa_url: 10.10.10.2
    api_token: c6033033-fe69-2515-a9e8-966bb7fe4b40

Expected behavior

The given interface should be configured with the IP. In this case, it should delete an existing IP configuration.

Desktop (please complete the following information):

ansible-playbook [core 2.15.3]
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/.../.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.11/site-packages/ansible
  ansible collection location = /home/.../.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/bin/ansible-playbook
  python version = 3.11.5 (main, Sep 22 2023, 15:34:29) [GCC 8.5.0 20210514 (Red Hat 8.5.0-20)] (/usr/bin/python3.11)
  jinja version = 3.1.2
  libyaml = True
sdodsley commented 5 months ago

Thanks for reporting this. We will take a look.

Can you confirm the state of the network interface before you ran this failing playbook task?

sdodsley commented 5 months ago

@Natscho2001 please upgrade to the latest FlashArray collection and then apply this patch. This should then resolve your issue.

Natscho2001 commented 4 months ago

Thanks for your reply, but that did not fix the issue. This is a brand new FlashArray, all interfaces are configured by default.

I update the collection successfully

ansible-galaxy collection install -U -f purestorage.flasharray
Starting galaxy collection install process
Process install dependency map
Starting collection install process
Downloading 
purestorage.flasharray:1.28.0 was installed successfully

An added the lines provided

322-    if not current_state["address"]:
323:        current_state["address"] = "0.0.0.0"
--
384-        if not address:
385:            address = "0.0.0.0"

But still get

Traceback (most recent call last):
  File \"/home/../.ansible/tmp/ansible-tmp-1714978601.4099014-513915-231433368316548/AnsiballZ_purefa_network.py\", line 107, in <module>
    _ansiballz_main()
  File \"/home/../.ansible/tmp/ansible-tmp-1714978601.4099014-513915-231433368316548/AnsiballZ_purefa_network.py\", line 99, in _ansiballz_main
    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
  File \"/home/../.ansible/tmp/ansible-tmp-1714978601.4099014-513915-231433368316548/AnsiballZ_purefa_network.py\", line 47, in invoke_module
    runpy.run_module(mod_name='ansible_collections.purestorage.flasharray.plugins.modules.purefa_network', init_globals=dict(_module_fqn='ansible_collections.purestorage.flasharray.plugins.modules.purefa_network', _modlib_path=modlib_path),
  File \"<frozen runpy>\", line 226, in run_module
  File \"<frozen runpy>\", line 98, in _run_module_code
  File \"<frozen runpy>\", line 88, in _run_code
  File \"/tmp/ansible_purestorage.flasharray.purefa_network_payload__e2_ayub/ansible_purestorage.flasharray.purefa_network_payload.zip/ansible_collections/purestorage/flasharray/plugins/modules/purefa_network.py\", line 773, in <module>
  File \"/tmp/ansible_purestorage.flasharray.purefa_network_payload__e2_ayub/ansible_purestorage.flasharray.purefa_network_payload.zip/ansible_collections/purestorage/flasharray/plugins/modules/purefa_network.py\", line 743, in main
  File \"/tmp/ansible_purestorage.flasharray.purefa_network_payload__e2_ayub/ansible_purestorage.flasharray.purefa_network_payload.zip/ansible_collections/purestorage/flasharray/plugins/modules/purefa_network.py\", line 344, in update_interface
  File \"/home/../.local/lib/python3.11/site-packages/netaddr/strategy/ipv4.py\", line 99, in valid_str
    raise TypeError('Invalid type: %s' % type(addr))
TypeError: Invalid type: <class 'NoneType'>
", "module_stdout": "", "msg": "MODULE FAILURE
See stdout/stderr for the exact error", "rc": 1}