GCE module and private IP addresses

Hello,

I’d like to add a private IP address when creating google gce instances. Looking at the docs this doesn’t seem to be possible. http://docs.ansible.com/ansible/gce_module.html. I am using version 2.1 from the source at github cloned using git a few weeks ago.

If I use the gloud SDK I can create the instance

gcloud compute --project “my-project” instances create “bootstrap” --zone “europe-west1-d” --machine-type “f1-micro” --subnet “default-6f68d4d6fabcb680” --private-network-ip “10.132.0.2” --metadata “block-project-ssh-keys=true” --maintenance-policy “MIGRATE” --scopes default=“https://www.googleapis.com/auth/cloud-platform” --disk “name=docker-disk-for-instance-bootstrap,device-name=docker-disk-for-bootstrap,mode=rw,boot=no” --image “/centos-cloud/centos-7-v20160511” --boot-disk-size “10” --boot-disk-type “pd-standard” --boot-disk-device-name “bootstrap”

I need to create a few instances with static IP addresses because I’m trying to write an install script for DCOS on GCE and a number of the instances need a private static IP address.

Is there a way to add a private IP addresses to a google instance using the gce module or should I call the gcloud tool using the command module?

…sorry, not an answer to your ansible question, but in Google Cloud Platform you can use the instance name instead of an IP address and that will resolve to the instance, whatever its IP - so you may not need a static IP at all.

Follow us on:

Appsbroker Consulting Limited, Registered office: Appsbroker House, The Square, Swindon,

SN1 3EB, Company Number: 5702796, VAT Number: GB 876 3533 92, Company registered in England and Wales.

Hi Abdul,

It’s not currently supported but certainly something we could add. Mind raising an issue at ansible/ansible-modules-core so we can prioritize and get it added?

As for today, my feeling is that you could either gcloud command line tool, the uri module with the GCE API, or perhaps use new subnetwork support with a small subnetwork (This won’t give you control over the IP, but does keep it in Ansible; minimum subnetwork size is /29).

Thanks,

Tom

Are there any updates on this feature request? This is something that I need as well.

I don’t see that an issue was ever created, so I just submitted one here: https://github.com/ansible/ansible/issues/28736