diff --git a/main.yaml b/main.yaml index 4ea861d2..52c4d519 100644 --- a/main.yaml +++ b/main.yaml @@ -84,7 +84,7 @@ - role: zigbee2mqtt tags: zigbee2mqtt, autorestic vars: - autorestic_docker: false + zigbee2mqtt_autorestic_docker: false - role: tailscale tags: tailscale vars: diff --git a/roles/autorestic/defaults/main.yaml b/roles/autorestic/defaults/main.yaml index 683a53d2..c57210b8 100644 --- a/roles/autorestic/defaults/main.yaml +++ b/roles/autorestic/defaults/main.yaml @@ -1,4 +1,4 @@ --- -service_name: "{{ ansible_role_name }}" -service_path: "{{ services_path }}/{{ service_name }}" +autorestic_service_name: "{{ ansible_role_name }}" +autorestic_service_path: "{{ services_path }}/{{ autorestic_service_name }}" autorestic_docker: true diff --git a/roles/autorestic/tasks/main.yaml b/roles/autorestic/tasks/main.yaml index 6f06f6a1..76e4fc9b 100644 --- a/roles/autorestic/tasks/main.yaml +++ b/roles/autorestic/tasks/main.yaml @@ -1,27 +1,27 @@ --- - name: Create directories ansible.builtin.file: - path: "{{ service_path }}" + path: "{{ autorestic_service_path }}" state: directory mode: "0775" - name: Create compose file ansible.builtin.template: src: "templates/compose.yaml.j2" - dest: "{{ service_path }}/compose.yaml" + dest: "{{ autorestic_service_path }}/compose.yaml" mode: "0640" when: autorestic_docker - name: Create autorestic config ansible.builtin.template: src: "templates/autorestic.yaml.j2" - dest: "{{ service_path }}/autorestic.yaml" + dest: "{{ autorestic_service_path }}/autorestic.yaml" mode: "0640" - name: Create justfile ansible.builtin.template: src: "templates/justfile.j2" - dest: "{{ service_path }}/justfile" + dest: "{{ autorestic_service_path }}/justfile" mode: "0640" - name: Install autorestic diff --git a/roles/autorestic/templates/autorestic_backup.service.j2 b/roles/autorestic/templates/autorestic_backup.service.j2 index 99c5d480..3bbd7ebe 100644 --- a/roles/autorestic/templates/autorestic_backup.service.j2 +++ b/roles/autorestic/templates/autorestic_backup.service.j2 @@ -4,9 +4,9 @@ Description=Backup {{ autorestic_location }} using autorestic [Service] Type=simple User={{ ansible_ssh_user | default(ansible_user_id) }} -WorkingDirectory={{ service_path }} +WorkingDirectory={{ autorestic_service_path }} {% if autorestic_docker %} ExecStart=docker compose run autorestic bash -c "apk add curl && autorestic backup --verbose --location {{ autorestic_location }}" {% else %} -ExecStart=autorestic backup --verbose --location {{ autorestic_location }} --config {{ service_path }}/autorestic.yaml +ExecStart=autorestic backup --verbose --location {{ autorestic_location }} --config {{ autorestic_service_path }}/autorestic.yaml {% endif %} diff --git a/roles/github_deploy/defaults/main.yaml b/roles/github_deploy/defaults/main.yaml index 23062f50..8ec7eba0 100644 --- a/roles/github_deploy/defaults/main.yaml +++ b/roles/github_deploy/defaults/main.yaml @@ -1,3 +1,3 @@ --- -service_name: github-deploy -service_path: "{{ services_path }}/{{ service_name }}" +github_deploy_service_name: github-deploy +github_deploy_service_path: "{{ services_path }}/{{ github_deploy_service_name }}" # yamllint disable rule:line-length diff --git a/roles/github_deploy/handlers/main.yaml b/roles/github_deploy/handlers/main.yaml index 749b8037..b9c9243a 100644 --- a/roles/github_deploy/handlers/main.yaml +++ b/roles/github_deploy/handlers/main.yaml @@ -1,6 +1,6 @@ --- -- name: Recreate {{ service_name }} +- name: Recreate {{ github_deploy_service_name }} ansible.builtin.command: - chdir: "{{ service_path }}" + chdir: "{{ github_deploy_service_path }}" cmd: docker compose up -d --force-recreate --build changed_when: true diff --git a/roles/github_deploy/tasks/main.yaml b/roles/github_deploy/tasks/main.yaml index 2751124c..2afb4870 100644 --- a/roles/github_deploy/tasks/main.yaml +++ b/roles/github_deploy/tasks/main.yaml @@ -5,25 +5,25 @@ state: directory mode: "0775" loop: - - "{{ service_path }}" + - "{{ github_deploy_service_path }}" - name: Create compose file ansible.builtin.template: src: "templates/compose.yaml.j2" - dest: "{{ service_path }}/compose.yaml" + dest: "{{ github_deploy_service_path }}/compose.yaml" mode: "0640" - notify: "Recreate {{ service_name }}" + notify: "Recreate {{ github_deploy_service_name }}" - name: Create files for image ansible.builtin.copy: src: "files/" - dest: "{{ service_path }}/" + dest: "{{ github_deploy_service_path }}/" mode: "0640" - notify: "Recreate {{ service_name }}" + notify: "Recreate {{ github_deploy_service_name }}" - name: Create initial empty processed_runs.txt ansible.builtin.copy: content: "" - dest: "{{ service_path }}/processed_runs.txt" + dest: "{{ github_deploy_service_path }}/processed_runs.txt" force: false mode: "0600" diff --git a/roles/healthchecks/defaults/main.yaml b/roles/healthchecks/defaults/main.yaml index 9b61aee1..bc5b4240 100644 --- a/roles/healthchecks/defaults/main.yaml +++ b/roles/healthchecks/defaults/main.yaml @@ -1,3 +1,3 @@ --- -service_name: "{{ ansible_role_name }}" -service_path: "{{ services_path }}/{{ service_name }}" +healthchecks_service_name: "{{ ansible_role_name }}" +healthchecks_service_path: "{{ services_path }}/{{ healthchecks_service_name }}" diff --git a/roles/healthchecks/handlers/main.yaml b/roles/healthchecks/handlers/main.yaml index 2972fc4c..cce06b09 100644 --- a/roles/healthchecks/handlers/main.yaml +++ b/roles/healthchecks/handlers/main.yaml @@ -1,6 +1,6 @@ --- -- name: Recreate {{ service_name }} +- name: Recreate {{ healthchecks_service_name }} ansible.builtin.command: - chdir: "{{ service_path }}" + chdir: "{{ healthchecks_service_path }}" cmd: docker compose up -d --force-recreate changed_when: true diff --git a/roles/healthchecks/tasks/main.yaml b/roles/healthchecks/tasks/main.yaml index 29244cbc..65abb85b 100644 --- a/roles/healthchecks/tasks/main.yaml +++ b/roles/healthchecks/tasks/main.yaml @@ -1,14 +1,14 @@ --- - name: Create service directory ansible.builtin.file: - path: "{{ service_path }}" + path: "{{ healthchecks_service_path }}" state: directory mode: "0775" - name: Create data directory become: true ansible.builtin.file: - path: "{{ service_path }}/data" + path: "{{ healthchecks_service_path }}/data" state: directory mode: "0775" owner: 999 @@ -17,13 +17,13 @@ - name: Create compose file ansible.builtin.template: src: "templates/compose.yaml.j2" - dest: "{{ service_path }}/compose.yaml" + dest: "{{ healthchecks_service_path }}/compose.yaml" mode: "0640" - notify: "Recreate {{ service_name }}" + notify: "Recreate {{ healthchecks_service_name }}" - name: Create uWSGI config ansible.builtin.copy: src: "files/uwsgi.ini" - dest: "{{ service_path }}/uwsgi.ini" + dest: "{{ healthchecks_service_path }}/uwsgi.ini" mode: "0644" - notify: "Recreate {{ service_name }}" + notify: "Recreate {{ healthchecks_service_name }}" diff --git a/roles/homeassistant/defaults/main.yaml b/roles/homeassistant/defaults/main.yaml index 79324b34..dccf4f19 100644 --- a/roles/homeassistant/defaults/main.yaml +++ b/roles/homeassistant/defaults/main.yaml @@ -1,6 +1,6 @@ --- -service_name: "{{ ansible_role_name }}" -service_path: "{{ services_path }}/{{ service_name }}" +homeassistant_service_name: "{{ ansible_role_name }}" +homeassistant_service_path: "{{ services_path }}/{{ homeassistant_service_name }}" # yamllint disable rule:line-length homeassistant_areas: - bedroom - guest_room diff --git a/roles/homeassistant/handlers/main.yaml b/roles/homeassistant/handlers/main.yaml index 2972fc4c..16eade1c 100644 --- a/roles/homeassistant/handlers/main.yaml +++ b/roles/homeassistant/handlers/main.yaml @@ -1,6 +1,6 @@ --- -- name: Recreate {{ service_name }} +- name: Recreate {{ homeassistant_service_name }} ansible.builtin.command: - chdir: "{{ service_path }}" + chdir: "{{ homeassistant_service_path }}" cmd: docker compose up -d --force-recreate changed_when: true diff --git a/roles/homeassistant/tasks/main.yaml b/roles/homeassistant/tasks/main.yaml index b713057e..de5f196b 100644 --- a/roles/homeassistant/tasks/main.yaml +++ b/roles/homeassistant/tasks/main.yaml @@ -5,64 +5,64 @@ state: directory mode: "0775" loop: - - "{{ service_path }}" - - "{{ service_path }}/config" + - "{{ homeassistant_service_path }}" + - "{{ homeassistant_service_path }}/config" - name: Create compose file ansible.builtin.template: src: "templates/compose.yaml.j2" - dest: "{{ service_path }}/compose.yaml" + dest: "{{ homeassistant_service_path }}/compose.yaml" mode: "0640" - notify: "Recreate {{ service_name }}" + notify: "Recreate {{ homeassistant_service_name }}" - name: Create config ansible.builtin.copy: src: "files/config/" - dest: "{{ service_path }}/config" + dest: "{{ homeassistant_service_path }}/config" mode: "0640" backup: true - notify: "Recreate {{ service_name }}" + notify: "Recreate {{ homeassistant_service_name }}" - name: Create lights timer automations ansible.builtin.template: src: "templates/lights_timer.yaml.j2" - dest: "{{ service_path }}/config/automation/lights_timer.yaml" + dest: "{{ homeassistant_service_path }}/config/automation/lights_timer.yaml" mode: "0640" - notify: "Recreate {{ service_name }}" + notify: "Recreate {{ homeassistant_service_name }}" - name: Create lights darkness automations ansible.builtin.template: src: "templates/lights_darkness.yaml.j2" - dest: "{{ service_path }}/config/automation/lights_darkness.yaml" + dest: "{{ homeassistant_service_path }}/config/automation/lights_darkness.yaml" # yamllint disable rule:line-length mode: "0640" - notify: "Recreate {{ service_name }}" + notify: "Recreate {{ homeassistant_service_name }}" - name: Create portfolio ansible.builtin.template: src: "templates/portfolio.yaml.j2" - dest: "{{ service_path }}/config/sensor/portfolio.yaml" + dest: "{{ homeassistant_service_path }}/config/sensor/portfolio.yaml" mode: "0640" - notify: "Recreate {{ service_name }}" + notify: "Recreate {{ homeassistant_service_name }}" - name: Create static template sensors ansible.builtin.template: src: "templates/static.yaml.j2" - dest: "{{ service_path }}/config/template/static.yaml" + dest: "{{ homeassistant_service_path }}/config/template/static.yaml" mode: "0640" - notify: "Recreate {{ service_name }}" + notify: "Recreate {{ homeassistant_service_name }}" - name: Create monitor dashboard ansible.builtin.template: src: "templates/lovelace-monitor.yaml.j2" - dest: "{{ service_path }}/config/lovelace-monitor.yaml" + dest: "{{ homeassistant_service_path }}/config/lovelace-monitor.yaml" mode: "0640" - name: Create secrets ansible.builtin.template: src: "templates/secrets.yaml.j2" - dest: "{{ service_path }}/config/secrets.yaml" + dest: "{{ homeassistant_service_path }}/config/secrets.yaml" mode: "0600" - notify: "Recreate {{ service_name }}" + notify: "Recreate {{ homeassistant_service_name }}" - name: Create backups with autorestic ansible.builtin.include_role: diff --git a/roles/traefik/defaults/main.yaml b/roles/traefik/defaults/main.yaml index 8f571429..1e8f9e0a 100644 --- a/roles/traefik/defaults/main.yaml +++ b/roles/traefik/defaults/main.yaml @@ -1,3 +1,3 @@ --- -service_name: traefik -service_path: "{{ services_path }}/{{ service_name }}" +traefik_service_name: traefik +traefik_service_path: "{{ services_path }}/{{ traefik_service_name }}" diff --git a/roles/traefik/handlers/main.yaml b/roles/traefik/handlers/main.yaml index 2972fc4c..9b0158c5 100644 --- a/roles/traefik/handlers/main.yaml +++ b/roles/traefik/handlers/main.yaml @@ -1,6 +1,6 @@ --- -- name: Recreate {{ service_name }} +- name: Recreate {{ traefik_service_name }} ansible.builtin.command: - chdir: "{{ service_path }}" + chdir: "{{ traefik_service_path }}" cmd: docker compose up -d --force-recreate changed_when: true diff --git a/roles/traefik/tasks/main.yaml b/roles/traefik/tasks/main.yaml index bee4c6ed..331a90e8 100644 --- a/roles/traefik/tasks/main.yaml +++ b/roles/traefik/tasks/main.yaml @@ -5,34 +5,34 @@ state: directory mode: "0775" loop: - - "{{ service_path }}" - - "{{ service_path }}/log" + - "{{ traefik_service_path }}" + - "{{ traefik_service_path }}/log" - name: Create compose file ansible.builtin.template: src: "templates/compose.yaml.j2" - dest: "{{ service_path }}/compose.yaml" + dest: "{{ traefik_service_path }}/compose.yaml" mode: "0640" - notify: "Recreate {{ service_name }}" + notify: "Recreate {{ traefik_service_name }}" - name: Create middlewares ansible.builtin.copy: src: "files/middlewares.yaml" - dest: "{{ service_path }}/middlewares.yaml" + dest: "{{ traefik_service_path }}/middlewares.yaml" mode: "0640" - notify: "Recreate {{ service_name }}" + notify: "Recreate {{ traefik_service_name }}" - name: Create config ansible.builtin.template: src: "templates/traefik.yaml.j2" - dest: "{{ service_path }}/traefik.yaml" + dest: "{{ traefik_service_path }}/traefik.yaml" mode: "0640" - notify: "Recreate {{ service_name }}" + notify: "Recreate {{ traefik_service_name }}" - name: Create initial empty acme ansible.builtin.copy: content: "" - dest: "{{ service_path }}/acme.json" + dest: "{{ traefik_service_path }}/acme.json" force: false mode: "0600" @@ -46,7 +46,7 @@ - name: Create basic auth file community.general.htpasswd: - path: "{{ service_path }}/.htpasswd" + path: "{{ traefik_service_path }}/.htpasswd" name: "{{ traefik_username }}" password: "{{ traefik_password }}" mode: "0600" diff --git a/roles/zigbee2mqtt/tasks/main.yaml b/roles/zigbee2mqtt/tasks/main.yaml index 47efaab2..a5ab5587 100644 --- a/roles/zigbee2mqtt/tasks/main.yaml +++ b/roles/zigbee2mqtt/tasks/main.yaml @@ -18,3 +18,4 @@ name: autorestic vars: autorestic_location: "zigbee2mqtt" + autorestic_docker: zigbee2mqtt_autorestic_docker