mirror of
https://github.com/ansible/awx.git
synced 2026-03-04 18:21:03 -03:30
Use option to add back in gce_image hostvar
construct groups from this gce image hostvar
This commit is contained in:
@@ -2339,6 +2339,8 @@ class gce(PluginFileInjector):
|
|||||||
'gce_tags': 'tags.get("items", [])',
|
'gce_tags': 'tags.get("items", [])',
|
||||||
'gce_zone': 'zone',
|
'gce_zone': 'zone',
|
||||||
'gce_metadata': 'metadata.get("items", []) | items2dict(key_name="key", value_name="value")',
|
'gce_metadata': 'metadata.get("items", []) | items2dict(key_name="key", value_name="value")',
|
||||||
|
# NOTE: image hostvar is enabled via retrieve_image_info option
|
||||||
|
'gce_image': 'image',
|
||||||
# We need this as long as hostnames is non-default, otherwise hosts
|
# We need this as long as hostnames is non-default, otherwise hosts
|
||||||
# will not be addressed correctly, was returned in script
|
# will not be addressed correctly, was returned in script
|
||||||
'ansible_ssh_host': 'networkInterfaces[0].accessConfigs[0].natIP'
|
'ansible_ssh_host': 'networkInterfaces[0].accessConfigs[0].natIP'
|
||||||
@@ -2367,7 +2369,9 @@ class gce(PluginFileInjector):
|
|||||||
{'prefix': '', 'separator': '', 'key': 'machineType'},
|
{'prefix': '', 'separator': '', 'key': 'machineType'},
|
||||||
{'prefix': '', 'separator': '', 'key': 'zone'},
|
{'prefix': '', 'separator': '', 'key': 'zone'},
|
||||||
{'prefix': 'tag', 'key': 'gce_tags'}, # composed var
|
{'prefix': 'tag', 'key': 'gce_tags'}, # composed var
|
||||||
{'prefix': 'status', 'key': 'status | lower'}
|
{'prefix': 'status', 'key': 'status | lower'},
|
||||||
|
# NOTE: image hostvar is enabled via retrieve_image_info option
|
||||||
|
{'prefix': '', 'separator': '', 'key': 'image'},
|
||||||
]
|
]
|
||||||
# This will be used as the gce instance_id, must be universal, non-compat
|
# This will be used as the gce instance_id, must be universal, non-compat
|
||||||
compose_dict = {'gce_id': 'id'}
|
compose_dict = {'gce_id': 'id'}
|
||||||
@@ -2376,6 +2380,8 @@ class gce(PluginFileInjector):
|
|||||||
# TODO: proper group_by and instance_filters support, irrelevant of compat mode
|
# TODO: proper group_by and instance_filters support, irrelevant of compat mode
|
||||||
# The gce.py script never sanitized any names in any way
|
# The gce.py script never sanitized any names in any way
|
||||||
ret['use_contrib_script_compatible_sanitization'] = True
|
ret['use_contrib_script_compatible_sanitization'] = True
|
||||||
|
# Perform extra API query to get the image hostvar
|
||||||
|
ret['retrieve_image_info'] = True
|
||||||
# Add in old hostvars aliases
|
# Add in old hostvars aliases
|
||||||
compose_dict.update(self._compat_compose_vars())
|
compose_dict.update(self._compat_compose_vars())
|
||||||
# Non-default names to match script
|
# Non-default names to match script
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ compose:
|
|||||||
ansible_ssh_host: networkInterfaces[0].accessConfigs[0].natIP
|
ansible_ssh_host: networkInterfaces[0].accessConfigs[0].natIP
|
||||||
gce_description: description if description else None
|
gce_description: description if description else None
|
||||||
gce_id: id
|
gce_id: id
|
||||||
|
gce_image: image
|
||||||
gce_machine_type: machineType
|
gce_machine_type: machineType
|
||||||
gce_metadata: metadata.get("items", []) | items2dict(key_name="key", value_name="value")
|
gce_metadata: metadata.get("items", []) | items2dict(key_name="key", value_name="value")
|
||||||
gce_name: name
|
gce_name: name
|
||||||
@@ -36,9 +37,13 @@ keyed_groups:
|
|||||||
prefix: tag
|
prefix: tag
|
||||||
- key: status | lower
|
- key: status | lower
|
||||||
prefix: status
|
prefix: status
|
||||||
|
- key: image
|
||||||
|
prefix: ''
|
||||||
|
separator: ''
|
||||||
plugin: gcp_compute
|
plugin: gcp_compute
|
||||||
projects:
|
projects:
|
||||||
- fooo
|
- fooo
|
||||||
|
retrieve_image_info: true
|
||||||
service_account_file: {{ file_reference }}
|
service_account_file: {{ file_reference }}
|
||||||
use_contrib_script_compatible_sanitization: true
|
use_contrib_script_compatible_sanitization: true
|
||||||
zones:
|
zones:
|
||||||
|
|||||||
Reference in New Issue
Block a user