Creating GCE instances
Creating a virtual machine is the most basic building block of the GCE. A default network is created for us to boot the virtual machine in. However, in many cases, we would want to create a separate virtual network for the sake of isolation.
How to do it…
- Let us start by creating a network in the
us-west1
region where we will boot our instances:
- name: Create Custom Network gce_net: name: my-network mode: custom subnet_name: "public-subnet" subnet_region: us-west1 ipv4_range: '10.0.0.0/24' state: "present" service_account_email: "{{ service_account_email }}" project_id: "{{ project_id }}" credentials_file: "{{ credentials_file }}" tags: - recipe2
- Now we will get the static IP:
- name: create public ip gce_eip: name: app region: us-west1 state: present service_account_email: "{{ service_account_email }}" project_id: "{{ project_id }}" credentials_file: "{{ credentials_file }}" register: app_eip tags...