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?
--
With Regards,
Mehul Ved
--
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 post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/CADTL0ob3%3DPxCqGLVkehnP8L8OTWyrLuOMak72LNU6ZnTLKGCKQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.