Skip to content

Commit

Permalink
Merge pull request #168 from Aveek-Saha/main
Browse files Browse the repository at this point in the history
feat: Add ability to restore etcd backup from s3 to a cluster with a different name
  • Loading branch information
MonolithProjects authored Nov 10, 2023
2 parents 41d613b + 8df97eb commit 000fc21
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions tasks/first_server.yml
Original file line number Diff line number Diff line change
Expand Up @@ -144,3 +144,22 @@
ansible.builtin.set_fact:
active_server: "{{ inventory_hostname }}"
run_once: true

- name: Get all nodes
ansible.builtin.shell: |
{{ rke2_data_path }}/bin/kubectl --kubeconfig /etc/rancher/rke2/rke2.yaml \
get nodes --no-headers | awk '{print $1}'
args:
executable: /bin/bash
changed_when: false
register: node_names

- name: Restore etcd - remove old nodes
ansible.builtin.shell: |
{{ rke2_data_path }}/bin/kubectl --kubeconfig /etc/rancher/rke2/rke2.yaml \
delete node {{ item }} 2>&1 || true
args:
executable: /bin/bash
with_items: "{{ node_names.stdout_lines | difference(groups[rke2_cluster_group_name]) }}"
changed_when: false
when: inventory_hostname != item and (do_etcd_restore is defined or do_etcd_restore_from_s3 is defined)

0 comments on commit 000fc21

Please sign in to comment.