Skip to content

Commit

Permalink
replace_node.yml: Allow replacing an alive node
Browse files Browse the repository at this point in the history
This patch changes the replace_node playbook to allow the replace
of an alive node by adding a variable named `alive_node_replace`,
which when set to true will stop the node being replaced
before starting the replace.
  • Loading branch information
igorribeiroduarte authored and vladzcloudius committed Dec 15, 2023
1 parent 2488371 commit 17a136d
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
40 changes: 40 additions & 0 deletions example-playbooks/replace_node/replace_node.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,46 @@
when: hostvars[new_node]['broadcast_address'] in scylla_seeds or new_node in scylla_seeds
run_once: true

- name: Stop scylla-server on the node being replaced
block:
- name: Disable Scylla service
service:
name: scylla-server
enabled: false
become: true

- name: Run nodetool drain
async_task:
shell: |
nodetool drain
alias: drain_scylla
async: 60
retries: 60
delay: 1
ignore_errors: true
register: _drain_scylla_output

- name: Stop Scylla service
async_task:
shell: |
systemctl stop scylla-server
alias: stop_scylla
async: 5
retries: 5
delay: 1
ignore_errors: true
register: _stop_scylla_output
become: true

- name: Send SIGKILL to scylla
shell: |
pkill -9 scylla$
ignore_errors: true
become: true
delegate_to: "{{ replaced_node }}"
run_once: true
when: alive_node_replace is defined and alive_node_replace|bool

- name: Save one of the seeds as a fact in order to run some checks
set_fact:
alive_node: "{{ item }}"
Expand Down
4 changes: 4 additions & 0 deletions example-playbooks/replace_node/vars/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ new_node_repair_timeout_seconds: 36000
# Default bootstrap timeout for the new node
new_node_bootstrap_wait_time_sec: 25200

# If you set this to true, this playbook will allow you to replace an alive node
# by draining/stopping the node being replaced before starting the replace
alive_node_replace: false

alive_nodes_listen_address: "{{ vars['ansible_'~scylla_nic].ipv4.address }}"
alive_nodes_broadcast_address: "{{ vars['ansible_'~scylla_nic].ipv4.address }}"

Expand Down

0 comments on commit 17a136d

Please sign in to comment.