-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathelasticsearch.yml
216 lines (200 loc) · 6.16 KB
/
elasticsearch.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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
---
- name: Create elastics0er instances
hosts: localhost
gather_facts: False
vars_files:
- gce_vars/auth
- gce_vars/machines
- gce_vars/zone
tasks:
- name: create a disk mapped for elasticsearch App instance 1 - Centos 8
gcp_compute_disk:
name: elastics01-disk-instance1
size_gb: 50
type: pd-ssd
source_image: "{{ image }}"
zone: "{{ zone.za }}"
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
state: present
register: elastics01_disk_instance1
- name: create a disk mapped for elasticsearch02 App instance 2 - Centos 8
gcp_compute_disk:
name: elastics02-disk-instance2
size_gb: 50
type: pd-ssd
source_image: "{{ image }}"
zone: "{{ zone.za }}"
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
state: present
register: elastics02_disk_instance2
- name: create a disk mapped for elasticsearch03 App instance 3 - Centos 8
gcp_compute_disk:
name: elastics03-disk-instance3
size_gb: 50
type: pd-ssd
source_image: "{{ image }}"
zone: "{{ zone.za }}"
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
state: present
register: elastics03_disk_instance3
- name: create a VPC stockcheck 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 elasticseacrh app
gcp_compute_firewall:
name: elastics-fw-ports
network: "{{ network }}"
allowed:
- ip_protocol: icmp
- ip_protocol: tcp
ports:
- '22'
- '80'
- '443'
- '9200-9400'
target_tags:
- elasticsearch
source_tags:
- management
- elasticsearch
- greeneagle
- redis
- shoplauncher
- stockcheck
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
state: present
register: firewall
- name: create the elastics01 app instance 1
gcp_compute_instance:
name: "{{ es_zonea }}"
machine_type: "{{ machine_type.elastics }}"
disks:
- index: 0
auto_delete: 'no'
boot: 'true'
source: "{{ elastics01_disk_instance1 }}"
labels:
environment: elasticsprod
network_interfaces:
- network: "{{ network }}"
tags:
items:
- elasticsearch
metadata:
ssh_user: "{{ ssh_user }}"
ssh_key: "{{ ssh_key }}"
zone: "{{ zone.za }}"
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
state: present
register: elastics01
- name: create the elastics02 instance 2
gcp_compute_instance:
name: "{{ es_zoneb }}"
machine_type: "{{ machine_type.elastics }}"
disks:
- index: 0
auto_delete: 'no'
boot: 'true'
source: "{{ elastics02_disk_instance2 }}"
network_interfaces:
- network: "{{ network }}"
tags:
items:
- elasticsearch
metadata:
ssh_user: "{{ ssh_user }}"
ssh_key: "{{ ssh_key }}"
zone: "{{ zone.za }}"
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
state: present
register: elastics02
- name: create the elastics03 instance 3
gcp_compute_instance:
name: "{{ es_zonec }}"
machine_type: "{{ machine_type.elastics }}"
disks:
- index: 0
auto_delete: 'no'
boot: 'true'
source: "{{ elastics03_disk_instance3 }}"
network_interfaces:
- network: "{{ network }}"
tags:
items:
- elasticsearch
metadata:
ssh_user: "{{ ssh_user }}"
ssh_key: "{{ ssh_key }}"
zone: "{{ zone.za }}"
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
state: present
register: elastics03
- debug: var=elastics01
- debug: var=elastics02
- debug: var=elastics03
- debug: var=elastics01.networkInterfaces[0].networkIP
- debug: var=elastics02.networkInterfaces[0].networkIP
- debug: var=elastics03.networkInterfaces[0].networkIP
- name: Add elastics01 to group elastics
add_host:
name: "{{ elastics01.networkInterfaces[0].networkIP }}"
groups: elastics
- name: Add elastics02 to group elastics
add_host:
name: "{{ elastics02.networkInterfaces[0].networkIP }}"
groups: elastics
- name: Add elastics03 to group elastics
add_host:
name: "{{ elastics03.networkInterfaces[0].networkIP }}"
groups: elastics
post_tasks:
- name: Wait for SSH for elastics01
wait_for:
delay: 30
host: "{{ elastics01.networkInterfaces[0].networkIP }}"
port: 22
state: started
timeout: 120
- name: Wait for SSH for elastics02
wait_for:
delay: 30
host: "{{ elastics02.networkInterfaces[0].networkIP }}"
port: 22
state: started
timeout: 120
- name: Wait for SSH for elastics03
wait_for:
delay: 30
host: "{{ elastics03.networkInterfaces[0].networkIP }}"
port: 22
state: started
timeout: 120
- hosts: elastics
roles:
- apache
- elasticsinstall
gather_facts: true
become: true
vars:
ansible_user: belloau
ansible_ssh_private_key_file: ~/.ssh/id_rsa.pub