-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathcreate-gc-vpc-by-name.yml
More file actions
42 lines (38 loc) · 1.15 KB
/
create-gc-vpc-by-name.yml
File metadata and controls
42 lines (38 loc) · 1.15 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
---
- name: Create a Google Cloud Virtual Private Cloud (VPC)
hosts: localhost
connection: local
gather_facts: false
tasks:
- name: Create a Virtual Private Cloud (VPC) network
google.cloud.gcp_compute_network:
name: "{{ vpc_name }}"
auto_create_subnetworks: 'false'
project: "{{ gcp_project }}"
auth_kind: serviceaccount
state: present
register: network
- name: Create a subnetwork
google.cloud.gcp_compute_subnetwork:
name: "{{ vpc_name }}-subnet"
region: "{{ gcp_region }}"
network: "{{ network }}"
ip_cidr_range: 172.16.0.0/16
project: "{{ gcp_project }}"
auth_kind: serviceaccount
state: present
register: vpcsubnet
- name: Create a firewall rule to allow SSH
google.cloud.gcp_compute_firewall:
name: "{{ vpc_name }}-allowssh"
allowed:
- ip_protocol: tcp
ports:
- '22'
- '80'
- '443'
project: "{{ gcp_project }}"
network: "{{ network }}"
auth_kind: serviceaccount
state: present
register: sshallowed