3
0
forked from jakub/ansible

edit homarr

This commit is contained in:
martin.fencl
2026-02-03 17:57:37 +01:00
parent fa2f4fa6d5
commit 309394b503

View File

@@ -1,54 +1,50 @@
# update_homarr2.yml
- name: Update Homarr - name: Update Homarr
hosts: pve2_vm hosts: pve2_vm
gather_facts: false gather_facts: false
become: true
become_method: sudo
vars: vars:
homarr_compose_local: "{{ playbook_dir }}/docker-compose/docker-compose-homarr.yml" homarr_project: homarr
homarr_compose_remote_dir: "/data/compose/homarr"
homarr_compose_remote: "{{ homarr_compose_remote_dir }}/docker-compose-homarr.yml" # Local (controller) directory with compose files
compose_local_dir: "{{ playbook_dir }}/docker-compose"
# Remote (target) staging directory - writable for the SSH user
compose_remote_dir: "/home/{{ ansible_user }}/.ansible-compose/docker-compose"
# Which compose file inside the directory to use
homarr_compose_filename: "docker-compose-homarr.yml"
homarr_service: homarr homarr_service: homarr
homarr_port: 7575 homarr_port: 7575
tasks: tasks:
- name: Show effective user (debug) - name: Ensure remote staging directory exists
ansible.builtin.command: id
register: whoami_result
changed_when: false
- name: Print effective user (debug)
ansible.builtin.debug:
var: whoami_result.stdout
- name: Ensure remote compose directory exists
ansible.builtin.file: ansible.builtin.file:
path: "{{ homarr_compose_remote_dir }}" path: "{{ compose_remote_dir }}"
state: directory state: directory
mode: "0755" mode: "0755"
- name: Test write access to remote dir (as become) - name: Sync compose directory from controller to remote host
ansible.builtin.command: "sh -lc 'echo test > {{ homarr_compose_remote_dir }}/.ansible_write_test && rm -f {{ homarr_compose_remote_dir }}/.ansible_write_test'" ansible.posix.synchronize:
changed_when: false src: "{{ compose_local_dir }}/"
dest: "{{ compose_remote_dir }}/"
- name: Copy compose file from controller to remote host delete: true
ansible.builtin.copy: recursive: true
src: "{{ homarr_compose_local }}"
dest: "{{ homarr_compose_remote }}"
mode: "0644"
- name: Pull latest Homarr image - name: Pull latest Homarr image
community.docker.docker_compose_v2: community.docker.docker_compose_v2:
project_src: "{{ homarr_compose_remote_dir }}" project_src: "{{ compose_remote_dir }}"
files: files:
- "{{ homarr_compose_remote | basename }}" - "{{ homarr_compose_filename }}"
pull: always pull: always
- name: Recreate Homarr service - name: Recreate Homarr service
community.docker.docker_compose_v2: community.docker.docker_compose_v2:
project_src: "{{ homarr_compose_remote_dir }}" project_src: "{{ compose_remote_dir }}"
files: files:
- "{{ homarr_compose_remote | basename }}" - "{{ homarr_compose_filename }}"
services: services:
- "{{ homarr_service }}" - "{{ homarr_service }}"
state: present state: present