-
Notifications
You must be signed in to change notification settings - Fork 44
Expand file tree
/
Copy pathcommon.yml
More file actions
452 lines (386 loc) · 15.8 KB
/
Copy pathcommon.yml
File metadata and controls
452 lines (386 loc) · 15.8 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
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
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
---
- name: General, NIC and CPU settings related tweaking
block:
- name: configure Scylla
shell: |
scylla_setup --no-raid-setup --no-ec2-check --no-kernel-check --no-ntp-setup --no-io-setup --no-node-exporter \
--no-coredump-setup --no-sysconfig-setup --no-swap-setup --no-cpuscaling-setup --no-fstrim-setup \
{% if skip_mem_setup is defined and skip_mem_setup|bool == True %} --no-memory-setup {% endif %}
- name: check if /etc/scylla.d/perftune.yaml exists
stat:
path: /etc/scylla.d/perftune.yaml
register: _perftune_conf_file
# Formally speaking scylla_sysconfig_setup configures values in scylla-server sysconfig file.
# By default, the block below is going to be executed only once for a new node. And this is exactly how we want it.
# To make the block below run again once can simply nuke perftune.yaml.
# If some custom configuration is set then the user should be knowledgable enough to configure scylla-server file
# correctly.
- name: configure sysconfig and generate (enforce!) an auto-selected cpuset.conf
shell: |
scylla_sysconfig_setup --set-clocksource --setup-nic-and-disks --nic {{ scylla_nic }}
when: skip_sysconfig is defined and skip_sysconfig|bool == false and _perftune_conf_file.stat.exists|bool == false
- name: overwrite an automatic cpuset.conf with an explicit value
shell: |
{{ cpuset_command }}
when: cpuset_command is defined and skip_cpuset is defined and skip_cpuset|bool == false
become: true
- name: Detect NVME disks
block:
- name: Get list of NVMEs with no mount points
shell: |
for nvme_disk in $(nvme list | awk '{print $1}' | tail -n +3)
do
{ echo -n "$nvme_disk "; lsblk -n "$nvme_disk" -o MOUNTPOINT | grep / | wc -l; } | awk '{if ($2=="0") print $1}'
done
register: _detected_nvmes
- set_fact:
scylla_raid_setup: "{{ _detected_nvmes.stdout_lines }}"
become: true
when: detect_nvmes|bool
- name: configure RAID via Scylla-setup
block:
- name: check for current raid
shell: |
lsblk | grep -w "/var/lib/scylla" | wc -l
register: present_scylla_disks
- name: run raid setup if there is no scylla mount yet
block:
- name: check if online-discard configuration is supported
shell: |
scylla_raid_setup --help
become: true
register: _scylla_raid_setup_help
- name: Explicitly set online discard option to {{ scylla_raid_online_discard }} if supported
set_fact:
_disable_online_discard: "--online-discard {{ scylla_raid_online_discard }}"
when: _scylla_raid_setup_help.stdout is search("--online-discard")
- name: "ansible-scylla-node: common.yml: Setting raid setup with disks"
debug:
msg: "Using the following disk devices: {{ scylla_raid_setup | join(',') }}"
- name: run raid setup if there is no scylla mount yet
shell: "scylla_raid_setup --disks {{ scylla_raid_setup | join(',') }} --update-fstab {{ _disable_online_discard }}"
become: true
when: scylla_raid_setup is defined and scylla_raid_setup|length > 0 and present_scylla_disks.stdout|int == 0
vars:
_disable_online_discard: ""
# Resulting map -> {'dc1': [node1, node2, node3], 'dc2': [node4, node5, node6]}
- name: Create a map from dc to its list of nodes
set_fact:
dc_to_node_list: "{{ dc_to_node_list | default({}) | combine( {hostvars[item]['dc']: (dc_to_node_list | default({}))[hostvars[item]['dc']] | default([]) + [item]} ) }}"
loop: "{{ groups['scylla'] }}"
run_once: true
when: scylla_io_probe_dc_aware|bool
- name: Collect IO settings for the first node of every DC
block:
- name: check for existing io_properties
stat:
path: /etc/scylla.d/io_properties.yaml
register: io_prop_stat
- name: Measure IO settings on one node
shell: |
scylla_io_setup
when: io_prop_stat.stat.exists|bool == False
- name: store /etc/scylla.d/io_properties.yaml
shell: |
cat /etc/scylla.d/io_properties.yaml
register: _io_properties
- set_fact:
io_properties: "{{ _io_properties.stdout | from_yaml }}"
- name: store /etc/scylla.d/io.conf
shell: |
cat /etc/scylla.d/io.conf
register: _io_conf
- set_fact:
io_conf: "{{ _io_conf.stdout_lines[0] }}"
when: io_properties is not defined and scylla_io_probe|bool == True and (scylla_io_probe_dc_aware|bool == False or dc_to_node_list[dc][0] == inventory_hostname)
become: true
- name: For every node, check if io.conf already exists and if it's not empty
block:
- stat:
path: /etc/scylla.d/io.conf
register: _io_conf_file
# During installation, scylla creates an io.conf filled only with comments and this file needs to be replaced
- name: Check if file is empty or filled only with comments
shell: "cat /etc/scylla.d/io.conf | grep -v ^#"
register: _io_conf_out
ignore_errors: true
when: _io_conf_file.stat.exists|bool
- name: Set io.conf
lineinfile:
path: /etc/scylla.d/io.conf
regexp: '^SEASTAR_IO='
line: "{% if scylla_io_probe|bool and scylla_io_probe_dc_aware|bool %}{{ hostvars[dc_to_node_list[dc][0]]['io_conf'] }}{% else %}{{ io_conf }}{% endif %}"
create: yes
become: true
when: io_conf is defined and (_io_conf_file.stat.exists|bool == false or _io_conf_out.stdout|length == 0 or always_replace_io_conf|bool)
- name: For every node, check if io_properties.yaml already exists
stat:
path: /etc/scylla.d/io_properties.yaml
register: _io_properties_file
- name: Set io_properties
template:
src: templates/io_properties.yaml.j2
dest: /etc/scylla.d/io_properties.yaml
owner: root
group: root
mode: '0644'
become: true
when: _io_properties_file.stat.exists|bool == false or always_replace_io_properties|bool
- name: Override SCYLLA_ARGS if requested
lineinfile:
path: /etc/default/scylla-server
regexp: '^SCYLLA_ARGS='
line: 'SCYLLA_ARGS="{{ scylla_args_value }}"'
create: yes
become: true
when: scylla_args_value is defined and scylla_args_value|length > 0
- name: configure NTP
shell: |
scylla_ntp_setup
become: true
when: skip_ntp is defined and skip_ntp|bool == false
- name: node exporter setup
shell: |
node_exporter_install --force
when: scylla_install_type == 'online'
become: true
notify:
- node_exporter start
ignore_errors: true
#TODO: stop ignoring errors when the node_exporter_install script fix is available in all actual versions, resp. use only for < 5.0 / 2022
- name: Re-populate package facts
package_facts:
manager: auto
- name: node exporter setup from 5.0/2022
block:
- name: Start scylla-node-exporter service
service:
name: scylla-node-exporter
state: started
enabled: yes
register: _scylla_node_exporter_status
- name: Set custom scylla-node-exporter service configuration
block:
- name: Get {{ scylla_package_prefix }}-node-exporter environment configuration file name
set_fact:
# 'EnvironmentFiles' has the following format: '<file name> (ignore_errors=[yes|no])'
_scylla_node_exporter_env_config_file: "{{ _scylla_node_exporter_status.status.EnvironmentFiles.split(' ')[0] }}"
- name: Set a custom configuration in {{ _scylla_node_exporter_env_config_file | default('a scylla-node-exporter configuration file') }}
template:
src: templates/scylla-node-exporter.j2
dest: "{{ _scylla_node_exporter_env_config_file }}"
owner: root
group: root
mode: '0644'
- name: Restart scylla-node-exporter service
service:
name: scylla-node-exporter
state: restarted
enabled: yes
when: scylla_node_exporter_params is defined
when: (scylla_package_prefix + '-node-exporter') in ansible_facts.packages
become: true
- name: enable ssl options
include_tasks: ssl.yml
when: ssl_internode_enabled|bool or ssl_client_enabled|bool
- name: configure scylla.yaml
template:
src: templates/scylla.yaml.j2
dest: /etc/scylla/scylla.yaml
owner: root
group: root
mode: '0644'
become: true
- name: configure cassandra-rackdc.properties
template:
src: templates/cassandra-rackdc.properties.j2
dest: /etc/scylla/cassandra-rackdc.properties
owner: root
group: root
mode: '0644'
become: true
when: scylla_snitch != 'SimpleSnitch' and scylla_snitch != 'RackInferringSnitch'
- name: finalize Scylla node configuration
block:
- name: check for scylla_bootparam_setup
stat:
path: /usr/sbin/scylla_bootparam_setup
register: scylla_bootparam_setup
- name: run bootparam setup
shell: |
scylla_bootparam_setup
when: scylla_bootparam_setup.stat.exists
- name: set up coredump
shell: |
scylla_coredump_setup --dump-to-raiddir
when: skip_coredump is defined and skip_coredump|bool == false
- name: set up swap
shell: |
scylla_swap_setup{% if swap_file_size_mb is defined and swap_file_size_mb|int > 0 %} --swap-size {{ [swap_file_size_mb|int, 1024]|max // 1024 }} {% endif %}
register: swap_setup
failed_when:
- swap_setup.rc > 0
- '"swap already configured, exiting setup" not in swap_setup.stdout'
when: skip_swap is defined and skip_swap|bool == false
- name: configure cpu scaling
shell: |
scylla_cpuscaling_setup
- name: configure fstrim
shell: |
scylla_fstrim_setup
notify: Enable and start 'scylla-fstrim.timer' service
become: true
- name: set devmode command
set_fact:
devmode_command: "scylla_dev_mode_setup --developer-mode 1"
- name: run devmode
shell: |
{{ devmode_command }}
become: true
when: (devmode is defined) and (devmode|bool)
- name: configure custom scylla.yaml paramaters
lineinfile:
path: /etc/scylla/scylla.yaml
regexp: '^{{ item.key }}'
line: "{{ item.key }}: {{ item.value }}"
create: yes
become: true
loop: "{{ lookup('dict', scylla_yaml_params) }}"
- name: Copy system and table keys
include_tasks: copy_system_and_table_keys.yml
# scylla_listen_address is a composite indirect value that depends on another per-host value - scylla_nic.
# Therefore in order to be able to get the corresponding value via hostvars[item] later in the play we need to
# have an actual value resolved.
# One way to do that is to resolve it and store as an Ansible fact.
- name: Resolve a scylla_listen_address as a fact
set_fact:
listen_address: "{{ scylla_listen_address }}"
# The same relates to the below
- name: Resolve scylla_rpc_address
set_fact:
rpc_address: "{{ scylla_rpc_address }}"
# The same relates to the below
- name: Resolve scylla_broadcast_address
set_fact:
broadcast_address: "{{ scylla_broadcast_address }}"
- name: start_scylla_service dependent tasks
block:
- name: Generate tokens for the new nodes
run_once: true
include_tasks: generate_tokens.yml
when: token_distributor is defined
- name: Start seeders serially
run_once: true
include_tasks: start_one_node.yml
vars:
node: "{{ item }}"
loop: "{{ groups['scylla'] }}"
when: hostvars[item]['broadcast_address'] in scylla_seeds or item in scylla_seeds
- name: Start scylla non-seeds nodes serially
run_once: true
include_tasks: start_one_node.yml
vars:
node: "{{ item }}"
loop: "{{ groups['scylla'] }}"
when:
- item not in scylla_seeds
- hostvars[item]['broadcast_address'] not in scylla_seeds
- name: wait for the API port to come up on all nodes
wait_for:
port: "{{ scylla_api_port }}"
host: "{{ scylla_api_address }}"
timeout: 600
- name: wait for the cluster to become healthy
shell: |
nodetool status|grep -E '^UN|^UJ|^DN'|wc -l
register: node_count
until: node_count.stdout|int == ansible_play_batch|length
retries: "{{ scylla_bootstrap_wait_time_sec|int }}"
delay: 1
when: full_inventory|bool
- name: check API access
uri:
url: "http://{{ scylla_api_address }}:{{ scylla_api_port }}/failure_detector/endpoints/"
follow_redirects: none
method: GET
register: _result
until: _result.status == 200
retries: 90
delay: 1
- name: Delete initial_token in scylla.yaml
lineinfile:
path: /etc/scylla/scylla.yaml
regexp: '^initial_token:'
line: ""
become: true
when: token_distributor is defined
when: start_scylla_service is defined and start_scylla_service|bool
- name: Copy system and table keys
include_tasks: copy_system_and_table_keys.yml
- name: Check if authentication and audit are enabled
block:
- command: cat /etc/scylla/scylla.yaml
ignore_errors: true
register: _scylla_yaml_out
- set_fact:
_scylla_yaml_map: "{{ _scylla_yaml_out.stdout | from_yaml }}"
- set_fact:
_authentication_enabled: |
{% if (_scylla_yaml_map.authenticator is defined and (_scylla_yaml_map.authenticator == 'TransitionalAuthenticator' or _scylla_yaml_map.authenticator == 'PasswordAuthenticator')) or
(_scylla_yaml_map.authorizer is defined and (_scylla_yaml_map.authorizer == 'TransitionalAuthorizer' or _scylla_yaml_map.authorizer == 'CassandraAuthorizer')) %}True{% else %}False{% endif %}
_audit_enabled: |
{% if (_scylla_yaml_map.audit is defined and _scylla_yaml_map.audit == 'table') %}True{% else %}False{% endif %}
run_once: true
- name: Adjust replication for system_auth keyspace
include_tasks: adjust_keyspace_replication.yml
vars:
_keyspace: "system_auth"
_keyspace_replication_strategy: "{{ system_auth_replication_strategy }}"
_keyspace_rf: "{{ system_auth_rf }}"
when:
- start_scylla_service|bool
- adjust_system_auth_replication is defined and adjust_system_auth_replication|bool
- _authentication_enabled is defined and _authentication_enabled|bool
- system_auth_rf is defined and system_auth_replication_strategy is defined
- name: Adjust replication for audit keyspace
include_tasks: adjust_keyspace_replication.yml
vars:
_keyspace: "audit"
_keyspace_replication_strategy: "{{ audit_replication_strategy }}"
_keyspace_rf: "{{ audit_rf }}"
when:
- start_scylla_service|bool
- adjust_audit_replication is defined and adjust_audit_replication|bool
- _audit_enabled is defined and _audit_enabled|bool
- audit_rf is defined and audit_replication_strategy is defined
- name: Adjust replication for system_distributed keyspace
include_tasks: adjust_keyspace_replication.yml
vars:
_keyspace: "system_distributed"
_keyspace_replication_strategy: "{{ system_distributed_replication_strategy }}"
_keyspace_rf: "{{ system_distributed_rf }}"
when:
- start_scylla_service|bool
- adjust_system_distributed_replication is defined and adjust_system_distributed_replication|bool
- system_distributed_rf is defined and system_distributed_replication_strategy is defined
- name: Adjust replication for system_traces keyspace
include_tasks: adjust_keyspace_replication.yml
vars:
_keyspace: "system_traces"
_keyspace_replication_strategy: "{{ system_traces_replication_strategy }}"
_keyspace_rf: "{{ system_traces_rf }}"
when:
- start_scylla_service|bool
- adjust_system_traces_replication is defined and adjust_system_traces_replication|bool
- system_traces_rf is defined and system_traces_replication_strategy is defined
- name: configure the Manager agents
include_tasks: manager_agents.yml
when: scylla_manager_enabled|bool
- name: Update sysctl
ansible.posix.sysctl:
name: "{{ item.name }}"
value: "{{ item.value }}"
become: true
loop: "{{ sysctl }}"
ignore_errors: true
when: update_sysctl|bool is defined and update_sysctl|bool