-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathGCP_VM_Create.yml
More file actions
44 lines (43 loc) · 1.34 KB
/
GCP_VM_Create.yml
File metadata and controls
44 lines (43 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
---
- name: Create an VM instance
hosts: localhost
connection: local
gather_facts: no
vars:
gcp_project: ceenter
zone: "europe-west3-a"
region: "europe-west3"
tasks:
- name: create a disk
gcp_compute_disk:
name: "{{ vm_disk_name | default('ansible-tower-test-disk', true) }}"
size_gb: 50
source_image: 'projects/ubuntu-os-cloud/global/images/family/ubuntu-1604-lts'
zone: "{{ zone }}"
project: "{{ gcp_project }}"
state: present
register: disk
- name: create a address
gcp_compute_address:
name: "{{ vm_address_name | default('ansible-tower-test-address', true) }}"
region: "{{ region }}"
project: "{{ gcp_project }}"
state: present
register: address
- name: create a instance
gcp_compute_instance:
state: present
name: "{{ vm_name | default('ansible-tower-test', true) }}"
machine_type: n1-standard-1
disks:
- auto_delete: true
boot: true
source: "{{ disk }}"
network_interfaces:
- network: null # use default
access_configs:
- name: 'External NAT'
nat_ip: "{{ address }}"
type: 'ONE_TO_ONE_NAT'
zone: "{{ zone }}"
project: "{{ gcp_project }}"