The error was: ModuleNotFoundError: No module named 'azure.mgmt.managementgroups

ansible [core 2.17.10]
config file = /etc/ansible/ansible.cfg
configured module search path = [‘/home/azureuser/.ansible/plugins/modules’, ‘/usr/share/ansible/plugins/modules’]
ansible python module location = /usr/local/lib/python3.10/dist-packages/ansible
ansible collection location = /home/azureuser/.ansible/collections:/usr/share/ansible/collections
executable location = /usr/local/bin/ansible
python version = 3.10.12 (main, Feb 4 2025, 14:57:36) [GCC 11.4.0] (/usr/bin/python3.10)
jinja version = 3.1.6

the python interpreter is set to the correct path, and the package is there. could this be version?
python 3.10
ansible 2.17.10

/home/azureuser/.ansible/collections/ansible_collections

Collection Version


azure.azcollection 3.3.1

/usr/local/lib/python3.10/dist-packages/ansible_collections

Collection Version


azure.azcollection 2.7.0

pip list returns this
azure-mgmt-managementgroups 1.0.0

- my code!
  • Set at least one tag (the experts follow the tags, so the right people will find you if you tag)
    python ansible azure

You can run ansible-galaxy collection list and see if its installed. if not, you can run ansible-galaxy collection install azure.azcollection to install it (as well as installing all all the things required in its requirements.txt)

1 Like

it looks as if it is installed

It sounds like you might be addressing it incorrectly (I don’t see example code listed, so I can’t be sure). Based on the documentation I found it likely needs do be

- name: my cool task
  azure_rm_managementgroup:

instead of (what I am assuming you’re doing, based on the error you shared)

- name: my cool task
  azure.mgmt.managementgroup:

pip list shows this
azure-mgmt-keyvault 1.1.0
azure-mgmt-loganalytics 1.0.0
azure-mgmt-managedservices 1.0.0
azure-mgmt-managementgroups 1.0.0
azure-mgmt-marketplaceordering 0.1.0
azure-mgmt-monitor 0.5.2

Ansible is using this specific python /usr/bin/python3.10, ensure you are using the corresponding pip, even better, use it as python module /usr/bin/python3.10 -m pip ...