-
Notifications
You must be signed in to change notification settings - Fork 2
/
gcp-ansible-create-instance.yml
60 lines (57 loc) · 1.76 KB
/
gcp-ansible-create-instance.yml
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
---
- name: Create GCP resources and then create a GCP instance
hosts: localhost
connection: local
gather_facts: false
tasks:
- name: Create a disk mapped from a RHEL-9 image
google.cloud.gcp_compute_disk:
name: disk-instance
size_gb: 50
source_image: "projects/rhel-cloud/global/images/rhel-9-v20221102"
zone: "{{ gcp_zone }}"
project: "{{ gcp_project }}"
auth_kind: serviceaccount
state: present
register: disk
- name: Create a Google Virtual Private Cloud (VPC) network
google.cloud.gcp_compute_network:
name: network-instance
auto_create_subnetworks: 'true'
project: "{{ gcp_project }}"
auth_kind: serviceaccount
state: present
register: network
- name: create an IPv4 public IP address
google.cloud.gcp_compute_address:
name: ipaddress-instance
region: "{{ gcp_region }}"
project: "{{ gcp_project }}"
auth_kind: serviceaccount
state: present
register: ipaddress
- name: create a VM instance
google.cloud.gcp_compute_instance:
name: rhel-9-vm
machine_type: n1-standard-1
disks:
- auto_delete: 'true'
boot: 'true'
source: "{{ disk }}"
- auto_delete: 'true'
interface: NVME
type: SCRATCH
initialize_params:
disk_type: local-ssd
labels:
environment: production
network_interfaces:
- network: "{{ network }}"
access_configs:
- name: External NAT
nat_ip: "{{ ipaddress }}"
type: ONE_TO_ONE_NAT
zone: "{{ gcp_zone }}"
project: "{{ gcp_project }}"
auth_kind: serviceaccount
state: present