Hello,
I have a playbook where I am calling my az commands via the command module.
It works as expected.
I’m trying to convert it to PoSH (different thread) and as I’m seeing some issues there, falling back to using specific Azure Modules.
When I execute the following playbook, it fails.
My intent is just to check for the existence of a resource group, authenticating using service principal.
I’ve got more int he original playbook; however, trying to start small, so I’ve only coded a couple tasks.
get the subscription_id, client_id, tenant, secret
- name: read secret
include_vars:
file: …/files/spsecret
no_log: true
check if resource group exists, pass in the args retrieved in previous step for authentication
- name: check if the rg already exists
azure.azcollection.azure_rm_resourcegroup_info:
name: “np-{{ custom_name }}-rg-east”
subscription_id: “{{ sub_id }}”
client_id: “{{ sp }}”
secret: “{{ secret }}”
tenant: “{{ tenant }}”
register: rg_exists
The full traceback is:
Traceback (most recent call last):
File “/Users/j8683/.ansible/tmp/ansible-tmp-1678891419.194826-50522-78867749364726/AnsiballZ_azure_rm_resourcegroup_info.py”, line 107, in
_ansiballz_main()
File “/Users/j8683/.ansible/tmp/ansible-tmp-1678891419.194826-50522-78867749364726/AnsiballZ_azure_rm_resourcegroup_info.py”, line 99, in _ansiballz_main
invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
File “/Users/j8683/.ansible/tmp/ansible-tmp-1678891419.194826-50522-78867749364726/AnsiballZ_azure_rm_resourcegroup_info.py”, line 47, in invoke_module
runpy.run_module(mod_name=‘ansible_collections.azure.azcollection.plugins.modules.azure_rm_resourcegroup_info’, init_globals=dict(_module_fqn=‘ansible_collections.azure.azcollection.plugins.modules.azure_rm_resourcegroup_info’, _modlib_path=modlib_path),
File “/opt/homebrew/Cellar/python@3.10/3.10.9/Frameworks/Python.framework/Versions/3.10/lib/python3.10/runpy.py”, line 224, in run_module
return _run_module_code(code, init_globals, run_name, mod_spec)
File “/opt/homebrew/Cellar/python@3.10/3.10.9/Frameworks/Python.framework/Versions/3.10/lib/python3.10/runpy.py”, line 96, in _run_module_code
_run_code(code, mod_globals, init_globals,
File “/opt/homebrew/Cellar/python@3.10/3.10.9/Frameworks/Python.framework/Versions/3.10/lib/python3.10/runpy.py”, line 86, in _run_code
exec(code, run_globals)
File “/var/folders/51/76dtk91x4wq1lgdndd_ll6040000gn/T/ansible_azure.azcollection.azure_rm_resourcegroup_info_payload_52xvp3bz/ansible_azure.azcollection.azure_rm_resourcegroup_info_payload.zip/ansible_collections/azure/azcollection/plugins/modules/azure_rm_resourcegroup_info.py”, line 235, in
File “/var/folders/51/76dtk91x4wq1lgdndd_ll6040000gn/T/ansible_azure.azcollection.azure_rm_resourcegroup_info_payload_52xvp3bz/ansible_azure.azcollection.azure_rm_resourcegroup_info_payload.zip/ansible_collections/azure/azcollection/plugins/modules/azure_rm_resourcegroup_info.py”, line 231, in main
File “/var/folders/51/76dtk91x4wq1lgdndd_ll6040000gn/T/ansible_azure.azcollection.azure_rm_resourcegroup_info_payload_52xvp3bz/ansible_azure.azcollection.azure_rm_resourcegroup_info_payload.zip/ansible_collections/azure/azcollection/plugins/modules/azure_rm_resourcegroup_info.py”, line 160, in init
File “/var/folders/51/76dtk91x4wq1lgdndd_ll6040000gn/T/ansible_azure.azcollection.azure_rm_resourcegroup_info_payload_52xvp3bz/ansible_azure.azcollection.azure_rm_resourcegroup_info_payload.zip/ansible_collections/azure/azcollection/plugins/module_utils/azure_rm_common.py”, line 472, in init
File “/var/folders/51/76dtk91x4wq1lgdndd_ll6040000gn/T/ansible_azure.azcollection.azure_rm_resourcegroup_info_payload_52xvp3bz/ansible_azure.azcollection.azure_rm_resourcegroup_info_payload.zip/ansible_collections/azure/azcollection/plugins/modules/azure_rm_resourcegroup_info.py”, line 174, in exec_module
File “/var/folders/51/76dtk91x4wq1lgdndd_ll6040000gn/T/ansible_azure.azcollection.azure_rm_resourcegroup_info_payload_52xvp3bz/ansible_azure.azcollection.azure_rm_resourcegroup_info_payload.zip/ansible_collections/azure/azcollection/plugins/modules/azure_rm_resourcegroup_info.py”, line 194, in get_item
File “/var/folders/51/76dtk91x4wq1lgdndd_ll6040000gn/T/ansible_azure.azcollection.azure_rm_resourcegroup_info_payload_52xvp3bz/ansible_azure.azcollection.azure_rm_resourcegroup_info_payload.zip/ansible_collections/azure/azcollection/plugins/module_utils/azure_rm_common.py”, line 1070, in rm_client
File “/var/folders/51/76dtk91x4wq1lgdndd_ll6040000gn/T/ansible_azure.azcollection.azure_rm_resourcegroup_info_payload_52xvp3bz/ansible_azure.azcollection.azure_rm_resourcegroup_info_payload.zip/ansible_collections/azure/azcollection/plugins/module_utils/azure_rm_common.py”, line 920, in get_mgmt_svc_client
TypeError: ResourceManagementClient.init() missing 1 required positional argument: ‘credential’.
Not getting what is causing the error as I’m passing the parameters required for service principal auth.
In addition, I tried having a az login task, removing the service principal stuff from the ‘check if the rg already exists’ task. The az login worked… but the task failed with the same error.
This is my version of ansible and ansible-core:
ansible 7.3.0
ansible-core 2.14.3
Here’s more details about my environment:
ansible [core 2.14.3]
config file = None
configured module search path = [‘/Users/j8683/.ansible/plugins/modules’, ‘/usr/share/ansible/plugins/modules’]
ansible python module location = /Users/j8683/Library/Python/3.9/lib/python/site-packages/ansible
ansible collection location = /Users/j8683/.ansible/collections:/usr/share/ansible/collections
executable location = /Users/j8683/Library/Python/3.9/bin/ansible
python version = 3.9.6 (default, Sep 26 2022, 11:37:49) [Clang 14.0.0 (clang-1400.0.29.202)] (/Library/Developer/CommandLineTools/usr/bin/python3)
jinja version = 3.1.2
libyaml = True
Thanks,
Shawn