ansible-lint

This commit is contained in:
2023-07-07 22:40:54 +05:30
parent 8a0bf70474
commit 3f9c37c08f
5 changed files with 117 additions and 102 deletions

View File

@@ -1,47 +1,52 @@
---
- name: Create directory for service
file:
path: /opt/docker/{{item}}
ansible.builtin.file:
path: /opt/docker/{{ item }}
state: directory
mode: "0755"
tags: docker
- name: Copy docker-compose templates for the service
template:
src: ./compose/{{item}}/compose.yml.j2
dest: /opt/docker/{{item}}/compose.yml
backup: yes
ansible.builtin.template:
src: ./compose/{{ item }}/compose.yml.j2
dest: /opt/docker/{{ item }}/compose.yml
backup: true
mode: preserve
register: check_status
tags: docker
- name: check if extras file exists for the service
local_action: stat path=./compose/{{item}}/extras.conf.j2
- name: Check if extras file exists for the service
delegate_to: localhost
ansible.builtin.stat:
path: ./compose/{{ item }}/extras.conf.j2
register: file
tags: docker
- name: Copy extras file
template:
src: ./compose/{{item}}/extras.conf.j2
dest: /opt/docker/{{item}}/extras.conf
backup: yes
ansible.builtin.template:
src: ./compose/{{ item }}/extras.conf.j2
dest: /opt/docker/{{ item }}/extras.conf
backup: true
mode: preserve
when: file.stat.exists
tags: docker
- name: "Update docker service image"
command:
ansible.builtin.command:
chdir: "/opt/docker/{{ item }}"
cmd: docker compose pull
when: check_status.changed
tags: docker
- name: "Stop docker service"
command:
ansible.builtin.command:
chdir: "/opt/docker/{{ item }}"
cmd: docker compose down
when: check_status.changed
tags: docker
- name: "Start docker service"
command:
ansible.builtin.command:
chdir: "/opt/docker/{{ item }}"
cmd: docker compose up -d --build --remove-orphans
when: check_status.changed

View File

@@ -13,20 +13,22 @@
tasks:
# This is run again so config still updates even if i dont run the role which isnt needed most of the time
- name: Copy Caddyfile
template:
ansible.builtin.template:
src: ./templates/Caddyfile.j2
dest: /etc/caddy/Caddyfile
mode: preserve
tags: caddy-non-update
- name: Copy per-server caddy extras
copy:
ansible.builtin.copy:
src: "./templates/{{ inventory_hostname }}/"
dest: /etc/caddy/
directory_mode: true
mode: preserve
tags: caddy-non-update
- name: Reload Caddy
service:
ansible.builtin.service:
name: caddy
enabled: yes
enabled: true
state: reloaded
tags: caddy-non-update
- name: Setup docker compose for privacy frontends
@@ -34,11 +36,9 @@
vars:
docker_services:
- anonymousoverflow
#- beatbump
- breezewiki
- gothub
- gothub-dev
#- invidious
- librarian
- libreddit
- nitter
@@ -48,20 +48,23 @@
- simplytranslate
- teddit
- watchtower
non_pizza_docker_services:
#- piped
- searxng
tasks:
#
# community.docker does not support compose 2.0 right now.
# https://github.com/ansible-collections/community.docker/issues/216
#
- name: Update docker compose files and restart those with changes
include_tasks: docker-tasks.yaml
ansible.builtin.include_tasks: docker-tasks.yaml
with_items: "{{ docker_services }}"
tags: docker
- name: Setup docker compose for privacy frontends (non-pizza1)
hosts: in,us
vars:
non_pizza_docker_services:
- searxng
tasks:
# community.docker does not support compose 2.0 right now.
# https://github.com/ansible-collections/community.docker/issues/216
- name: Update docker compose files and restart those with changes (Privacy Frontends but without Pizza1)
include_tasks: docker-tasks.yaml
ansible.builtin.include_tasks: docker-tasks.yaml
with_items: "{{ non_pizza_docker_services }}"
tags: docker
@@ -69,14 +72,14 @@
hosts: privfrontends
tasks:
- name: Restart invidious every hour
cron:
ansible.builtin.cron:
name: "hourly invidious restart"
special_time: hourly
job: "docker restart invidious-invidious-1 && curl https://healthchecks.projectsegfau.lt/ping/{{invidious_hc_uuid}}"
job: "docker restart invidious-invidious-1 && curl https://healthchecks.projectsegfau.lt/ping/{{ invidious_hc_uuid }}"
tags: cron
- name: Restart teddit every hour
cron:
ansible.builtin.cron:
name: "hourly teddit restart"
special_time: hourly
job: "docker restart teddit && curl https://healthchecks.projectsegfau.lt/ping/{{teddit_hc_uuid}}"
job: "docker restart teddit && curl https://healthchecks.projectsegfau.lt/ping/{{ teddit_hc_uuid }}"
tags: cron