I am trying to create a new instance in google compute engine with a reserved external IP address.
Since ansible doesn’t have a module to reserve static IP, I have used gcloud command to do that and then use gce module to create a new instance
Ensure that network and subnet with desired IP range exists
GCE_INI_PATH=inventory/gce.ini ansible all -i inventory/localhost -m gce_net -a “project_id=myproject name=ansiblenet mode=custom ipv4_range=‘172.16.0.0/16’ subnet_name=dev subnet_region=asia-east1 subnet_desc=‘Development area’ state=present” -v
Allow ssh access from outside
GCE_INI_PATH=inventory/gce.ini ansible all -i inventory/localhost -m gce_net -a “project_id=myproject name=ansiblenet mode=custom ipv4_range=‘172.16.0.0/16’ subnet_name=dev subnet_region=asia-east1 subnet_desc=‘Development area’ state=present fwname=allowssh src_range=‘0.0.0.0/0’ allowed=‘tcp:22’” -v
Reserve an IP address
gcloud compute addresses create testing --region=asia-east1
Provision a new instance with reserved IP address
GCE_INI_PATH=inventory/gce.ini ansible all -i inventory/localhost -m gce -a “project_id=myproject name=trial metadata={‘Name’:‘trial’,‘Environment’:‘Development’} machine_type=f1-micro image=debian-8 external_ip=testing tags=‘dev,trial’ network=ansiblenet subnetwork=dev zone=asia-east1-a state=present” -v
The new instance is created but with an ephermal IP address. I tried replacing the name of the external IP with the actual IP address but it still fails to work.
GCE_INI_PATH=inventory/gce.ini ansible all -i inventory/localhost -m gce -a “project_id=myproject name=trial metadata={‘Name’:‘trial’,‘Environment’:‘Development’} machine_type=f1-micro image=debian-8 external_ip=‘104.199.231.152’ tags=‘dev,trial’ network=ansiblenet subnetwork=dev zone=asia-east1-a state=present” -vvvv
I couldn’t find anything in the documentation which could point me to the issue. Am I doing something wrong or is there a bug in the module?