Page MenuHomePhorge

reinstall-k3s.yaml
No OneTemporary

Authored By
Unknown
Size
2 KB
Referenced Files
None
Subscribers
None

reinstall-k3s.yaml

---
- name: Configure KVM
hosts: infrastructure_nodes:worker_nodes
gather_facts: false
any_errors_fatal: true
roles:
- kvm
# We have to run it with serial=1, otherwise it's not executed per host
- name: Update hosts
hosts: infrastructure_nodes:worker_nodes
gather_facts: false
serial: 1
tasks:
- name: Add a host alias so we can connect to the discovered vm ip
ansible.builtin.add_host:
hostname: '{{ inventory_hostname }}'
ansible_host: '{{ vm_ip.stdout }}'
- name: Uninstall k3s
hosts: infrastructure_nodes:worker_nodes
gather_facts: false
tasks:
- name: Killall k3s
ansible.builtin.command: /usr/local/bin/k3s-killall.sh
ignore_errors: true
- name: Uninstall k3s
ansible.builtin.command: /usr/local/bin/k3s-uninstall.sh
ignore_errors: true
when: "'infrastructure_nodes' in group_names"
- name: Uninstall k3s
ansible.builtin.command: /usr/local/bin/k3s-agent-uninstall.sh
ignore_errors: true
when: "'worker_nodes' in group_names"
- name: Drop databases
hosts: infrastructure_nodes[0]
gather_facts: false
tasks:
- name: Drop database k3s
ansible.builtin.command: mariadb -e "DROP DATABASE IF EXISTS k3s;"
- name: Drop database kolabdev
ansible.builtin.command: mariadb -e "DROP DATABASE IF EXISTS kolabdev;"
ignore_errors: true
- name: Drop database roundcube
ansible.builtin.command: mariadb -e "DROP DATABASE IF EXISTS roundcube;"
ignore_errors: true
- name: Configure kolab-node
hosts: infrastructure_nodes:worker_nodes
gather_facts: False
any_errors_fatal: true
roles:
- kolab-node
- name: Fetch kubeconfig.yaml
hosts: infrastructure_nodes[0]
gather_facts: False
tasks:
- ansible.builtin.set_fact:
kubeconfig: "{{ resources_dir }}/kubeconfig.yaml"
- fetch:
flat: true
src: /etc/rancher/k3s/k3s.yaml
dest: "{{ kubeconfig }}"
- ansible.builtin.shell: |
sed -i "s/127.0.0.1/{{ virtual_ip }}/" {{ kubeconfig }}; \
env KUBECONFIG={{ kubeconfig }} kubectl config set-context --namespace=kolab --user=default --cluster=default --current; \
delegate_to: 127.0.0.1
- name: Check kubectl config
ansible.builtin.shell:
cmd: env KUBECONFIG={{ kubeconfig }} kubectl get pods
delegate_to: 127.0.0.1

File Metadata

Mime Type
text/plain
Expires
Sat, Apr 4, 6:27 AM (1 w, 2 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
18822840
Default Alt Text
reinstall-k3s.yaml (2 KB)

Event Timeline