Can't reference azcollection from command line or playbook after installing with ansible-galaxy

Having a problem referencing the azcollection modules after install.

Env:

  • RedHat 9.2 VMs, Ansible AAP 2.5 on separate controller and gateway, Ansible 2.18(pip3.11)
  • EE: ansible-automation-platform-24/ee-supported-rhel9:latest (Shows ansible 2.15 version when running playbook verbose) also: stuck on 24 version per support ticket as 25 has bug with kerberos needed for our windows vms…
  • Following microsoft guide for ansible azure resource creation, created sp and exported 4 required system variables
  • Installed azure.azcollection using ansible-galaxy and using default supported ee from redhat.

Testing:

  • When running test from console using Ansible 2.18 w/ azcollection/requirements.txt pip-r’d:

    • command: ansible localhost -m azure_rm_resourcegroup -a “name=test location=uswest2” -vvv
    • error: Failed to import the required Python library (ansible[azure] (azure >= 2.0.0)) on hostname’s Python /var/lib/awx/venv/awx/bin/python
    • I’ve verified the pip/pip3/pip3.11 install ansible[azure] shows requirements already satisfied for all packages, no errors.
  • When running from a playbook on AAP it uses Ansible 2.15 (assuming from within ee) and I get the error: ERROR! couldn’t resolve module/action ‘azure.azcollection.azure_rm_resourcegroup’

What I’m trying to understand is:

  1. Why does the command line ansible say i don’t have ansible[azure] installed when I can’t find any way it’s not installed?
  2. Do I need to create a custom EE with ansible/other/azure.azcollection or should the default supported ee with ansible 2.15 have what’s needed and the ansible-galaxy method should work for the azcollection parts? Despite azcollection requiring ansible 2.16… (which is why the console version is pip’d to 2.18)
  3. How do the 4 variables exported as part of the azure SP setup get used by the test/playbook? I can see how the command line test might see the vars but not sure how the ee triggered version in aap would see them?

Am I missing a piece somewhere? I’m fairly new to ansible/aap but not system management and this is driving me nuts.

Hi @idlebyte

A couple things to unpack:

  1. For the CLI ansible, do you see the azure.azcollection listed if you do
ansible-galaxy collection list

If you don’t, can you try doing the following:

ansible-galaxy collection install azure.azcollection
  1. We’ve always built a custom EE that includes azure.azcollection since the default images from RH usually don’t. We use a similar base EE to what you mentioned and can say that we’re using the latest version of the azure.azcollection (3.2.0) with Ansible 2.15.12.
  2. The azure.azcollection looks for these environment vars as part of its auth workflow and is transparent to the user. When you launch from AAP/AWX and attach a “Microsoft Azure Resource Manager” credential to the job template, the environment vars will be injected into the EE at launch.

10. Credentials — Ansible AWX community documentation *pinned to the Azure section

If you haven’t built a custom EE before, check out Ansible Builder. And if you’re using AAP, you should be able to use Automation Hub as your image repo (depending on how you AAP installed)
Introduction to Ansible Builder — Ansible Builder Documentation

There was a lot here so feel free to send back any follow-up questions and we do our best to help get you going. I’ll see if I can dig up any good Youtube resources Azure/Ansible and Ansible Builder if I can get some downtime this evening.

Best regards,

Joe

TY for update, I will be trying to create an ee over the next few days.