Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion plugins/inventory/gcp_compute.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@
hostnames:
description: A list of options that describe the ordering for which
hostnames should be assigned. Currently supported hostnames are
'public_ip', 'private_ip', 'name' or 'labels.vm_name'.
'public_ip', 'private_ip', 'name', 'labels.vm_name' or 'hostname'.
As 'hostname' may not be defined,
it will fallback on 'name'.
default: ['public_ip', 'private_ip', 'name']
type: list
auth_kind:
Expand Down Expand Up @@ -238,6 +240,9 @@ def hostname(self):
name = self._get_privateip()
elif order == "name":
name = self.json[u"name"]
elif order == "hostname":
# If hostname is not defined, then fallback on name
name = self.json[u"hostname"] if "hostname" in self.json else self.json[u"name"]
else:
raise AnsibleParserError("%s is not a valid hostname precedent" % order)

Expand Down