Add OneLab Helm chart, Argo CD Application, and GitOps values for k3s
Made-with: Cursor
This commit is contained in:
3
resources/restore/restore.sh
Normal file
3
resources/restore/restore.sh
Normal file
@@ -0,0 +1,3 @@
|
||||
|
||||
#!/bin/bash
|
||||
ANSIBLE_LOG_PATH=../../logs/ansible/$(date +%F)-ansible.log ansible-playbook ./restore.yml
|
||||
104
resources/restore/restore.yml
Normal file
104
resources/restore/restore.yml
Normal file
@@ -0,0 +1,104 @@
|
||||
---
|
||||
- name: Restoring OneLab (1.27.0)
|
||||
hosts: localhost
|
||||
vars_prompt:
|
||||
- name: "userchoice"
|
||||
prompt: "Confirm OneLab 1.27.0 restore: yes/no"
|
||||
private: no
|
||||
vars:
|
||||
onelab_path: '../..'
|
||||
onelab_images_path: '../../../onelab-images-1.27.0.tar.gz'
|
||||
main_path: '../../..'
|
||||
|
||||
tasks:
|
||||
- name: Checking if the OneLab images bundle is existing
|
||||
stat:
|
||||
path: "{{ onelab_images_path }}"
|
||||
get_checksum: no
|
||||
register: docker_images_tar
|
||||
|
||||
- name: Aborting the restore process
|
||||
fail:
|
||||
msg: Aborting the restore process
|
||||
when: userchoice != "yes"
|
||||
|
||||
# Stop OneLab if OneLab is running
|
||||
- name: Checking if OneLab is running
|
||||
shell: docker stack ls | grep 'onelab' | wc -l
|
||||
become: true
|
||||
register: stack_count
|
||||
|
||||
# Stop OneLab (unkown version) if OneLab is running
|
||||
- include_tasks: "{{ onelab_path }}/installation/latest/app/playbooks/tasks/stop-onelab.yml"
|
||||
when: stack_count.stdout != "0"
|
||||
- include_tasks: "{{ onelab_path }}/installation/latest/app/playbooks/tasks/stop-proxy.yml"
|
||||
when: stack_count.stdout != "0"
|
||||
|
||||
# Load docker images
|
||||
- name: Loading Docker images
|
||||
debug:
|
||||
msg:
|
||||
- "Loading images could take few minutes, please do not interrupt"
|
||||
when: (docker_images_tar is defined) and (docker_images_tar.stat.exists)
|
||||
|
||||
- name: Loading OneLab images from the tar file
|
||||
shell:
|
||||
docker load --input {{ onelab_images_path }}
|
||||
become: true
|
||||
when: (docker_images_tar is defined) and (docker_images_tar.stat.exists)
|
||||
|
||||
- name: Unzipping backup
|
||||
shell: |
|
||||
tar xzvf ./onelab.tar.gz -C ./../..
|
||||
become: true
|
||||
|
||||
- name: Cleaning latest installation
|
||||
ansible.builtin.file:
|
||||
path: "{{ onelab_path }}/installation/latest"
|
||||
state: absent
|
||||
|
||||
- name: Flagging restored version as current
|
||||
ansible.builtin.copy:
|
||||
src: ../../installation/1.27.0/
|
||||
dest: ../../installation/latest
|
||||
directory_mode: no
|
||||
remote_src: yes
|
||||
|
||||
# Load configuration
|
||||
- include_vars:
|
||||
file: "{{ onelab_path }}/configurations.yml"
|
||||
|
||||
# Perform reconfiguration
|
||||
- include_tasks: "{{ onelab_path }}/installation/latest/app/playbooks/tasks/reconfigure-task.yml"
|
||||
|
||||
# Checking if volumes are existing
|
||||
- name: Getting the list of docker volumes
|
||||
shell: docker volume ls
|
||||
become: true
|
||||
register: volumes_result
|
||||
|
||||
# Removing volumes
|
||||
|
||||
- name: Resetting postgres database & cleaning cache
|
||||
shell: |
|
||||
docker volume rm onelab_pgdata -f
|
||||
docker volume rm onelab_rabbitmq_data -f
|
||||
become: true
|
||||
when: "'rabbitmq' in volumes_result.stdout or 'pgdata' in volumes_result.stdout"
|
||||
|
||||
# Restoring database
|
||||
|
||||
- include_tasks: "{{ onelab_path }}/installation/latest/app/playbooks/tasks/start-db-only.yml"
|
||||
|
||||
- name: Restoring database
|
||||
shell: >
|
||||
docker exec -i $(docker ps --filter "name=onelab_db|onelab-db" -q) pg_restore -Upostgres -dpostgres -v -Fc < ./db.tar.gz
|
||||
become: true
|
||||
|
||||
- include_tasks: "{{ onelab_path }}/installation/latest/app/playbooks/tasks/stop-db-only.yml"
|
||||
|
||||
# Start OneLab if OneLab was running
|
||||
- include_tasks: "{{ onelab_path }}/installation/latest/app/playbooks/tasks/start-proxy.yml"
|
||||
when: stack_count.stdout != "0"
|
||||
- include_tasks: "{{ onelab_path }}/installation/latest/app/playbooks/tasks/start-onelab.yml"
|
||||
when: stack_count.stdout != "0"
|
||||
Reference in New Issue
Block a user