-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmanagement.yml
155 lines (144 loc) · 4 KB
/
management.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
- name: Create Master instances
hosts: localhost
gather_facts: False
vars_files:
- gce_vars/auth
- gce_vars/machines
- gce_vars/zone
tasks:
- name: create a disk mapped for Management Node - Centos 8
gcp_compute_disk:
name: master-disk-instance
size_gb: 100
type: pd-ssd
source_image: "{{ image }}"
zone: "{{ zone.za }}"
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
state: present
register: disk
- name: create a data disk for Management Node - Centos 8
gcp_compute_disk:
name: master-disk-data
size_gb: 100
zone: "{{ zone.za }}"
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
state: present
register: disk_data
- name: create a VPC network
gcp_compute_network:
name: stockchecker-subnetwork
auto_create_subnetworks: 'true'
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
state: present
register: network
- name: create a firewall rules for VPC
gcp_compute_firewall:
name: stockchecker-fw-ports
network: "{{ network }}"
allowed:
- ip_protocol: icmp
- ip_protocol: tcp
ports:
- '22'
- '80'
- '443'
target_tags:
- management
source_tags:
- stockcheck
- greeneagle
- redis
- elasticsearch
source_ranges:
- '0.0.0.0/0'
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
state: present
register: firewall
- name: create an IPv4 public IP Address
gcp_compute_address:
name: master-instance
region: "{{ region }}"
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
state: present
register: address
- name: create the Management instance
gcp_compute_instance:
name: master
machine_type: "{{ machine_type }}"
deletion_protection: yes
disks:
- index: 0
auto_delete: 'no'
boot: 'true'
source: "{{ disk }}"
- index: 1
auto_delete: 'no'
source: "{{ disk_data }}"
type: PERSISTENT
initialize_params:
disk_type: pd-ssd
labels:
environment: production
network_interfaces:
- network: "{{ network }}"
access_configs:
- name: External NAT
nat_ip: "{{ address }}"
type: ONE_TO_ONE_NAT
tags:
items:
- management
- stockcheck
- greenseagel
- redis
- elasticsearch
metadata:
ssh_user: "{{ ssh_user }}"
ssh_key: "{{ ssh_key }}"
zone: "{{ zone.za }}"
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
state: present
register: instance
- name: Show Management Instance Details
debug:
msg: "The Master instance is accessible at {{ address.address }}"
- name: Add master to group master
add_host:
name: "{{ address.address }}"
groups: master
post_tasks:
- name: Wait for SSH for instance Master in first zone
wait_for:
delay: 30
host: "{{ address.address }}"
port: 22
state: started
timeout: 120
- hosts: master
roles:
- systemtools
- apache
gather_facts: False
become: true
vars:
ansible_user: belloau
ansible_ssh_private_key_file: ~/.ssh/id_rsa.pub
tasks:
- name: Adding copying pub keys
copy:
src: keys/id_rsa.pub
dest: /home/belloau/.ssh/
mode: '0600'
- name: Copying priv-keys
copy:
src: keys/id_rsa
dest: /home/belloau/.ssh/
mode: '0600'