You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I am using the google.cloud.gcp_compute to generate and inventory with the retrieve_image_info: true option enabled and there is multiple projects I get an error that says it fails to parse. This is not an issue with a single project or if run multiple projects but retrieve_image_info: false.
ISSUE TYPE
Bug Report
COMPONENT NAME
google.cloud.gcp_compute
ANSIBLE VERSION
ansible [core 2.17.5]
COLLECTION VERSION
(.venv) ➜ inventory ansible-galaxy collection list google.cloud
# /usr/local/Cellar/ansible/10.5.0/libexec/lib/python3.12/site-packages/ansible_collections
Collection Version
------------ -------
google.cloud 1.4.1
Run the following yaml
ansible-inventory -i gcp.yaml --graph
---
plugin: google.cloud.gcp_computeprojects:
- project-infra-test
- project-infra-stg
- project-infra-prdauth_kind: serviceaccountservice_account_file: /pathtojason.jsonretrieve_image_info: truekeyed_groups:
- prefix: NETWORKkey: networkInterfaces[0].network.name
- prefix: PROJECTkey: project
- prefix: IMAGEkey: imagehostnames:
# List host by name instead of the default public ip
- namefilters:
- NOT labels.goog-gke-node = ""
EXPECTED RESULTS
I would expect to parse through all the projects and group them as expected with only one project.
ACTUAL RESULTS
When I run the command it wont provide any inventory and will error out. Note that if the list of projects is large enough. even with retrieve_image_info: true it will return image: null for all hosts.
(.venv) ➜ inventory ansible-inventory -i gcp.yaml --graph -vvvv
ansible-inventory [core 2.17.5]
config file = None
configured module search path = ['/Users/user.name/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/local/Cellar/ansible/10.5.0/libexec/lib/python3.12/site-packages/ansible
ansible collection location = /Users/user.name/.ansible/collections:/usr/share/ansible/collections
executable location = /usr/local/bin/ansible-inventory
python version = 3.12.7 (main, Oct 1 2024, 02:05:46) [Clang 15.0.0 (clang-1500.3.9.4)] (/usr/local/Cellar/ansible/10.5.0/libexec/bin/python)
jinja version = 3.1.4
libyaml = True
No config file found; using defaults
setting up inventory plugins
Loading collection ansible.builtin from
host_list declined parsing /Users/user.name/notes/AWX/ansible/inventory/gcp.yaml as it did not pass its verify_file() method
script declined parsing /Users/user.name/notes/AWX/ansible/inventory/gcp.yaml as it did not pass its verify_file() method
Loading collection google.cloud from /usr/local/Cellar/ansible/10.5.0/libexec/lib/python3.12/site-packages/ansible_collections/google/cloud
Using inventory plugin 'ansible_collections.google.cloud.plugins.inventory.gcp_compute' to process inventory source '/Users/user.name/notes/AWX/ansible/inventory/gcp.yaml'
toml declined parsing /Users/user.name/notes/AWX/ansible/inventory/gcp.yaml as it did not pass its verify_file() method
[WARNING]: * Failed to parse /Users/user.name/notes/AWX/ansible/inventory/gcp.yaml with auto plugin: 'https://www.googleapis.com/compute/v1/projects/project-infra-test/zones/us-
central1-a/disks/solarwinds-npm-nta'
File "/usr/local/Cellar/ansible/10.5.0/libexec/lib/python3.12/site-packages/ansible/inventory/manager.py", line 292, in parse_source
plugin.parse(self._inventory, self._loader, source, cache=cache)
File "/usr/local/Cellar/ansible/10.5.0/libexec/lib/python3.12/site-packages/ansible/plugins/inventory/auto.py", line 58, in parse
plugin.parse(inventory, loader, path, cache=cache)
File "/usr/local/Cellar/ansible/10.5.0/libexec/lib/python3.12/site-packages/ansible_collections/google/cloud/plugins/inventory/gcp_compute.py", line 622, in parse
self._add_hosts(value, config_data, project_disks=project_disks)
File "/usr/local/Cellar/ansible/10.5.0/libexec/lib/python3.12/site-packages/ansible_collections/google/cloud/plugins/inventory/gcp_compute.py", line 438, in _add_hosts
host = GcpInstance(
^^^^^^^^^^^^
File "/usr/local/Cellar/ansible/10.5.0/libexec/lib/python3.12/site-packages/ansible_collections/google/cloud/plugins/inventory/gcp_compute.py", line 178, in __init__
self.convert()
File "/usr/local/Cellar/ansible/10.5.0/libexec/lib/python3.12/site-packages/ansible_collections/google/cloud/plugins/inventory/gcp_compute.py", line 208, in convert
self.json["image"] = self._get_image()
^^^^^^^^^^^^^^^^^
File "/usr/local/Cellar/ansible/10.5.0/libexec/lib/python3.12/site-packages/ansible_collections/google/cloud/plugins/inventory/gcp_compute.py", line 277, in _get_image
image = self.project_disks[disk["source"]]
~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^
[WARNING]: * Failed to parse /Users/user.name/notes/AWX/ansible/inventory/gcp.yaml with yaml plugin: Plugin configuration YAML file, not YAML inventory
File "/usr/local/Cellar/ansible/10.5.0/libexec/lib/python3.12/site-packages/ansible/inventory/manager.py", line 292, in parse_source
plugin.parse(self._inventory, self._loader, source, cache=cache)
File "/usr/local/Cellar/ansible/10.5.0/libexec/lib/python3.12/site-packages/ansible/plugins/inventory/yaml.py", line 113, in parse
raise AnsibleParserError('Plugin configuration YAML file, not YAML inventory')
[WARNING]: * Failed to parse /Users/user.name/notes/AWX/ansible/inventory/gcp.yaml with ini plugin: Invalid host pattern '---' supplied, '---' is normally a sign this is a YAML file.
File "/usr/local/Cellar/ansible/10.5.0/libexec/lib/python3.12/site-packages/ansible/inventory/manager.py", line 292, in parse_source
plugin.parse(self._inventory, self._loader, source, cache=cache)
File "/usr/local/Cellar/ansible/10.5.0/libexec/lib/python3.12/site-packages/ansible/plugins/inventory/ini.py", line 137, in parse
raise AnsibleParserError(e)
[WARNING]: Unable to parse /Users/user.name/notes/AWX/ansible/inventory/gcp.yaml as an inventory source
[WARNING]: No inventory was parsed, only implicit localhost is available
@all:
The text was updated successfully, but these errors were encountered:
SUMMARY
When I am using the google.cloud.gcp_compute to generate and inventory with the retrieve_image_info: true option enabled and there is multiple projects I get an error that says it fails to parse. This is not an issue with a single project or if run multiple projects but retrieve_image_info: false.
ISSUE TYPE
COMPONENT NAME
google.cloud.gcp_compute
ANSIBLE VERSION
COLLECTION VERSION
CONFIGURATION
OS / ENVIRONMENT
MAc
STEPS TO REPRODUCE
Run the following yaml
ansible-inventory -i gcp.yaml --graph
EXPECTED RESULTS
I would expect to parse through all the projects and group them as expected with only one project.
ACTUAL RESULTS
When I run the command it wont provide any inventory and will error out. Note that if the list of projects is large enough. even with retrieve_image_info: true it will return image: null for all hosts.
The text was updated successfully, but these errors were encountered: