Skip to content

Commit

Permalink
Make role variables compliant with latest ansible-lint
Browse files Browse the repository at this point in the history
  • Loading branch information
claha committed Oct 26, 2023
1 parent 71bb0a1 commit 659b998
Show file tree
Hide file tree
Showing 17 changed files with 65 additions and 64 deletions.
2 changes: 1 addition & 1 deletion main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
- role: zigbee2mqtt
tags: zigbee2mqtt, autorestic
vars:
autorestic_docker: false
zigbee2mqtt_autorestic_docker: false
- role: tailscale
tags: tailscale
vars:
Expand Down
4 changes: 2 additions & 2 deletions roles/autorestic/defaults/main.yaml
Original file line number Diff line number Diff line change
@@ -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
8 changes: 4 additions & 4 deletions roles/autorestic/tasks/main.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions roles/autorestic/templates/autorestic_backup.service.j2
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}
4 changes: 2 additions & 2 deletions roles/github_deploy/defaults/main.yaml
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions roles/github_deploy/handlers/main.yaml
Original file line number Diff line number Diff line change
@@ -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
12 changes: 6 additions & 6 deletions roles/github_deploy/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
4 changes: 2 additions & 2 deletions roles/healthchecks/defaults/main.yaml
Original file line number Diff line number Diff line change
@@ -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 }}"
4 changes: 2 additions & 2 deletions roles/healthchecks/handlers/main.yaml
Original file line number Diff line number Diff line change
@@ -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
12 changes: 6 additions & 6 deletions roles/healthchecks/tasks/main.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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 }}"
4 changes: 2 additions & 2 deletions roles/homeassistant/defaults/main.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions roles/homeassistant/handlers/main.yaml
Original file line number Diff line number Diff line change
@@ -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
34 changes: 17 additions & 17 deletions roles/homeassistant/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions roles/traefik/defaults/main.yaml
Original file line number Diff line number Diff line change
@@ -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 }}"
4 changes: 2 additions & 2 deletions roles/traefik/handlers/main.yaml
Original file line number Diff line number Diff line change
@@ -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
20 changes: 10 additions & 10 deletions roles/traefik/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -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"
1 change: 1 addition & 0 deletions roles/zigbee2mqtt/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@
name: autorestic
vars:
autorestic_location: "zigbee2mqtt"
autorestic_docker: zigbee2mqtt_autorestic_docker

0 comments on commit 659b998

Please sign in to comment.