Add OneLab Helm chart, Argo CD Application, and GitOps values for k3s
Made-with: Cursor
This commit is contained in:
115
app/playbooks/update.yml
Normal file
115
app/playbooks/update.yml
Normal file
@@ -0,0 +1,115 @@
|
||||
# This playbook updates the OneLab Enterprise to latest version or a chosen version in one step
|
||||
---
|
||||
- name: Updating OneLab
|
||||
hosts: localhost
|
||||
gather_facts: yes
|
||||
vars:
|
||||
main_path: '../../../../..'
|
||||
onelab_path: '../../../../../onelab'
|
||||
|
||||
vars_prompt:
|
||||
- name: "userchoice"
|
||||
prompt: "Confirm OneLab update: yes/no"
|
||||
private: no
|
||||
|
||||
tasks:
|
||||
|
||||
# Choice to proceed or stop the update process
|
||||
- name: Aborting the update process
|
||||
fail:
|
||||
msg: Aborting the update process
|
||||
when: userchoice != "yes"
|
||||
|
||||
# Gather latest version information
|
||||
- name: Fetching OneLab latest version details from the repository
|
||||
uri:
|
||||
url: "https://hub.andrewalliance.com/enterprise/version.json"
|
||||
return_content: yes
|
||||
validate_certs: no
|
||||
register: latest_version
|
||||
become: true
|
||||
when: version is undefined
|
||||
- set_fact:
|
||||
latest: "{{ (latest_version.content | from_json).version }}"
|
||||
when: version is undefined
|
||||
|
||||
- name: Checking OneLab current version
|
||||
fail:
|
||||
msg: OneLab is already up-to-date (1.27.0)
|
||||
when: (version is undefined) and (latest == "1.27.0")
|
||||
|
||||
- name: Starting OneLab update to {{ version | default(latest) }}
|
||||
debug:
|
||||
msg: Version {{ version | default(latest) }}
|
||||
|
||||
# Remove installer bundles if it exists already, then download & unzip
|
||||
- name: Removing the bundle if it already exists
|
||||
file:
|
||||
state: absent
|
||||
path: "{{ item }}"
|
||||
with_items:
|
||||
- "{{ main_path }}/onelab-enterprise-installer-{{ version | default(latest)}}"
|
||||
- "{{ main_path }}/onelab-enterprise-installer-{{ version | default(latest)}}.zip"
|
||||
become: true
|
||||
|
||||
- name: Downloading the installer bundle
|
||||
shell: wget --no-check-certificate https://hub.andrewalliance.com/enterprise/onelab-enterprise-installer-{{ version | default(latest)}}.zip -P {{ main_path }}
|
||||
become: true
|
||||
|
||||
- name: Unzip the installer bundle
|
||||
shell: unzip {{ main_path }}/onelab-enterprise-installer-{{ version | default(latest)}}.zip -d {{ main_path }}/onelab-enterprise-installer-{{ version | default(latest)}}
|
||||
become: true
|
||||
|
||||
- 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"
|
||||
|
||||
# Start Proxy (maintenance page) if OneLab was running
|
||||
- include_tasks: "{{ onelab_path }}/installation/latest/app/playbooks/tasks/start-proxy.yml"
|
||||
when: stack_count.stdout != "0"
|
||||
|
||||
# Perform OneLab backup
|
||||
- include_tasks: "{{ onelab_path }}/installation/latest/app/playbooks/tasks/backup-task.yml"
|
||||
|
||||
# Perform OneLab update
|
||||
- include_tasks: "{{ main_path }}/onelab-enterprise-installer-{{ version | default(latest)}}/app/playbooks/tasks/install-task.yml"
|
||||
vars:
|
||||
main_path: '../../../../..'
|
||||
onelab_path: '../../../../../onelab'
|
||||
installer_path: '../../../../../onelab-enterprise-installer-{{ version | default(latest)}}'
|
||||
|
||||
# Load configuration
|
||||
- include_vars:
|
||||
file: "{{ onelab_path }}/configurations.yml"
|
||||
|
||||
# Perform reconfiguration
|
||||
# Use dynamic path (variable) to force dynamic loading of this new task
|
||||
- include_tasks: "{{ onelab_path }}/installation/latest/app/playbooks/tasks/reconfigure-task.yml"
|
||||
|
||||
# Remove installer bundles
|
||||
- name: Removing the installer
|
||||
file:
|
||||
state: absent
|
||||
path: "{{ item }}"
|
||||
with_items:
|
||||
- "{{ main_path }}/onelab-enterprise-installer-{{ version | default(latest)}}"
|
||||
- "{{ main_path }}/onelab-enterprise-installer-{{ version | default(latest)}}.zip"
|
||||
become: true
|
||||
|
||||
# Stop Proxy (maintenance page) if OneLab was running
|
||||
# Use dynamic path (variable) to force dynamic loading of this new task
|
||||
- include_tasks: "{{ onelab_path }}/installation/latest/app/playbooks/tasks/stop-proxy.yml"
|
||||
when: stack_count.stdout != "0"
|
||||
|
||||
# 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