Hello all,
We are facing one issue with dynamic inventory of azure.
Getting below error
ansible-inventory -i test.azure_rm.yaml --graph -vvv
ansible-inventory [core 2.13.7]
config file = /etc/ansible/ansible.cfg
configured module search path = [‘/root/.ansible/plugins/modules’, ‘/usr/share/ansible/plugins/modules’]
ansible python module location = /usr/lib/python3/dist-packages/ansible
ansible collection location = /root/.ansible/collections:/usr/share/ansible/collections
executable location = /usr/bin/ansible-inventory
python version = 3.10.6 (main, Nov 14 2022, 16:10:14) [GCC 11.3.0]
jinja version = 3.0.3
libyaml = True
Using /etc/ansible/ansible.cfg as config file
host_list declined parsing /root/test.azure_rm.yaml as it did not pass its verify_file() method
script declined parsing /root/test.azure_rm.yaml as it did not pass its verify_file() method
Using inventory plugin ‘ansible_collections.azure.azcollection.plugins.inventory.azure_rm’ to process inventory source ‘/root/test.azure_rm.yaml’
toml declined parsing /root/test.azure_rm.yaml as it did not pass its verify_file() method
[WARNING]: * Failed to parse /root/test.azure_rm.yaml with auto plugin: Failed to get credentials. Either pass as
parameters, set environment variables, define a profile in ~/.azure/credentials, or install Azure CLI and log in (az login).
File “/usr/lib/python3/dist-packages/ansible/inventory/manager.py”, line 290, in parse_source
plugin.parse(self._inventory, self._loader, source, cache=cache)
File “/usr/lib/python3/dist-packages/ansible/plugins/inventory/auto.py”, line 59, in parse
plugin.parse(inventory, loader, path, cache=cache)
File “/root/.ansible/collections/ansible_collections/azure/azcollection/plugins/inventory/azure_rm.py”, line 220, in parse
self._credential_setup()
File “/root/.ansible/collections/ansible_collections/azure/azcollection/plugins/inventory/azure_rm.py”, line 241, in _credential_setup
self.azure_auth = AzureRMAuth(**auth_options)
File “/root/.ansible/collections/ansible_collections/azure/azcollection/plugins/module_utils/azure_rm_common.py”, line 1479, in init
self.fail("Failed to get credentials. Either pass as parameters, set environment variables, "
File “/root/.ansible/collections/ansible_collections/azure/azcollection/plugins/module_utils/azure_rm_common.py”, line 1605, in fail
self._fail_impl(msg)
File “/root/.ansible/collections/ansible_collections/azure/azcollection/plugins/module_utils/azure_rm_common.py”, line 1608, in _default_fail_impl
raise AzureRMAuthException(msg)
[WARNING]: * Failed to parse /root/test.azure_rm.yaml with yaml plugin: Plugin configuration YAML file, not YAML inventory
File “/usr/lib/python3/dist-packages/ansible/inventory/manager.py”, line 290, in parse_source
plugin.parse(self._inventory, self._loader, source, cache=cache)
File “/usr/lib/python3/dist-packages/ansible/plugins/inventory/yaml.py”, line 114, in parse
raise AnsibleParserError(‘Plugin configuration YAML file, not YAML inventory’)
[WARNING]: * Failed to parse /root/test.azure_rm.yaml with ini plugin: Invalid host pattern ‘plugin:’ supplied, ending in
‘:’ is not allowed, this character is reserved to provide a port.
File “/usr/lib/python3/dist-packages/ansible/inventory/manager.py”, line 290, in parse_source
plugin.parse(self._inventory, self._loader, source, cache=cache)
File “/usr/lib/python3/dist-packages/ansible/plugins/inventory/ini.py”, line 136, in parse
raise AnsibleParserError(e)
[WARNING]: Unable to parse /root/test.azure_rm.yaml as an inventory source
[WARNING]: No inventory was parsed, only implicit localhost is available
@all:
|–@ungrouped:
Able to do az vm list
az vm list | wc -l
1341
my azure inventory is below
cat test.azure_rm.yaml
plugin: azure.azcollection.azure_rm
auth_source: auto
include_vm_resource_groups:
- ‘*’
vars:
ansible_python_interpreter: /usr/bin/python3