Ansible 2.10 - ModuleNotFoundError: No module named 'azure.mgmt.monitor.version'

1,344 views
Skip to first unread message

nbmp...@gmail.com

unread,
Oct 7, 2020, 7:09:37 AM10/7/20
to Ansible Project
Hi,

I find it impossible to find good guides on how to switch to ansible 2.10 and use galaxy collections. 

SUMMARY

Installed Ansible 2.10 and collection azure.azurecollection. I am unable to get Ansible 2.10 working with collections for my existing playbooks.

COMPONENT NAME

azure_rm_virtualmachine_info

ANSIBLE VERSION
2.10.2 

STEPS TO REPRODUCE
- hosts: localhost gather_facts: no collections: - azure.azcollection

ACTUAL RESULTS
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: ModuleNotFoundError: No module named 'azure.mgmt.monitor.version' fatal: [127.0.0.1]: FAILED! => {"changed": false, "msg": "Failed to import the required Python library (ansible[azure] (azure >= 2.0.0)) on ansible-test's Python /usr/bin/python3. Please read the module documentation and install it in the appropriate location. If the required library is installed, but Ansible is using the wrong Python interpreter, please consult the documentation on ansible_python_interpreter"} 

Hrvoje Gašpar

unread,
Oct 8, 2020, 10:04:46 AM10/8/20
to Ansible Project
You should always take a look at the requirements for each module in collection:
https://docs.ansible.com/ansible/latest/collections/azure/azcollection/azure_rm_virtualmachine_info_module.html

The error is refering to missing python module. 
Have you installed azure sdk for python version 2.0 or higher?? 
Run:

pip list 

See if azure is on the list. 
If not, try  and run:

pip install azure   

If that doesn't help, let me know. 

Nicolai Baral Müller

unread,
Oct 9, 2020, 4:18:26 AM10/9/20
to ansible...@googlegroups.com
Hi,

Thanks. The Azure SDK is no longer available. 

sudo pip3 install azure
[sudo] password for nbm:
Collecting azure
  Using cached azure-5.0.0.zip (4.6 kB)
    ERROR: Command errored out with exit status 1:
     command: /usr/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-0sq87aw5/azure/setup.py'"'"'; __file__='"'"'/tmp/pip-install-0sq87aw5/azure/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-install-0sq87aw5/azure/pip-egg-info
         cwd: /tmp/pip-install-0sq87aw5/azure/
    Complete output (24 lines):
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-install-0sq87aw5/azure/setup.py", line 60, in <module>
        raise RuntimeError(message)
    RuntimeError:
   
    Starting with v5.0.0, the 'azure' meta-package is deprecated and cannot be installed anymore.
    Please install the service specific packages prefixed by `azure` needed for your application.
   
    The complete list of available packages can be found at:
    https://aka.ms/azsdk/python/all
   
    Here's a non-exhaustive list of common packages:
   
    -  azure-mgmt-compute (https://pypi.python.org/pypi/azure-mgmt-compute) : Management of Virtual Machines, etc.
    -  azure-mgmt-storage (https://pypi.python.org/pypi/azure-mgmt-storage) : Management of storage accounts.
    -  azure-mgmt-resource (https://pypi.python.org/pypi/azure-mgmt-resource) : Generic package about Azure Resource Management (ARM)
    -  azure-keyvault-secrets (https://pypi.python.org/pypi/azure-keyvault-secrets) : Access to secrets in Key Vault
    -  azure-storage-blob (https://pypi.python.org/pypi/azure-storage-blob) : Access to blobs in storage accounts
   
    A more comprehensive discussion of the rationale for this decision can be found in the following issue:
    https://github.com/Azure/azure-sdk-for-python/issues/10646
   
   
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.


I have installed the mentioned common packages. 

--
You received this message because you are subscribed to a topic in the Google Groups "Ansible Project" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ansible-project/fKs8pUsTbmw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/6f961d6c-3dac-4524-8020-e61b8013b783n%40googlegroups.com.

Hrvoje Gašpar

unread,
Oct 14, 2020, 7:58:57 AM10/14/20
to Ansible Project
Hey :)

Sorry for the late response, I was unable to check the group for a while. 
The azure sdk version does not need to be latest. It's enough for it to be higher than version 2.0. 

If the meta package became depricated with version 5.0, you can always install the latest before that.

Try this:
sudo pip3 install 'azure<5.0'  


Let me know if you encounter any furhter issues. 

Nicolai Baral Müller

unread,
Oct 14, 2020, 8:08:15 AM10/14/20
to ansible...@googlegroups.com
I also tried that and didnt work :-/ posting this bug in ansible will close right away. so not upgrading :)

--


Mvh

Nicolai

Reply all
Reply to author
Forward
0 new messages