Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Release 1.18.0 breaks azure_rm dynamic inventory plugin #1270

Closed
morco opened this issue Sep 23, 2023 · 3 comments · Fixed by #1271
Closed

New Release 1.18.0 breaks azure_rm dynamic inventory plugin #1270

morco opened this issue Sep 23, 2023 · 3 comments · Fixed by #1271
Assignees
Labels
bug Something isn't working

Comments

@morco
Copy link

morco commented Sep 23, 2023

SUMMARY

When running with newly released version 1.18.0 or current head of dev branch the azure dynamic inventory plugin stops working for us, failing to produce a hostlist from an azure environment and printing an error as ansible warning (see below).

ISSUE TYPE
  • Bug Report
COMPONENT NAME

azure.azcollection.azure_rm inventory

ANSIBLE VERSION
ansible 2.10.8
  config file = /opt/vstsagent/_work/1/s/ansible.cfg
  configured module search path = ['/home/vm-admin/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3/dist-packages/ansible
  executable location = /usr/bin/ansible
  python version = 3.10.12 (main, Jun 11 2023, 05:26:28) [GCC 11.4.0]
COLLECTION VERSION
# /opt/vstsagent/_work/1/s/collections/ansible_collections
Collection         Version
------------------ -------
azure.azcollection 1.18.0 
CONFIGURATION
ANSIBLE_FORCE_COLOR(env: ANSIBLE_FORCE_COLOR) = True
COLLECTIONS_PATHS(/opt/vstsagent/_work/1/s/ansible.cfg) = ['/opt/vstsagent/_work/1/s/collections']
DEFAULT_ROLES_PATH(/opt/vstsagent/_work/1/s/ansible.cfg) = ['/opt/vstsagent/_work/1/s/roles']
DEFAULT_TIMEOUT(/opt/vstsagent/_work/1/s/ansible.cfg) = 300
OS / ENVIRONMENT

Azure Ubuntu Minimal: Ubuntu 22.04.3 LTS (GNU/Linux 6.2.0-1012-azure x86_64)

STEPS TO REPRODUCE

Add azure.azcollection to your collections/requirements.yml and set it explicitly to version 1.18.0 or simply leave version off as buggy version is also current default version.

collections:
   - name: azure.azcollection
     version: 1.18.0

Install ansible collections:

ansible-galaxy collection install -r collections/requirements.yml

Ensure all necessary python deps for plugin to work are installed.

pip3 install -r "[...]/azure/azcollection/requirements-azure.txt"

Create a dynamic inventory configuration file fitting your azure environment / subscription like described in the docu for the
plugin: https://docs.ansible.com/ansible/latest/collections/azure/azcollection/azure_rm_inventory.html

Try to create a dynamic ansible inventory for your azure environment using your plugin config (of course you must also make sure that azure authing works properly for your setup):

ansible-inventory -i <inventory_plugin_cfg.yml> --graph
EXPECTED RESULTS

Inventory plugin "scans" our azure environment and creates a matching ansible inventory entry for each vm found.

ACTUAL RESULTS

Inventory plugin fails to create any ansible host automatically from our azure vms and fails with the following error message:

[WARNING]:  * Failed to parse
/opt/vstsagent/_work/1/s/inventories/tdcs_azure_machines.azure_rm.yml with auto
plugin: 'AzureRMAuth' object has no attribute 'azure_credentials'
[WARNING]:  * Failed to parse
/opt/vstsagent/_work/1/s/inventories/tdcs_azure_machines.azure_rm.yml with yaml
plugin: Plugin configuration YAML file, not YAML inventory
[WARNING]:  * Failed to parse
/opt/vstsagent/_work/1/s/inventories/tdcs_azure_machines.azure_rm.yml with ini
plugin: Invalid host pattern '---' supplied, '---' is normally a sign this is a
YAML file.
[WARNING]: Unable to parse
/opt/vstsagent/_work/1/s/inventories/tdcs_azure_machines.azure_rm.yml as an
inventory source
[WARNING]: No inventory was parsed, only implicit localhost is available
@all:
  |--@ungrouped:

The very first part is imho the important here:

[WARNING]:  * Failed to parse
/opt/vstsagent/_work/1/s/inventories/tdcs_azure_machines.azure_rm.yml with auto
plugin: 'AzureRMAuth' object has no attribute 'azure_credentials'
@morco
Copy link
Author

morco commented Sep 23, 2023

Be aware that this issue can be somewhat tricky to detect as the plugin failing to create and inventory is only a warning in ansible, not an error, and ansible is also totally fine with running your playbook against an empty host list, so your pipeline will run and will be green, but in reality it just does nothing :)

@sbrile
Copy link

sbrile commented Sep 24, 2023

Same for me.

Using inventory plugin 'ansible_collections.azure.azcollection.plugins.inventory.azure_rm' to process inventory source '/runner/project/inv/dev_servers/azure_rm.yml'

toml declined parsing /runner/project/inv/dev_servers/azure_rm.yml as it did not pass its verify_file() method

[WARNING]:  * Failed to parse /runner/project/inv/dev_servers/azure_rm.yml with
auto plugin: 'AzureRMAuth' object has no attribute 'azure_credentials'

  File "/usr/local/lib/python3.9/site-packages/ansible/inventory/manager.py", line 293, in parse_source
    plugin.parse(self._inventory, self._loader, source, cache=cache)

  File "/usr/local/lib/python3.9/site-packages/ansible/plugins/inventory/auto.py", line 59, in parse
    plugin.parse(inventory, loader, path, cache=cache)

  File "/usr/share/ansible/collections/ansible_collections/azure/azcollection/plugins/inventory/azure_rm.py", line 223, in parse
    self._credential_setup()

  File "/usr/share/ansible/collections/ansible_collections/azure/azcollection/plugins/inventory/azure_rm.py", line 246, in _credential_setup
    self._clientconfig = AzureRMRestConfiguration(self.azure_auth.azure_credentials, self.azure_auth.subscription_id,

@sbrile
Copy link

sbrile commented Sep 24, 2023

@xuzhang3 - I'm guessing the issue is caused by #1268

@xuzhang3 xuzhang3 self-assigned this Sep 25, 2023
@xuzhang3 xuzhang3 added the bug Something isn't working label Sep 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants