mirror of
https://github.com/ansible-collections/google.cloud.git
synced 2025-07-24 13:50:30 -07:00
Add inventory hostname label support
This commit is contained in:
parent
65f0a7a141
commit
85e48b588b
1 changed files with 4 additions and 2 deletions
|
@ -45,7 +45,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', or 'name'.
|
'public_ip', 'private_ip', 'name' or 'labels.vm_name'.
|
||||||
default: ['public_ip', 'private_ip', 'name']
|
default: ['public_ip', 'private_ip', 'name']
|
||||||
type: list
|
type: list
|
||||||
auth_kind:
|
auth_kind:
|
||||||
|
@ -230,7 +230,9 @@ class GcpInstance(object):
|
||||||
"""
|
"""
|
||||||
for order in self.hostname_ordering:
|
for order in self.hostname_ordering:
|
||||||
name = None
|
name = None
|
||||||
if order == "public_ip":
|
if order.startswith("labels."):
|
||||||
|
name = self.json[u"labels"].get(order[7:])
|
||||||
|
elif order == "public_ip":
|
||||||
name = self._get_publicip()
|
name = self._get_publicip()
|
||||||
elif order == "private_ip":
|
elif order == "private_ip":
|
||||||
name = self._get_privateip()
|
name = self._get_privateip()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue