mirror of
https://github.com/ansible-collections/google.cloud.git
synced 2025-07-29 08:01:31 -07:00
Adding hostname support to dynamic inventory
Fixes #434 It is basically the same as #438 but with a few extra checks, don't want to rebase the whole thing. Signed-off-by: Jorge Gallegos <jgallego@redhat.com>
This commit is contained in:
parent
4d9aa19dc6
commit
3e3611fb23
1 changed files with 5 additions and 3 deletions
|
@ -23,7 +23,7 @@ DOCUMENTATION = """
|
||||||
required: True
|
required: True
|
||||||
choices: ['google.cloud.gcp_compute', 'gcp_compute']
|
choices: ['google.cloud.gcp_compute', 'gcp_compute']
|
||||||
zones:
|
zones:
|
||||||
description: A list of regions in which to describe GCE instances.
|
description: A list of zones in which to describe GCE instances.
|
||||||
If none provided, it defaults to all zones available to a given project.
|
If none provided, it defaults to all zones available to a given project.
|
||||||
type: list
|
type: list
|
||||||
elements: string
|
elements: string
|
||||||
|
@ -48,7 +48,7 @@ DOCUMENTATION = """
|
||||||
hostnames:
|
hostnames:
|
||||||
description: A list of options that describe the ordering for which
|
description: A list of options that describe the ordering for which
|
||||||
hostnames should be assigned. Currently supported hostnames are
|
hostnames should be assigned. Currently supported hostnames are
|
||||||
'public_ip', 'private_ip', 'name' or 'labels.vm_name'.
|
'public_ip', 'private_ip', 'name', 'hostname' or 'labels.vm_name'.
|
||||||
default: ['public_ip', 'private_ip', 'name']
|
default: ['public_ip', 'private_ip', 'name']
|
||||||
type: list
|
type: list
|
||||||
elements: string
|
elements: string
|
||||||
|
@ -121,7 +121,7 @@ DOCUMENTATION = """
|
||||||
|
|
||||||
EXAMPLES = """
|
EXAMPLES = """
|
||||||
plugin: google.cloud.gcp_compute
|
plugin: google.cloud.gcp_compute
|
||||||
zones: # populate inventory with instances in these regions
|
zones: # populate inventory with instances in these zones
|
||||||
- us-east1-a
|
- us-east1-a
|
||||||
projects:
|
projects:
|
||||||
- gcp-prod-gke-100
|
- gcp-prod-gke-100
|
||||||
|
@ -248,6 +248,8 @@ class GcpInstance(object):
|
||||||
name = self._get_publicip()
|
name = self._get_publicip()
|
||||||
elif order == "private_ip":
|
elif order == "private_ip":
|
||||||
name = self._get_privateip()
|
name = self._get_privateip()
|
||||||
|
elif order == "hostname":
|
||||||
|
name = self.json.get("hostname", self.json["name"] + self.name_suffix)
|
||||||
elif order == "name":
|
elif order == "name":
|
||||||
name = self.json["name"] + self.name_suffix
|
name = self.json["name"] + self.name_suffix
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue