Hi All
my ansible version,
ansible --version
ansible 2.7.10
config file = /etc/ansible/ansible.cfg
configured module search path = [u’/root/.ansible/plugins/modules’, u’/usr/share/ansible/plugins/modules’]
ansible python module location = /usr/lib/python2.7/dist-packages/ansible
executable location = /usr/bin/ansible
python version = 2.7.15rc1 (default, Nov 12 2018, 14:31:15) [GCC 7.3.0]
How can I create a gce instance with already exists network and subnetwork, then assign a static internal and a static external ip address in to it,
I tried followed, success with creating instance with network and subnetwork, but can not add a static internal and a static external ip address
tasks:
-
name: Create a Regional external IP address
gce_eip:
name: test-ansi3-ext-ip
service_account_email: “{{ service_account_email }}”
credentials_file: “{{ credentials_file }}”
project_id: “{{ project_id }}”
region: “{{ region }}”
state: present
register: externalip -
name: Launch instances (“{{ instances }}”)
gce:
instance_names: “{{ instances }}”
machine_type: “{{ machine_type }}”
image: “{{ image }}”
service_account_email: “{{ service_account_email }}”
credentials_file: “{{ credentials_file }}”
project_id: “{{ project_id }}”
zone: asia-southeast1-b
disk_auto_delete: true
preemptible: true
network: pickme-stage-vpc
subnetwork: mgmt-sn
external_ip: ‘{{ externalip }}’
tags: ansible,allow-jenkins-fw-rule,allow-ssh-fw-rule,int-lb
register: gce -
name: Wait for SSH to come up (“{{ instances }}”)
wait_for: host={{ item.public_ip }} port=22 delay=10 timeout=60
with_items: “{{ gce.instance_data }}” -
name: Add host to groupname (“{{ instances }}”)
add_host: hostname={{ item.public_ip }} groupname=new_instances
with_items: “{{ gce.instance_data }}” -
name: Save host data (“{{ instances }}”)
add_host:
hostname: “{{ item.public_ip }}”
groupname: gce_instances
with_items: “{{ gce.instance_data }}”