mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
gcp_compute: Add vars_prefix to prefix host_vars (#49601)
* Add vars_prefix to prefix host_vars * Set vars_prefix default to empty string
This commit is contained in:
parent
332dc6a93a
commit
f97abc095b
1 changed files with 7 additions and 1 deletions
|
@ -48,6 +48,9 @@ DOCUMENTATION = '''
|
|||
description:
|
||||
- An optional service account email address if machineaccount is selected
|
||||
and the user does not wish to use the default email.
|
||||
vars_prefix:
|
||||
description: prefix to apply to host variables, does not include facts nor params
|
||||
default: ''
|
||||
'''
|
||||
|
||||
EXAMPLES = '''
|
||||
|
@ -111,7 +114,10 @@ class InventoryModule(BaseInventoryPlugin, Constructable, Cacheable):
|
|||
hostname = self._get_hostname(item)
|
||||
self.inventory.add_host(hostname)
|
||||
for key in item:
|
||||
self.inventory.set_variable(hostname, key, item[key])
|
||||
try:
|
||||
self.inventory.set_variable(hostname, self.get_option('vars_prefix') + key, item[key])
|
||||
except (ValueError, TypeError) as e:
|
||||
self.display.warning("Could not set host info hostvar for %s, skipping %s: %s" % (hostname, key, to_native(e)))
|
||||
self.inventory.add_child('all', hostname)
|
||||
|
||||
def verify_file(self, path):
|
||||
|
|
Loading…
Reference in a new issue