Update documentation for gcp_compute (#43791)
Added examples on how to use "keyed_groups", "hostnames", and "compose" The compose example shows how to set the ansible_host var for a host to either the public or private ip. This is necessary when you set your hostname by name instead of ip
This commit is contained in:
parent
86341f7520
commit
9a1191cbe5
1 changed files with 11 additions and 1 deletions
|
@ -60,11 +60,21 @@ projects:
|
||||||
filters:
|
filters:
|
||||||
- machineType = n1-standard-1
|
- machineType = n1-standard-1
|
||||||
- scheduling.automaticRestart = true AND machineType = n1-standard-1
|
- scheduling.automaticRestart = true AND machineType = n1-standard-1
|
||||||
|
|
||||||
scopes:
|
scopes:
|
||||||
- https://www.googleapis.com/auth/compute
|
- https://www.googleapis.com/auth/compute
|
||||||
service_account_file: /tmp/service_account.json
|
service_account_file: /tmp/service_account.json
|
||||||
auth_kind: serviceaccount
|
auth_kind: serviceaccount
|
||||||
|
keyed_groups:
|
||||||
|
# Create groups from GCE labels
|
||||||
|
- prefix: gcp
|
||||||
|
key: labels
|
||||||
|
hostnames:
|
||||||
|
# List host by name instead of the default public ip
|
||||||
|
- name
|
||||||
|
compose:
|
||||||
|
# Set an inventory parameter to use the Public IP address to connect to the host
|
||||||
|
# For Private ip use "networkInterfaces[0].networkIP"
|
||||||
|
ansible_host: networkInterfaces[0].accessConfigs[0].natIP
|
||||||
'''
|
'''
|
||||||
|
|
||||||
from ansible.errors import AnsibleError, AnsibleParserError
|
from ansible.errors import AnsibleError, AnsibleParserError
|
||||||
|
|
Loading…
Reference in a new issue