Hi.
I configured inventory according to the example [1]:

hostnames:
  - name
compose:
  ansible_host: networkInterfaces[0].accessConfigs[0].natIP

And the inventory correctly uses hostname. But to my experience, the 
`inventory_hostname` variable (which should be the primary variable for 
setting the hostname) still contains the IP address. As a result, using 
that var for setting hostname ends up with something like `192` as machine 
name.
I tried several `compose` combination, but I've read in the docs this is a 
readonly variable and as such it cannot be manually set.

The only method I found so far to have a usable `inventory_hostname` is to 
comment the `ansible_host` directive in the `compose` and set the hostname 
in /etc/hosts, in order to allow Ansible to connect. But this way I'm 
losing the benefit of using GCP inventory.
So I was wondering what am I doing wrong.
Thanks


[1] 
https://docs.ansible.com/ansible/latest/collections/google/cloud/gcp_compute_inventory.html#examples

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/b2bf1ba3-c7ee-4bd3-95d6-b83a1f2f7410n%40googlegroups.com.

Reply via email to