ansible-collections / azure

Development area for Azure Collections
https://galaxy.ansible.com/azure/azcollection
GNU General Public License v3.0
247 stars 330 forks source link

`azure_rm_networkinterface` pointing to wrong not existing API `2021-03-01` #1471

Closed roelsieg closed 9 months ago

roelsieg commented 9 months ago
SUMMARY

API version for NetworkManagementClient used by azure_rm_networkinterface pointing to wrong not existing API 2021-03-01.

ISSUE TYPE
COMPONENT NAME

I am trying to use the azure_rm_networkinterface

ANSIBLE VERSION
  config file = /runnertmp/_work/ahit-cft-network-f5-deployment/ahit-cft-network-f5-deployment/ansible_ghwf.cfg
  configured module search path = ['/home/runner/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/runner/.local/lib/python3.10/site-packages/ansible
  ansible collection location = /home/runner/.local/lib/python3.10/site-packages/ansible_collections
  executable location = /home/runner/.local/bin/ansible
  python version = 3.10.[12](https://github.com/RoyalAholdDelhaize/ahit-cft-network-f5-deployment/actions/runs/8095607745/job/22122681993#step:12:13) (main, Nov 20 2023, 15:[14](https://github.com/RoyalAholdDelhaize/ahit-cft-network-f5-deployment/actions/runs/8095607745/job/22122681993#step:12:15):05) [GCC 11.4.0] (/usr/bin/python3)
  jinja version = 3.1.3
  libyaml = True
COLLECTION VERSION
Collection         Version
------------------ -------
azure.azcollection 2.2.0  
CONFIGURATION
COLLECTIONS_PATHS(/runnertmp/_work/ahit-cft-network-f5-deployment/ahit-cft-network-f5-deployment/ansible_ghwf.cfg) = ['/home/runner/.local/lib/python3.10/site-packages/ansible_collections']
CONFIG_FILE() = /runnertmp/_work/ahit-cft-network-f5-deployment/ahit-cft-network-f5-deployment/ansible_ghwf.cfg
DEPRECATION_WARNINGS(/runnertmp/_work/ahit-cft-network-f5-deployment/ahit-cft-network-f5-deployment/ansible_ghwf.cfg) = False
OS / ENVIRONMENT

Running ansible from a docker container as a github action runner

STEPS TO REPRODUCE

Just a simple execution within a playbook like this:

   - name: 'Creating/Updating Azure Network Interface(s)'
      azure_rm_networkinterface:
        state: "{{ network_interface_state | default('present') }}"
        name: "{{ network_interface_name }}"
        resource_group: "{{ network_interface_resource_group_name }}"
        virtual_network: "/subscriptions/{{ subscription_id }}/resourceGroups/{{ network_interface_network_resource_group_name }}/providers/Microsoft.Network/virtualNetworks/{{ network_interface_virtual_network_name }}"
        subnet_name: "{{ network_interface_virtual_subnet_name }}"
        create_with_security_group: false
        enable_accelerated_networking: false
        ip_configurations:
          - name: 'ipconfig1'
            primary: true
            private_ip_address: "{{ network_interface_private_ip_address | default(omit) }}"
            private_ip_allocation_method: "{{ network_interface_private_ip_allocation_method | default('Dynamic') }}"
            load_balancer_backend_address_pools: "{{ network_interface_load_balancer_backend_address_pools | default([]) }}"
            application_security_groups: "{{ network_interface_application_security_groups | default([]) }}"
      register: network_interfaces_created
EXPECTED RESULTS

Create the azure_rm_networkinterface resource in Azure

ACTUAL RESULTS
TASK [azure_network_interface_custom : Creating/Updating Azure Network Interface(s)] ***
task path: /runnertmp/_work/ahit-cft-network-f5-deployment/ahit-cft-network-f5-deployment/roles/azure_network_interface_custom/tasks/main.yml:66
redirecting (type: modules) ansible.builtin.azure_rm_networkinterface to azure.azcollection.azure_rm_networkinterface
<localhost> ESTABLISH LOCAL CONNECTION FOR USER: runner
<localhost> EXEC /bin/sh -c 'echo ~runner && sleep 0'
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/runner/.ansible/tmp `"&& mkdir "` echo /home/runner/.ansible/tmp/ansible-tmp-1709211718.7010422-550-188074361084421 `" && echo ansible-tmp-1709211718.7010422-550-188074361084421="` echo /home/runner/.ansible/tmp/ansible-tmp-1709211718.7010422-550-188074361084421 `" ) && sleep 0'
redirecting (type: modules) ansible.builtin.azure_rm_networkinterface to azure.azcollection.azure_rm_networkinterface
<localhost> Attempting python interpreter discovery
<localhost> EXEC /bin/sh -c 'echo PLATFORM; uname; echo FOUND; command -v '"'"'python3.12'"'"'; command -v '"'"'python3.11'"'"'; command -v '"'"'python3.10'"'"'; command -v '"'"'python3.9'"'"'; command -v '"'"'python3.8'"'"'; command -v '"'"'python3.7'"'"'; command -v '"'"'python3.6'"'"'; command -v '"'"'/usr/bin/python3'"'"'; command -v '"'"'/usr/libexec/platform-python'"'"'; command -v '"'"'python2.7'"'"'; command -v '"'"'/usr/bin/python'"'"'; command -v '"'"'python'"'"'; echo ENDFOUND && sleep 0'
<localhost> EXEC /bin/sh -c '/usr/bin/python3.10 && sleep 0'
Using module file /home/runner/.local/lib/python3.10/site-packages/ansible_collections/azure/azcollection/plugins/modules/azure_rm_networkinterface.py
<localhost> PUT /runnertmp/.ansible/tmp/ansible-local-542w1em7r4p/tmpc50bce44 TO /runnertmp/.ansible/tmp/ansible-tmp-1709211718.7010422-550-188074361084421/AnsiballZ_azure_rm_networkinterface.py
<localhost> EXEC /bin/sh -c 'chmod u+x /home/runner/.ansible/tmp/ansible-tmp-1709211718.7010422-550-188074361084421/ /home/runner/.ansible/tmp/ansible-tmp-1709211718.7010422-550-188074361084421/AnsiballZ_azure_rm_networkinterface.py && sleep 0'
<localhost> EXEC /bin/sh -c '/usr/bin/python3 /home/runner/.ansible/tmp/ansible-tmp-1709211718.7010422-550-188074361084421/AnsiballZ_azure_rm_networkinterface.py && sleep 0'
<localhost> EXEC /bin/sh -c 'rm -f -r /home/runner/.ansible/tmp/ansible-tmp-1709211718.7010422-550-188074361084421/ > /dev/null 2>&1 && sleep 0'
The full traceback is:
Traceback (most recent call last):
  File "/home/runner/.ansible/tmp/ansible-tmp-1709211718.7010422-550-188074361084421/AnsiballZ_azure_rm_networkinterface.py", line [107](https://github.com/RoyalAholdDelhaize/ahit-cft-network-f5-deployment/actions/runs/8096439380/job/22125203763#step:10:108), in <module>
    _ansiballz_main()
  File "/home/runner/.ansible/tmp/ansible-tmp-1709211718.7010422-550-18807436[108](https://github.com/RoyalAholdDelhaize/ahit-cft-network-f5-deployment/actions/runs/8096439380/job/22125203763#step:10:109)4421/AnsiballZ_azure_rm_networkinterface.py", line 99, in _ansiballz_main
    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
  File "/home/runner/.ansible/tmp/ansible-tmp-17092[117](https://github.com/RoyalAholdDelhaize/ahit-cft-network-f5-deployment/actions/runs/8096439380/job/22125203763#step:10:118)18.7010422-550-188074361084421/AnsiballZ_azure_rm_networkinterface.py", line 47, in invoke_module
    runpy.run_module(mod_name='ansible_collections.azure.azcollection.plugins.modules.azure_rm_networkinterface', init_globals=dict(_module_fqn='ansible_collections.azure.azcollection.plugins.modules.azure_rm_networkinterface', _modlib_path=modlib_path),
  File "/usr/lib/python3.10/runpy.py", line 224, in run_module
    return _run_module_code(code, init_globals, run_name, mod_spec)
  File "/usr/lib/python3.10/runpy.py", line 96, in _run_module_code
    _run_code(code, mod_globals, init_globals,
  File "/usr/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/tmp/ansible_azure_rm_networkinterface_payload_q33pt9jx/ansible_azure_rm_networkinterface_payload.zip/ansible_collections/azure/azcollection/plugins/modules/azure_rm_networkinterface.py", line 976, in <module>
  File "/tmp/ansible_azure_rm_networkinterface_payload_q33pt9jx/ansible_azure_rm_networkinterface_payload.zip/ansible_collections/azure/azcollection/plugins/modules/azure_rm_networkinterface.py", line 972, in main
  File "/tmp/ansible_azure_rm_networkinterface_payload_q33pt9jx/ansible_azure_rm_networkinterface_payload.zip/ansible_collections/azure/azcollection/plugins/modules/azure_rm_networkinterface.py", line 661, in __init__
  File "/tmp/ansible_azure_rm_networkinterface_payload_q33pt9jx/ansible_azure_rm_networkinterface_payload.zip/ansible_collections/azure/azcollection/plugins/module_utils/azure_rm_common.py", line 469, in __init__
  File "/tmp/ansible_azure_rm_networkinterface_payload_q33pt9jx/ansible_azure_rm_networkinterface_payload.zip/ansible_collections/azure/azcollection/plugins/modules/azure_rm_networkinterface.py", line 723, in exec_module
  File "/home/runner/.local/lib/python3.10/site-packages/azure/mgmt/network/_validation.py", line 25, in wrapper
    raise ValueError(
ValueError: 'network_interfaces' is not available in API version 2021-03-01. All valid API version are 2015-06-15, 2017-10-01, 2018-04-01, 2018-11-01, 2018-12-01, 2019-02-01, 2019-04-01, 2019-06-01, 2019-07-01, 2019-08-01, 2019-09-01, 2019-11-01, 2019-12-01, 2020-03-01, 2020-04-01, 2020-05-01, 2020-06-01, 2020-07-01, 2020-08-01, 2020-11-01, 2021-02-01, 2023-02-01, 2023-04-01, 2023-05-01, 2023-06-01, 2023-09-01.

Since a while the api_version has been pointing here to a not existing API version 2021-03-01 here: https://github.com/ansible-collections/azure/blob/b8d8d09217b5018d681a6a468e55bb7a19b645a1/plugins/module_utils/azure_rm_common.py#L1058

Maybe this is a typo and it should have been 2021-02-01 which is existing. Or something changed on Azure API side?

Fred-sun commented 9 months ago

@roelsieg Can you share your 'azure-mgmt-network' version? Thank you very much!

roelsieg commented 9 months ago

@Fred-sun this is at this version azure-mgmt-network-25.3.0 For your info this is what I installed:

Successfully installed PySocks-1.7.1 adal-1.2.7 aiohttp-3.9.3 aiosignal-1.3.1 anyio-4.3.0 applicationinsights-0.11.10 argcomplete-3.1.6 async-timeout-4.0.3 attrs-23.2.0 azure-cli-core-2.57.0 azure-cli-telemetry-1.1.0 azure-common-1.1.28 azure-core-1.30.0 azure-identity-1.15.0 azure-keyvault-secrets-4.8.0 azure-mgmt-authorization-4.0.0 azure-mgmt-automation-1.0.0 azure-mgmt-compute-30.5.0 azure-mgmt-containerinstance-10.1.0 azure-mgmt-containerregistry-10.3.0 azure-mgmt-containerservice-29.1.0 azure-mgmt-core-1.4.0 azure-mgmt-datafactory-5.0.0 azure-mgmt-datalake-nspkg-3.0.1 azure-mgmt-datalake-store-0.5.0 azure-mgmt-dns-8.1.0 azure-mgmt-eventhub-11.0.0 azure-mgmt-iothub-3.0.0 azure-mgmt-keyvault-10.3.0 azure-mgmt-loganalytics-12.0.0 azure-mgmt-managementgroups-1.0.0 azure-mgmt-marketplaceordering-1.1.0 azure-mgmt-monitor-6.0.2 azure-mgmt-network-25.3.0 azure-mgmt-notificationhubs-8.0.0 azure-mgmt-nspkg-3.0.2 azure-mgmt-privatedns-1.1.0 azure-mgmt-rdbms-10.1.0 azure-mgmt-recoveryservicesbackup-3.0.0 azure-mgmt
Fred-sun commented 9 months ago

@roelsieg Can you downgrade to the specified version 'azure-mgmt-network==19.1.0'? Because of these dependency upgrades, it is possible to change the version specified by the code. Thank you!

Fred-sun commented 9 months ago

kindly ping!

roelsieg commented 9 months ago

I can confirm the version 19.1.0 from 2021-10-09 is a valid work around. Thanks a lot @Fred-sun for finding that in the dependency tree for us. I hope there will be a permanent fix in a future release of the ansible code also so we don't need to maintain old sdk versions for dependency reasons.

Fred-sun commented 9 months ago

@roelsieg Yeah, we'll set up a time to upgrade together. Thank you!