After upgrading Ansible Azure plugin module, while running my old ansible scripts against Azure resources to change or get information I was receiving error of TypeError: deprecated() got an unexpected keyword argument. (My credentials are stored in the file location of vim ~/.azure/credentials)
Related Article: Quickstart How to authenticate Ansible with Microsoft Azure
This issue occurs due to pyOpenSSL pip module version is not compatible with Ansible Azure modules. As a resolution I uninstalled pyOpenSSL module from Python PIP. I tried downgrading pip module. But previous versions didn't work for me.
After removal as you can see I am able to connect to Azure and fetch the required information from Microsoft Azure Cloud.
root@ubuntu2004:/home/ubuntu/Documents/Ansible/RGInfo# vim ~/.azure/credentials root@ubuntu2004:/home/ubuntu/Documents/Ansible/RGInfo# ansible localhost -m azure.azcollection.azure_rm_resourcegroup_info An exception occurred during task execution. To see the full traceback, use -vvv. The error was: TypeError: deprecated() got an unexpected keyword argument 'name' localhost | FAILED! => { "changed": false, "module_stderr": "Traceback (most recent call last):\n File \"/root/.ansible/tmp/ansible-tmp-1678638443.7841265-19909-212129883191283/AnsiballZ_azure_rm_resourcegroup_info.py\", line 107, in <module>\n _ansiballz_main()\n File \"/root/.ansible/tmp/ansible-tmp-1678638443.7841265-19909-212129883191283/AnsiballZ_azure_rm_resourcegroup_info.py\", line 99, in _ansiballz_main\n invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n File \"/root/.ansible/tmp/ansible-tmp-1678638443.7841265-19909-212129883191283/AnsiballZ_azure_rm_resourcegroup_info.py\", line 47, in invoke_module\n 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),\n File \"/usr/lib/python3.8/runpy.py\", line 207, in run_module\n return _run_module_code(code, init_globals, run_name, mod_spec)\n File \"/usr/lib/python3.8/runpy.py\", line 97, in _run_module_code\n _run_code(code, mod_globals, init_globals,\n File \"/usr/lib/python3.8/runpy.py\", line 87, in _run_code\n exec(code, run_globals)\n File \"/tmp/ansible_azure.azcollection.azure_rm_resourcegroup_info_payload_d5h_w38y/ansible_azure.azcollection.azure_rm_resourcegroup_info_payload.zip/ansible_collections/azure/azcollection/plugins/modules/azure_rm_resourcegroup_info.py\", line 135, in <module>\n File \"<frozen importlib._bootstrap>\", line 991, in _find_and_load\n File \"<frozen importlib._bootstrap>\", line 975, in _find_and_load_unlocked\n File \"<frozen importlib._bootstrap>\", line 655, in _load_unlocked\n File \"<frozen importlib._bootstrap>\", line 618, in _load_backward_compatible\n File \"<frozen zipimport>\", line 259, in load_module\n File \"/tmp/ansible_azure.azcollection.azure_rm_resourcegroup_info_payload_d5h_w38y/ansible_azure.azcollection.azure_rm_resourcegroup_info_payload.zip/ansible_collections/azure/azcollection/plugins/module_utils/azure_rm_common.py\", line 226, in <module>\n File \"/usr/local/lib/python3.8/dist-packages/msrest/__init__.py\", line 28, in <module>\n from .configuration import Configuration\n File \"/usr/local/lib/python3.8/dist-packages/msrest/configuration.py\", line 37, in <module>\n from .pipeline import Pipeline\n File \"/usr/local/lib/python3.8/dist-packages/msrest/pipeline/__init__.py\", line 52, in <module>\n from requests.structures import CaseInsensitiveDict\n File \"/usr/lib/python3/dist-packages/requests/__init__.py\", line 95, in <module>\n from urllib3.contrib import pyopenssl\n File \"/usr/lib/python3/dist-packages/urllib3/contrib/pyopenssl.py\", line 46, in <module>\n import OpenSSL.SSL\n File \"/usr/local/lib/python3.8/dist-packages/OpenSSL/__init__.py\", line 8, in <module>\n from OpenSSL import SSL, crypto\n File \"/usr/local/lib/python3.8/dist-packages/OpenSSL/SSL.py\", line 19, in <module>\n from OpenSSL.crypto import (\n File \"/usr/local/lib/python3.8/dist-packages/OpenSSL/crypto.py\", line 3253, in <module>\n utils.deprecated(\nTypeError: deprecated() got an unexpected keyword argument 'name'\nError in sys.excepthook:\nTraceback (most recent call last):\n File \"/usr/lib/python3/dist-packages/apport_python_hook.py\", line 72, in apport_excepthook\n from apport.fileutils import likely_packaged, get_recent_crashes\n File \"/usr/lib/python3/dist-packages/apport/__init__.py\", line 5, in <module>\n from apport.report import Report\n File \"/usr/lib/python3/dist-packages/apport/report.py\", line 32, in <module>\n import apport.fileutils\n File \"/usr/lib/python3/dist-packages/apport/fileutils.py\", line 12, in <module>\n import os, glob, subprocess, os.path, time, pwd, sys, requests_unixsocket\n File \"/usr/lib/python3/dist-packages/requests_unixsocket/__init__.py\", line 1, in <module>\n import requests\n File \"/usr/lib/python3/dist-packages/requests/__init__.py\", line 95, in <module>\n from urllib3.contrib import pyopenssl\n File \"/usr/lib/python3/dist-packages/urllib3/contrib/pyopenssl.py\", line 46, in <module>\n import OpenSSL.SSL\n File \"/usr/local/lib/python3.8/dist-packages/OpenSSL/__init__.py\", line 8, in <module>\n from OpenSSL import SSL, crypto\n File \"/usr/local/lib/python3.8/dist-packages/OpenSSL/SSL.py\", line 19, in <module>\n from OpenSSL.crypto import (\n File \"/usr/local/lib/python3.8/dist-packages/OpenSSL/crypto.py\", line 3253, in <module>\n utils.deprecated(\nTypeError: deprecated() got an unexpected keyword argument 'name'\n\nOriginal exception was:\nTraceback (most recent call last):\n File \"/root/.ansible/tmp/ansible-tmp-1678638443.7841265-19909-212129883191283/AnsiballZ_azure_rm_resourcegroup_info.py\", line 107, in <module>\n _ansiballz_main()\n File \"/root/.ansible/tmp/ansible-tmp-1678638443.7841265-19909-212129883191283/AnsiballZ_azure_rm_resourcegroup_info.py\", line 99, in _ansiballz_main\n invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n File \"/root/.ansible/tmp/ansible-tmp-1678638443.7841265-19909-212129883191283/AnsiballZ_azure_rm_resourcegroup_info.py\", line 47, in invoke_module\n 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),\n File \"/usr/lib/python3.8/runpy.py\", line 207, in run_module\n return _run_module_code(code, init_globals, run_name, mod_spec)\n File \"/usr/lib/python3.8/runpy.py\", line 97, in _run_module_code\n _run_code(code, mod_globals, init_globals,\n File \"/usr/lib/python3.8/runpy.py\", line 87, in _run_code\n exec(code, run_globals)\n File \"/tmp/ansible_azure.azcollection.azure_rm_resourcegroup_info_payload_d5h_w38y/ansible_azure.azcollection.azure_rm_resourcegroup_info_payload.zip/ansible_collections/azure/azcollection/plugins/modules/azure_rm_resourcegroup_info.py\", line 135, in <module>\n File \"<frozen importlib._bootstrap>\", line 991, in _find_and_load\n File \"<frozen importlib._bootstrap>\", line 975, in _find_and_load_unlocked\n File \"<frozen importlib._bootstrap>\", line 655, in _load_unlocked\n File \"<frozen importlib._bootstrap>\", line 618, in _load_backward_compatible\n File \"<frozen zipimport>\", line 259, in load_module\n File \"/tmp/ansible_azure.azcollection.azure_rm_resourcegroup_info_payload_d5h_w38y/ansible_azure.azcollection.azure_rm_resourcegroup_info_payload.zip/ansible_collections/azure/azcollection/plugins/module_utils/azure_rm_common.py\", line 226, in <module>\n File \"/usr/local/lib/python3.8/dist-packages/msrest/__init__.py\", line 28, in <module>\n from .configuration import Configuration\n File \"/usr/local/lib/python3.8/dist-packages/msrest/configuration.py\", line 37, in <module>\n from .pipeline import Pipeline\n File \"/usr/local/lib/python3.8/dist-packages/msrest/pipeline/__init__.py\", line 52, in <module>\n from requests.structures import CaseInsensitiveDict\n File \"/usr/lib/python3/dist-packages/requests/__init__.py\", line 95, in <module>\n from urllib3.contrib import pyopenssl\n File \"/usr/lib/python3/dist-packages/urllib3/contrib/pyopenssl.py\", line 46, in <module>\n import OpenSSL.SSL\n File \"/usr/local/lib/python3.8/dist-packages/OpenSSL/__init__.py\", line 8, in <module>\n from OpenSSL import SSL, crypto\n File \"/usr/local/lib/python3.8/dist-packages/OpenSSL/SSL.py\", line 19, in <module>\n from OpenSSL.crypto import (\n File \"/usr/local/lib/python3.8/dist-packages/OpenSSL/crypto.py\", line 3253, in <module>\n utils.deprecated(\nTypeError: deprecated() got an unexpected keyword argument 'name'\n", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1 } root@ubuntu2004:/home/ubuntu/Documents/Ansible/RGInfo# pip3 uninstall pyOpenSSL Found existing installation: pyOpenSSL 23.0.0 Uninstalling pyOpenSSL-23.0.0: Would remove: /usr/local/lib/python3.8/dist-packages/OpenSSL/* /usr/local/lib/python3.8/dist-packages/pyOpenSSL-23.0.0.dist-info/* Proceed (y/n)? y Successfully uninstalled pyOpenSSL-23.0.0 root@ubuntu2004:/home/ubuntu/Documents/Ansible/RGInfo# root@ubuntu2004:/home/ubuntu/Documents/Ansible/RGInfo# root@ubuntu2004:/home/ubuntu/Documents/Ansible/RGInfo# ansible localhost -m azure.azcollection.azure_rm_resourcegroup_info localhost | SUCCESS => { "changed": false, "resourcegroups": [ { "id": "/subscriptions/9e22fba3-00a9-447c-b954-a26fec38e029/resourceGroups/vCloud-lab.com", "location": "eastus", "name": "vCloud-lab.com", "properties": { "provisioningState": "Succeeded" }, "tags": { "orgnization": "vcloud-lab.com", "owner": "vjanvi" } } ] }
Useful Articles
How to install and configure Ansible on Ubuntu
Get Started: Configure Ansible for Azure Cloud Infrastructure
Install the Microsoft Azure CLI on Ubuntu Linux
Deploy create Virtual Network vNET in Azure cloud using Ansible
Quickstart How to authenticate Ansible with Microsoft Azure
Ansible authenticate to Microsoft Azure using credential profiles Part 1
Ansible authenticate to Microsoft Azure using credential profiles Part 2
Ansible authenticate to Microsoft Azure using credential inside yaml file
Create multiple Azure vnet (Virtual Network) using ansible