4
0
forked from jakub/ansible
Files
ansible_fencl/update_bettershift.yml
T
2026-06-29 12:27:50 +02:00

86 lines
2.6 KiB
YAML

# update_bettershift.yml
- name: Update BetterShift
hosts: pve2_vm
gather_facts: false
vars:
compose_local_dir: "{{ playbook_dir }}/docker-compose"
compose_remote_base: "/home/{{ ansible_user }}/.ansible-compose/docker-compose"
bettershift_project: bettershift
bettershift_compose_filename: "docker-compose-bettershift.yml"
bettershift_service: bettershift
bettershift_port: 3067
bettershift_data_dir: "/data/compose/bettershift/data"
tasks:
- name: Ensure remote compose directory exists
ansible.builtin.file:
path: "{{ compose_remote_base }}"
state: directory
mode: "0755"
- name: Ensure BetterShift data directory exists
ansible.builtin.file:
path: "{{ bettershift_data_dir }}"
state: directory
mode: "0755"
- name: Upload BetterShift compose file to remote host
ansible.builtin.copy:
src: "{{ compose_local_dir }}/{{ bettershift_compose_filename }}"
dest: "{{ compose_remote_base }}/{{ bettershift_compose_filename }}"
mode: "0644"
- name: Check BetterShift env file exists on remote host
ansible.builtin.stat:
path: "{{ compose_remote_base }}/.env.bettershift"
register: bettershift_env_file
- name: Fail if BetterShift env file is missing
ansible.builtin.fail:
msg: >-
Missing {{ compose_remote_base }}/.env.bettershift on remote host.
Create it manually because it contains secrets.
when: not bettershift_env_file.stat.exists
- name: Pull latest BetterShift image
community.docker.docker_compose_v2:
project_name: "{{ bettershift_project }}"
project_src: "{{ compose_remote_base }}"
files:
- "{{ bettershift_compose_filename }}"
pull: always
- name: Recreate BetterShift service
community.docker.docker_compose_v2:
project_name: "{{ bettershift_project }}"
project_src: "{{ compose_remote_base }}"
files:
- "{{ bettershift_compose_filename }}"
services:
- "{{ bettershift_service }}"
state: present
recreate: always
- name: Wait for BetterShift port
ansible.builtin.wait_for:
host: 127.0.0.1
port: "{{ bettershift_port }}"
timeout: 60
- name: Check BetterShift HTTP endpoint
ansible.builtin.uri:
url: "http://127.0.0.1:{{ bettershift_port }}/"
status_code:
- 200
- 307
- 308
follow_redirects: none
register: bettershift_http
retries: 30
delay: 3
until: bettershift_http.status in [200, 307, 308]
changed_when: false