F5Networks / f5-ansible-f5os

Collection for managing F5OS based devices
2 stars 1 forks source link

f5networks.f5os.f5os_lag does not work for new configuration #17

Closed RemcoAA closed 1 month ago

RemcoAA commented 1 month ago
COMPONENT NAME

f5networks.f5os.f5os_lag

Environment

ANSIBLE VERSION
ansible [core 2.15.9]
  config file = /Users/fk74uw/Developer/P00983-F5-DO/ansible/ansible.cfg
  configured module search path = ['/Users/xxx/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /Users/xxx/.homebrew/Cellar/ansible@8/8.7.0/libexec/lib/python3.11/site-packages/ansible
  ansible collection location = /Users/xxx/Developer/F5-DO/ansible/collections/ansible_collections:/usr/share/ansible/collections:/home/ts26ss/py3env01/lib/python3.10/site-packages/ansible_collections
  executable location = /Users/xxx/.homebrew/opt/ansible@8/bin/ansible
  python version = 3.11.9 (main, Apr  2 2024, 08:25:04) [Clang 15.0.0 (clang-1500.3.9.4)] (/Users/xxx/.homebrew/Cellar/ansible@8/8.7.0/libexec/bin/python)
  jinja version = 3.1.3
  libyaml = True
F5OS VERSION
f5networks.f5os               1.11.0 
CONFIGURATION
[defaults]
host_key_checking = False
display_skipped_hosts = no
localhost_warning = false
OS / ENVIRONMENT

N/A

SUMMARY

Creating a new LAG fails with the following error:

An exception occurred during task execution. To see the full traceback, use -vvv. The error was: KeyError: 'openconfig-vlan:switched-vlan'
fatal: [nlrott99-bi4010.testlab.iaas.ing.net -> 10.215.250.230]: FAILED! => {"changed": false, "module_stderr": "Traceback (most recent call last):\n  File \"/Users/xxx/.ansible/tmp/ansible-local-35851blhs8j3k/ansible-tmp-1726210060.994598-35926-223342491619618/AnsiballZ_f5os_lag.py\", line 107, in <module>\n    _ansiballz_main()\n  File \"/Users/xxx/.ansible/tmp/ansible-local-35851blhs8j3k/ansible-tmp-1726210060.994598-35926-223342491619618/AnsiballZ_f5os_lag.py\", line 99, in _ansiballz_main\n    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n  File \"/Users/xxx/.ansible/tmp/ansible-local-35851blhs8j3k/ansible-tmp-1726210060.994598-35926-223342491619618/AnsiballZ_f5os_lag.py\", line 47, in invoke_module\n    runpy.run_module(mod_name='ansible_collections.f5networks.f5os.plugins.modules.f5os_lag', init_globals=dict(_module_fqn='ansible_collections.f5networks.f5os.plugins.modules.f5os_lag', _modlib_path=modlib_path),\n  File \"<frozen runpy>\", line 226, in run_module\n  File \"<frozen runpy>\", line 98, in _run_module_code\n  File \"<frozen runpy>\", line 88, in _run_code\n  File \"/var/folders/j_/jg5t8wmn76q_3d9trzy6g73m0000gp/T/ansible_f5networks.f5os.f5os_lag_payload_bhuzjja0/ansible_f5networks.f5os.f5os_lag_payload.zip/ansible_collections/f5networks/f5os/plugins/modules/f5os_lag.py\", line 725, in <module>\n  File \"/var/folders/j_/jg5t8wmn76q_3d9trzy6g73m0000gp/T/ansible_f5networks.f5os.f5os_lag_payload_bhuzjja0/ansible_f5networks.f5os.f5os_lag_payload.zip/ansible_collections/f5networks/f5os/plugins/modules/f5os_lag.py\", line 718, in main\n  File \"/var/folders/j_/jg5t8wmn76q_3d9trzy6g73m0000gp/T/ansible_f5networks.f5os.f5os_lag_payload_bhuzjja0/ansible_f5networks.f5os.f5os_lag_payload.zip/ansible_collections/f5networks/f5os/plugins/modules/f5os_lag.py\", line 403, in exec_module\n  File \"/var/folders/j_/jg5t8wmn76q_3d9trzy6g73m0000gp/T/ansible_f5networks.f5os.f5os_lag_payload_bhuzjja0/ansible_f5networks.f5os.f5os_lag_payload.zip/ansible_collections/f5networks/f5os/plugins/modules/f5os_lag.py\", line 419, in present\n  File \"/var/folders/j_/jg5t8wmn76q_3d9trzy6g73m0000gp/T/ansible_f5networks.f5os.f5os_lag_payload_bhuzjja0/ansible_f5networks.f5os.f5os_lag_payload.zip/ansible_collections/f5networks/f5os/plugins/modules/f5os_lag.py\", line 455, in create\n  File \"/var/folders/j_/jg5t8wmn76q_3d9trzy6g73m0000gp/T/ansible_f5networks.f5os.f5os_lag_payload_bhuzjja0/ansible_f5networks.f5os.f5os_lag_payload.zip/ansible_collections/f5networks/f5os/plugins/modules/f5os_lag.py\", line 507, in create_on_device\n  File \"/var/folders/j_/jg5t8wmn76q_3d9trzy6g73m0000gp/T/ansible_f5networks.f5os.f5os_lag_payload_bhuzjja0/ansible_f5networks.f5os.f5os_lag_payload.zip/ansible_collections/f5networks/f5os/plugins/modules/f5os_lag.py\", line 479, in _populate_vlans\nKeyError: 'openconfig-vlan:switched-vlan'\n", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}

But when manually creating a LAG with the desired name the modules works fine is changing the LAG conform the Ansible playbook.

changed: [<device-fqdn>  -> <ip>] => {
    "changed": true,
    "config_members": [
        "5.0",
        "6.0"
    ],
    "invocation": {
        "module_args": {
            "config_members": [
                "5.0",
                "6.0"
            ],
            "interval": "slow",
            "lag_type": "lacp",
            "mode": "active",
            "name": "lag-prod",
            "native_vlan": 2087,
            "state": "present",
            "trunk_vlans": null
        }
    }
}
STEPS TO REPRODUCE

Without any LAG config present the playbook fails but when a LAG with the same name is present the module works fine. Also tested version 1.9.0 and 1.10.0 and both have the same issue.

- name: Create LAG
  delegate_to: "{{ f5os_ip }}"
  f5networks.f5os.f5os_lag:
    name: "lag-prod"
    lag_type: "lacp"
    native_vlan: "{{ vlans[0] }}"
    mode: "active"
    interval: "slow"
    config_members:
      - "5.0"
      - "6.0"
    state: present
EXPECTED RESULTS

LAG should be created wihtout errors

ACTUAL RESULTS
TASK [f5os-base-config : Create LAG] ***********************************************************************************************************************************************************************************************************************************************************************************************************************************
task path: /Users/xxx/Developer/F5-DO/ansible/roles/f5os-base-config/tasks/main.yaml:20
The full traceback is:
Traceback (most recent call last):
  File "/Users/xxx/.ansible/tmp/ansible-local-38631knr3h979/ansible-tmp-1726210826.1286988-39223-82725270556885/AnsiballZ_f5os_lag.py", line 107, in <module>
    _ansiballz_main()
  File "/Users/xxx/.ansible/tmp/ansible-local-38631knr3h979/ansible-tmp-1726210826.1286988-39223-82725270556885/AnsiballZ_f5os_lag.py", line 99, in _ansiballz_main
    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
  File "/Users/xxx/.ansible/tmp/ansible-local-38631knr3h979/ansible-tmp-1726210826.1286988-39223-82725270556885/AnsiballZ_f5os_lag.py", line 47, in invoke_module
    runpy.run_module(mod_name='ansible_collections.f5networks.f5os.plugins.modules.f5os_lag', init_globals=dict(_module_fqn='ansible_collections.f5networks.f5os.plugins.modules.f5os_lag', _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 "/var/folders/j_/jg5t8wmn76q_3d9trzy6g73m0000gp/T/ansible_f5networks.f5os.f5os_lag_payload_z80ukuec/ansible_f5networks.f5os.f5os_lag_payload.zip/ansible_collections/f5networks/f5os/plugins/modules/f5os_lag.py", line 725, in <module>
  File "/var/folders/j_/jg5t8wmn76q_3d9trzy6g73m0000gp/T/ansible_f5networks.f5os.f5os_lag_payload_z80ukuec/ansible_f5networks.f5os.f5os_lag_payload.zip/ansible_collections/f5networks/f5os/plugins/modules/f5os_lag.py", line 718, in main
  File "/var/folders/j_/jg5t8wmn76q_3d9trzy6g73m0000gp/T/ansible_f5networks.f5os.f5os_lag_payload_z80ukuec/ansible_f5networks.f5os.f5os_lag_payload.zip/ansible_collections/f5networks/f5os/plugins/modules/f5os_lag.py", line 403, in exec_module
  File "/var/folders/j_/jg5t8wmn76q_3d9trzy6g73m0000gp/T/ansible_f5networks.f5os.f5os_lag_payload_z80ukuec/ansible_f5networks.f5os.f5os_lag_payload.zip/ansible_collections/f5networks/f5os/plugins/modules/f5os_lag.py", line 419, in present
  File "/var/folders/j_/jg5t8wmn76q_3d9trzy6g73m0000gp/T/ansible_f5networks.f5os.f5os_lag_payload_z80ukuec/ansible_f5networks.f5os.f5os_lag_payload.zip/ansible_collections/f5networks/f5os/plugins/modules/f5os_lag.py", line 455, in create
  File "/var/folders/j_/jg5t8wmn76q_3d9trzy6g73m0000gp/T/ansible_f5networks.f5os.f5os_lag_payload_z80ukuec/ansible_f5networks.f5os.f5os_lag_payload.zip/ansible_collections/f5networks/f5os/plugins/modules/f5os_lag.py", line 507, in create_on_device
  File "/var/folders/j_/jg5t8wmn76q_3d9trzy6g73m0000gp/T/ansible_f5networks.f5os.f5os_lag_payload_z80ukuec/ansible_f5networks.f5os.f5os_lag_payload.zip/ansible_collections/f5networks/f5os/plugins/modules/f5os_lag.py", line 479, in _populate_vlans
KeyError: 'openconfig-vlan:switched-vlan'
fatal: [<fqdn> -> <ip>]: FAILED! => {
    "changed": false,
    "module_stderr": "Traceback (most recent call last):\n  File \"/Users/xxx/.ansible/tmp/ansible-local-38631knr3h979/ansible-tmp-1726210826.1286988-39223-82725270556885/AnsiballZ_f5os_lag.py\", line 107, in <module>\n    _ansiballz_main()\n  File \"/Users/xxx/.ansible/tmp/ansible-local-38631knr3h979/ansible-tmp-1726210826.1286988-39223-82725270556885/AnsiballZ_f5os_lag.py\", line 99, in _ansiballz_main\n    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n  File \"/Users/xxx/.ansible/tmp/ansible-local-38631knr3h979/ansible-tmp-1726210826.1286988-39223-82725270556885/AnsiballZ_f5os_lag.py\", line 47, in invoke_module\n    runpy.run_module(mod_name='ansible_collections.f5networks.f5os.plugins.modules.f5os_lag', init_globals=dict(_module_fqn='ansible_collections.f5networks.f5os.plugins.modules.f5os_lag', _modlib_path=modlib_path),\n  File \"<frozen runpy>\", line 226, in run_module\n  File \"<frozen runpy>\", line 98, in _run_module_code\n  File \"<frozen runpy>\", line 88, in _run_code\n  File \"/var/folders/j_/jg5t8wmn76q_3d9trzy6g73m0000gp/T/ansible_f5networks.f5os.f5os_lag_payload_z80ukuec/ansible_f5networks.f5os.f5os_lag_payload.zip/ansible_collections/f5networks/f5os/plugins/modules/f5os_lag.py\", line 725, in <module>\n  File \"/var/folders/j_/jg5t8wmn76q_3d9trzy6g73m0000gp/T/ansible_f5networks.f5os.f5os_lag_payload_z80ukuec/ansible_f5networks.f5os.f5os_lag_payload.zip/ansible_collections/f5networks/f5os/plugins/modules/f5os_lag.py\", line 718, in main\n  File \"/var/folders/j_/jg5t8wmn76q_3d9trzy6g73m0000gp/T/ansible_f5networks.f5os.f5os_lag_payload_z80ukuec/ansible_f5networks.f5os.f5os_lag_payload.zip/ansible_collections/f5networks/f5os/plugins/modules/f5os_lag.py\", line 403, in exec_module\n  File \"/var/folders/j_/jg5t8wmn76q_3d9trzy6g73m0000gp/T/ansible_f5networks.f5os.f5os_lag_payload_z80ukuec/ansible_f5networks.f5os.f5os_lag_payload.zip/ansible_collections/f5networks/f5os/plugins/modules/f5os_lag.py\", line 419, in present\n  File \"/var/folders/j_/jg5t8wmn76q_3d9trzy6g73m0000gp/T/ansible_f5networks.f5os.f5os_lag_payload_z80ukuec/ansible_f5networks.f5os.f5os_lag_payload.zip/ansible_collections/f5networks/f5os/plugins/modules/f5os_lag.py\", line 455, in create\n  File \"/var/folders/j_/jg5t8wmn76q_3d9trzy6g73m0000gp/T/ansible_f5networks.f5os.f5os_lag_payload_z80ukuec/ansible_f5networks.f5os.f5os_lag_payload.zip/ansible_collections/f5networks/f5os/plugins/modules/f5os_lag.py\", line 507, in create_on_device\n  File \"/var/folders/j_/jg5t8wmn76q_3d9trzy6g73m0000gp/T/ansible_f5networks.f5os.f5os_lag_payload_z80ukuec/ansible_f5networks.f5os.f5os_lag_payload.zip/ansible_collections/f5networks/f5os/plugins/modules/f5os_lag.py\", line 479, in _populate_vlans\nKeyError: 'openconfig-vlan:switched-vlan'\n",
    "module_stdout": "",
    "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
    "rc": 1
}
pgouband commented 1 month ago

HI @RemcoAA,

The issue occured on Velos or rSeries or both?

RemcoAA commented 1 month ago

rSeries

pgouband commented 1 month ago

Hi,

Thanks for reporting. Added to the backlog and internal tracking ID for this request is: INFRAANO-1662.

urohit011 commented 1 month ago

Hello, this issue has been fixed and available in the daily builds.

RemcoAA commented 1 month ago

I have not yet tested the daily build but just now noticed that the "lag_type": "lacp" option does not work. The lags are created as lag_type = static.

Is this a known issue otherwise, I will raise another issue?

urohit011 commented 1 month ago

I checked on VELOS v1.7 and rSeries v1.8, it creates lags with type LACP. Did you notice on rSeries or VELOS? And which version please?

RemcoAA commented 1 month ago

rSeries running v1.7.0-8741

urohit011 commented 1 month ago

I'll check and let you know

urohit011 commented 1 month ago

Hello @RemcoAA , I checked on v1.7.0-8741 and it correctly created a lag of type 'lacp'.

RemcoAA commented 1 month ago

Which version of the module are you using? I am still using v1.11 and to have this one working the lag name should already be there. So when I manual create this with only the correct name and the reset default (type-static) and run the playbook this is the output.

TASK [f5os-base-config : Create LAG] **** task path: /Users/xxx/ansible/roles/f5os-base-config/tasks/main.yaml:55 changed: [ -> ] => { "changed": true, "config_members": [ "5.0", "6.0" ], "invocation": { "module_args": { "config_members": [ "5.0", "6.0" ], "interval": "slow", "lag_type": "lacp", "mode": "active", "name": "lag-prod", "native_vlan": null, "state": "present", "trunk_vlans": [ 2087 ] } } }

As you can see it should change the type to LACP but on the device the interfaces and vlans are added but the type is still static.

urohit011 commented 1 month ago

Is the issue occurring when updating and existing LAG?

RemcoAA commented 1 month ago

Yes and due to this bug the module only works for updates.

urohit011 commented 1 month ago

I see, the issue is coming when updating a static LAG to lacp, we'll work on it can you open a new issue, please.