Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

azure_rm_privateendpoint failed with AttributeError if cert_validation_mode: ignore specified #903

Closed
saito-hideki opened this issue Jun 29, 2022 · 0 comments · Fixed by #904
Labels
has_pr PR fixes have been made medium_priority Medium priority

Comments

@saito-hideki
Copy link
Contributor

SUMMARY

If cert_validation_mode: ignore has been set toazure_rm_privateendpoint module, it doesn't work with azure-mgmt-network 16.0.0(or later).
Since azure-mgmt-network==16.0.0(or later), config attribute is replaced with _config. So I think we need to replace it with _config in the following section:

ISSUE TYPE
  • Bug Report
COMPONENT NAME
  • azure/azcollection/plugins/module_utils/azure_rm_common.py
ANSIBLE VERSION
2.13.1
COLLECTION VERSION
1.13.0
CONFIGURATION
  • ansible.cfg
[defaults]
collections_paths = ./collections
  • test.yml
---
- hosts: localhost
  gather_facts: no

  tasks:
    - azure.azcollection.azure_rm_privateendpoint:
        cert_validation_mode: ignore
        name: my_ansible_test_endpoint
        resource_group: my_ansible_test
        private_link_service_connections:
          - name: my_ansible_test_privlink
            private_link_service_id: /subscriptions/xxx/resourceGroups/my_ansible_test/providers/Microsoft.Network/privateLinkServices/my_ansible_test_privlink
        subnet:
          id: /subscriptions/xxx/resourceGroups/my_ansible_test/providers/Microsoft.Network/virtualNetworks/my_ansibel_test_vnet/subnets/my_ansible_test_subnet
OS / ENVIRONMENT

Red Hat Enterprise Linux release 8.5 (Ootpa)

STEPS TO REPRODUCE
$ python3.9 -m venv venv
$ source venv/bin/activate
(venv)$ pip install -U pip
(venv)$ pip install ansible-core
(venv)$ ansible-galaxy collection install azure.azcollection:1.13.0
(venv)$ pip install -r collections/ansible_collections/azure/azcollection/requirements-azure.txt
(venv)$ az login
(venv)$ ansible-playbook test.yml
EXPECTED RESULTS
$ ansible-playbook test.yml
[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit
localhost does not match 'all'

PLAY [localhost] ***********************************************************************************

TASK [azure.azcollection.azure_rm_privateendpoint] *************************************************
changed: [localhost]

PLAY RECAP *****************************************************************************************
localhost                  : ok=1    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0
ACTUAL RESULTS
]$ ansible-playbook test.yml
[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit
localhost does not match 'all'

PLAY [localhost] ***********************************************************************************

TASK [azure.azcollection.azure_rm_privateendpoint] *************************************************
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: AttributeError: 'NetworkManagementClient' object has no attribute 'config'
fatal: [localhost]: FAILED! => {"changed": false, "module_stderr": "Traceback (most recent call last):\n
  File \"/home/ec2-user/.ansible/tmp/ansible-tmp-1656482016.582451-30656-23983966367178/AnsiballZ_azure_rm_privateendpoint.py\", line 107, in <module>\n
    _ansiballz_main()\n
  File \"/home/ec2-user/.ansible/tmp/ansible-tmp-1656482016.582451-30656-23983966367178/AnsiballZ_azure_rm_privateendpoint.py\", line 99, in _ansiballz_main\n
    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n
  File \"/home/ec2-user/.ansible/tmp/ansible-tmp-1656482016.582451-30656-23983966367178/AnsiballZ_azure_rm_privateendpoint.py\", line 47, in invoke_module\n
    runpy.run_module(mod_name='ansible_collections.azure.azcollection.plugins.modules.azure_rm_privateendpoint', init_globals=dict(_module_fqn='ansible_collections.azure.azcollection.plugins.modules.azure_rm_privateendpoint', _modlib_path=modlib_path),\n
  File \"/usr/lib64/python3.9/runpy.py\", line 210, in run_module\n
    return _run_module_code(code, init_globals, run_name, mod_spec)\n
  File \"/usr/lib64/python3.9/runpy.py\", line 97, in _run_module_code\n
    _run_code(code, mod_globals, init_globals,\n
  File \"/usr/lib64/python3.9/runpy.py\", line 87, in _run_code\n
    exec(code, run_globals)\n
  File \"/tmp/ansible_azure.azcollection.azure_rm_privateendpoint_payload_139bv_v0/ansible_azure.azcollection.azure_rm_privateendpoint_payload.zip/ansible_collections/azure/azcollection/plugins/modules/azure_rm_privateendpoint.py\", line 341, in <module>\n
  File \"/tmp/ansible_azure.azcollection.azure_rm_privateendpoint_payload_139bv_v0/ansible_azure.azcollection.azure_rm_privateendpoint_payload.zip/ansible_collections/azure/azcollection/plugins/modules/azure_rm_privateendpoint.py\", line 337, in main\n
  File \"/tmp/ansible_azure.azcollection.azure_rm_privateendpoint_payload_139bv_v0/ansible_azure.azcollection.azure_rm_privateendpoint_payload.zip/ansible_collections/azure/azcollection/plugins/modules/azure_rm_privateendpoint.py\", line 228, in __init__\n
  File \"/tmp/ansible_azure.azcollection.azure_rm_privateendpoint_payload_139bv_v0/ansible_azure.azcollection.azure_rm_privateendpoint_payload.zip/ansible_collections/azure/azcollection/plugins/module_utils/azure_rm_common.py\", line 469, in __init__\n
  File \"/tmp/ansible_azure.azcollection.azure_rm_privateendpoint_payload_139bv_v0/ansible_azure.azcollection.azure_rm_privateendpoint_payload.zip/ansible_collections/azure/azcollection/plugins/modules/azure_rm_privateendpoint.py\", line 250, in exec_module\n
  File \"/tmp/ansible_azure.azcollection.azure_rm_privateendpoint_payload_139bv_v0/ansible_azure.azcollection.azure_rm_privateendpoint_payload.zip/ansible_collections/azure/azcollection/plugins/modules/azure_rm_privateendpoint.py\", line 302, in get_resource\n
  File \"/tmp/ansible_azure.azcollection.azure_rm_privateendpoint_payload_139bv_v0/ansible_azure.azcollection.azure_rm_privateendpoint_payload.zip/ansible_collections/azure/azcollection/plugins/module_utils/azure_rm_common.py\", line 1056, in network_client\n
  File \"/tmp/ansible_azure.azcollection.azure_rm_privateendpoint_payload_139bv_v0/ansible_azure.azcollection.azure_rm_privateendpoint_payload.zip/ansible_collections/azure/azcollection/plugins/module_utils/azure_rm_common.py\", line 940, in get_mgmt_svc_client\n
AttributeError: 'NetworkManagementClient' object has no attribute 'config'\n", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}

PLAY RECAP *****************************************************************************************
localhost                  : ok=0    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0
saito-hideki added a commit to saito-hideki/azure that referenced this issue Jun 29, 2022
* Addresses issue ansible-collections#903

Signed-off-by: Hideki Saito <saito@fgrep.org>
saito-hideki added a commit to saito-hideki/azure that referenced this issue Jun 29, 2022
* Addresses issue ansible-collections#903

Signed-off-by: Hideki Saito <saito@fgrep.org>
saito-hideki added a commit to saito-hideki/azure that referenced this issue Jun 30, 2022
* Addresses issue ansible-collections#903

Signed-off-by: Hideki Saito <saito@fgrep.org>
@Fred-sun Fred-sun added has_pr PR fixes have been made medium_priority Medium priority labels Jul 4, 2022
saito-hideki added a commit to saito-hideki/azure that referenced this issue Jul 4, 2022
* Addresses issue ansible-collections#903

Signed-off-by: Hideki Saito <saito@fgrep.org>
xuzhang3 pushed a commit that referenced this issue Jul 20, 2022
* Addresses issue #903

Signed-off-by: Hideki Saito <saito@fgrep.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
has_pr PR fixes have been made medium_priority Medium priority
Projects
None yet
2 participants