-
Notifications
You must be signed in to change notification settings - Fork 33
/
Copy pathviya-services-stop.yml
279 lines (244 loc) · 9.39 KB
/
viya-services-stop.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
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
####################################################################
#### viya-services-stop.yml ####
####################################################################
#### Author: SAS Institute Inc. ####
####################################################################
#
# Copyright (c) 2019-2022, SAS Institute Inc., Cary, NC, USA. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0
#
---
- hosts: localhost
gather_facts: false
vars_files:
- viya-services-vars.yml
tasks:
- name: "WARNING: All Viya services are about to be stopped!"
pause:
seconds: "{{stop_pause_timer}}"
prompt: "Press 'ctl+c' to interrupt the process. If no response, playbook will continue after {{stop_pause_timer}} seconds"
when: not ansible_check_mode and enable_pause_timer|bool == true
- import_playbook: ../common/handle_hostgroup_hyphens.yml
tags:
- always
- hosts: sas_all
become: yes
become_user: root
gather_facts: false
any_errors_fatal: true
vars_files:
- viya-services-vars.yml
tasks:
- name: Check any SAS process running
script: viya-svs.sh checkps 1
register: psflag
check_mode: no
changed_when: false
- set_fact:
deployhostnum: "{{groups['sas_all'] | length }}"
check_mode: no
- hosts: sas_all
become: yes
become_user: root
gather_facts: false
any_errors_fatal: true
vars_files:
- viya-services-vars.yml
tasks:
- block:
- name: Stop SAS multi-tenant services
script: viya-svs.sh stopmt
- name: Stop SAS microservices
script: viya-svs.sh stopms
any_errors_fatal: true
when: psflag.stdout != "" and not ansible_check_mode and enable_svs_alternative|bool != true
- name: Stop SAS all services using alternative script
script: viya-svs-alternative.sh 1 stop
when: psflag.stdout != "" and not ansible_check_mode and enable_svs_alternative|bool == true
- hosts: httpproxy
become: yes
become_user: root
gather_facts: false
any_errors_fatal: true
tasks:
- name: Stop SAS HTTP proxy service
script: viya-svs.sh stop sas-viya-httpproxy-default
when: psflag.stdout != ""
- hosts: sas_casserver_primary
become: yes
become_user: root
gather_facts: false
any_errors_fatal: true
tasks:
- name: Stop SAS CAS server
script: viya-svs.sh stopcas
when: psflag.stdout != ""
- hosts: CoreServices
become: yes
become_user: root
gather_facts: false
any_errors_fatal: true
vars_files:
- viya-services-vars.yml
tasks:
- name: Stop cachelocator/cacheserver
script: viya-svs.sh stop sas-viya-cachelocator-default sas-viya-cacheserver-default
when: enable_svs_alternative|bool == true
- hosts: rabbitmq
become: yes
become_user: root
gather_facts: false
any_errors_fatal: true
tasks:
- name: Stop SAS Message Broker RabbitMQ
any_errors_fatal: true
script: viya-svs.sh stop sas-viya-rabbitmq-server-default
when: psflag.stdout != ""
- hosts: sas_all
become: yes
become_user: root
gather_facts: false
any_errors_fatal: true
vars_files:
- ../../../vars.yml
tasks:
- block:
- name: Stop SAS Infrastructure Data Server pgpool
include_tasks: viya-db.yml
vars:
dbname: "{{INVOCATION_VARIABLES[inventory_hostname]['pgpoolc'][0]['SERVICE_NAME']|default([])}}"
dbaction: "stopdb"
dbnum: "{{INVOCATION_VARIABLES[inventory_hostname]['pgpoolc'][0]['POOL_NUMBER']|default([])}}"
dbtype: pgpool
when: INVOCATION_VARIABLES[inventory_hostname]['pgpoolc'] is defined
- name: Stop SAS Infrastructure Data Server node
include_tasks: viya-db.yml
vars:
dbname: "{{INVOCATION_VARIABLES[inventory_hostname]['sasdatasvrc'][0]['SERVICE_NAME']|default([])}}"
dbaction: "stopdb"
dbnum: "{{INVOCATION_VARIABLES[inventory_hostname]['sasdatasvrc'][0]['NODE_NUMBER']|default([])}}"
dbtype: node
when: INVOCATION_VARIABLES[inventory_hostname]['sasdatasvrc'] is defined
- name: Stop SAS Infrastructure Data Server Consul Template pgpool
include_tasks: viya-dbct.yml
vars:
dbname: "{{INVOCATION_VARIABLES[inventory_hostname]['pgpoolc'][0]['SERVICE_NAME']|default([])}}"
dbaction: stopdbct
dbtype: pgpool
when: INVOCATION_VARIABLES[inventory_hostname]['pgpoolc'] is defined and INVOCATION_VARIABLES[inventory_hostname]['pgpoolc'][0]['HA_PGPOOL_VIRTUAL_IP'] is defined
- name: Stop SAS Infrastructure Data Server Consul Template node
include_tasks: viya-dbct.yml
vars:
dbname: "{{INVOCATION_VARIABLES[inventory_hostname]['sasdatasvrc'][0]['SERVICE_NAME']|default([])}}"
dbaction: stopdbct
dbtype: node
when: INVOCATION_VARIABLES[inventory_hostname]['sasdatasvrc'] is defined
- name: Stop SAS Infrastructure Data Server pgpool
include_tasks: viya-db.yml
vars:
dbname: "{{INVOCATION_VARIABLES[inventory_hostname]['cpspgpoolc'][0]['SERVICE_NAME']|default([])}}"
dbaction: "stopdb"
dbnum: "{{INVOCATION_VARIABLES[inventory_hostname]['cpspgpoolc'][0]['POOL_NUMBER']|default([])}}"
dbtype: pgpool
when: INVOCATION_VARIABLES[inventory_hostname]['cpspgpoolc'] is defined
- name: Stop SAS Infrastructure Data Server node
include_tasks: viya-db.yml
vars:
dbname: "{{INVOCATION_VARIABLES[inventory_hostname]['cpsdatasvrc'][0]['SERVICE_NAME']|default([])}}"
dbaction: "stopdb"
dbnum: "{{INVOCATION_VARIABLES[inventory_hostname]['cpsdatasvrc'][0]['NODE_NUMBER']|default([])}}"
dbtype: node
when: INVOCATION_VARIABLES[inventory_hostname]['cpsdatasvrc'] is defined
- name: Stop SAS Infrastructure Data Server Consul Template pgpool
include_tasks: viya-dbct.yml
vars:
dbname: "{{INVOCATION_VARIABLES[inventory_hostname]['cpspgpoolc'][0]['SERVICE_NAME']|default([])}}"
dbaction: stopdbct
dbtype: pgpool
when: INVOCATION_VARIABLES[inventory_hostname]['cpspgpoolc'] is defined and INVOCATION_VARIABLES[inventory_hostname]['cpspgpoolc'][0]['HA_PGPOOL_VIRTUAL_IP'] is defined
- name: Stop SAS Infrastructure Data Server Consul Template node
include_tasks: viya-dbct.yml
vars:
dbname: "{{INVOCATION_VARIABLES[inventory_hostname]['cpsdatasvrc'][0]['SERVICE_NAME']|default([])}}"
dbaction: stopdbct
dbtype: node
when: INVOCATION_VARIABLES[inventory_hostname]['cpsdatasvrc'] is defined
when: psflag.stdout != "" and INVOCATION_VARIABLES[inventory_hostname] is defined
- hosts: sas_all:!consul
become: yes
become_user: root
gather_facts: false
any_errors_fatal: true
vars_files:
- viya-services-vars.yml
tasks:
- name: Stop SAS Configuration consul Agent(s)
any_errors_fatal: true
script: viya-svs.sh stop sas-viya-consul-default {{consul_retry_count}}
when: psflag.stdout != ""
- hosts: consul
become: yes
become_user: root
gather_facts: false
any_errors_fatal: true
vars_files:
- viya-services-vars.yml
tasks:
- name: Stop SAS Secret Manager - vault
any_errors_fatal: true
script: viya-svs.sh stop sas-viya-vault-default
when: psflag.stdout != ""
- name: Stop SAS Configuration consul Server(s)
any_errors_fatal: true
script: viya-svs.sh stop sas-viya-consul-default {{consul_retry_count}}
when: psflag.stdout != ""
- hosts: ComputeServer
become: yes
become_user: root
gather_facts: false
any_errors_fatal: true
tasks:
- name: Clean up SAS compsrv child processes
script: viya-svs.sh cleancomp
when: not ansible_check_mode
- hosts: sas_all
become: yes
become_user: root
gather_facts: false
any_errors_fatal: true
vars_files:
- viya-services-vars.yml
tasks:
- name: Display SAS processes information
debug: msg="No Viya process running"
when: psflag.stdout == ""
check_mode: no
- block:
- name: Capture SAS stray processes
script: "viya-svs.sh checkps {{stray_process_count}}"
register: stray_processes
changed_when: false
check_mode: no
- name: Display SAS stray processes
debug:
msg:
- "Please examine the following stray process(es)"
- "If enable_stray_cleanup=true, process will be cleaned up automatically"
- "except database processes which require fix manually to avoid data corruption."
- "This playbook can be rerun to clean up the child processes."
- "{{stray_processes.stdout_lines}}"
failed_when: stray_processes.stdout != '' and not ansible_check_mode
when: (stray_processes.stdout != '') and (enable_stray_cleanup|bool != true)
- name: Clean up SAS stray processes if enabled
script: viya-svs.sh cleanps "{{stray_processes.stdout_lines}}"
when: (enable_stray_cleanup|bool == true) and (stray_processes.stdout != '')
check_mode: no
any_errors_fatal: true
- name: Display SAS cleanup stray processes
debug:
msg:
- "The following stray processes have been cleaned up"
- "{{stray_processes.stdout_lines}}"
check_mode: no
when: (stray_processes.stdout != '') and (enable_stray_cleanup|bool == true)
when: psflag.stdout != ""