Replace docker-compose restart hack with shell handler hack

The docker-compose integration would start 2 of the same container, which does bad things to things like databases!
This commit is contained in:
Jake Howard 2020-06-28 20:13:12 +01:00
parent 71086ca291
commit 86a398d6b4
Signed by: jake
GPG key ID: 57AFB45680EDD477
34 changed files with 112 additions and 271 deletions

View file

@ -4,3 +4,5 @@ docker_user:
docker_compose_file_mask: 0664 docker_compose_file_mask: 0664
docker_compose_directory_mask: 0775 docker_compose_directory_mask: 0775
docker_update_command: docker-compose down --remove-orphans && docker-compose rm && docker-compose pull && docker-compose up -d

View file

@ -0,0 +1,4 @@
- name: restart duplicati
shell:
chdir: /opt/duplicati
cmd: "{{ docker_update_command }}"

View file

@ -13,17 +13,5 @@
mode: "{{ docker_compose_file_mask }}" mode: "{{ docker_compose_file_mask }}"
owner: "{{ docker_user.name }}" owner: "{{ docker_user.name }}"
validate: /usr/bin/docker-compose -f %s config validate: /usr/bin/docker-compose -f %s config
register: compose_file notify: restart duplicati
become: true become: true
- name: Cycle duplicati container
docker_compose:
project_src: /opt/duplicati
pull: true
remove_orphans: true
remove_volumes: true
state: "{{ item }}"
when: compose_file.changed
loop:
- absent
- present

View file

@ -0,0 +1,4 @@
- name: restart homeassistant
shell:
chdir: /opt/home-assistant
cmd: "{{ docker_update_command }}"

View file

@ -20,7 +20,7 @@
mode: "{{ docker_compose_file_mask }}" mode: "{{ docker_compose_file_mask }}"
owner: "{{ docker_user.name }}" owner: "{{ docker_user.name }}"
validate: /usr/bin/docker-compose -f %s config validate: /usr/bin/docker-compose -f %s config
register: compose_file notify: restart homeassistant
become: true become: true
- name: Install config - name: Install config
@ -29,7 +29,7 @@
dest: /opt/home-assistant/config/configuration.yaml dest: /opt/home-assistant/config/configuration.yaml
mode: "{{ docker_compose_file_mask }}" mode: "{{ docker_compose_file_mask }}"
owner: "{{ docker_user.name }}" owner: "{{ docker_user.name }}"
register: config_file notify: restart homeassistant
become: true become: true
- name: Bump IGMP max memberships - name: Bump IGMP max memberships
@ -51,15 +51,3 @@
reload: yes reload: yes
sysctl_file: /etc/sysctl.d/99-sysctl.conf sysctl_file: /etc/sysctl.d/99-sysctl.conf
become: true become: true
- name: Cycle home-assistant container
docker_compose:
project_src: /opt/home-assistant
pull: true
remove_orphans: true
remove_volumes: true
state: "{{ item }}"
when: compose_file.changed or config_file.changed
loop:
- absent
- present

View file

@ -16,14 +16,8 @@
register: compose_file register: compose_file
become: true become: true
- name: Cycle calibre container - name: restart calibre
docker_compose: shell:
project_src: /opt/calibre chdir: /opt/calibre
pull: true cmd: "{{ docker_update_command }}"
remove_orphans: true
remove_volumes: true
state: "{{ item }}"
when: compose_file.changed when: compose_file.changed
loop:
- absent
- present

View file

@ -16,14 +16,8 @@
register: compose_file register: compose_file
become: true become: true
- name: Cycle folding@home container - name: restart folding-at-home
docker_compose: shell:
project_src: /opt/folding-at-home chdir: /opt/folding-at-home
pull: true cmd: "{{ docker_update_command }}"
remove_orphans: true
remove_volumes: true
state: "{{ item }}"
when: compose_file.changed when: compose_file.changed
loop:
- absent
- present

View file

@ -44,14 +44,8 @@
register: git_mirror_config_file register: git_mirror_config_file
become: true become: true
- name: Cycle gitea container - name: restart gitea
docker_compose: shell:
project_src: /opt/gitea chdir: /opt/gitea
pull: true cmd: "{{ docker_update_command }}"
remove_orphans: true
remove_volumes: true
state: "{{ item }}"
when: compose_file.changed or gitea_config_file.changed or git_mirror_config_file.changed when: compose_file.changed or gitea_config_file.changed or git_mirror_config_file.changed
loop:
- absent
- present

View file

@ -16,14 +16,9 @@
register: compose_file register: compose_file
become: true become: true
- name: Cycle gotify container
docker_compose: - name: restart gotify
project_src: /opt/gotify shell:
pull: true chdir: /opt/gotify
remove_orphans: true cmd: "{{ docker_update_command }}"
remove_volumes: true
state: "{{ item }}"
when: compose_file.changed when: compose_file.changed
loop:
- absent
- present

View file

@ -16,17 +16,11 @@
register: compose_file register: compose_file
become: true become: true
- name: Cycle jellyfin container - name: restart jellyfin
docker_compose: shell:
project_src: /opt/jellyfin chdir: /opt/jellyfin
pull: true cmd: "{{ docker_update_command }}"
remove_orphans: true
remove_volumes: true
state: "{{ item }}"
when: compose_file.changed when: compose_file.changed
loop:
- absent
- present
- name: Set media permissions - name: Set media permissions
cron: cron:

View file

@ -19,14 +19,8 @@
register: compose_file register: compose_file
become: true become: true
- name: Cycle librespeed container - name: restart librespeed
docker_compose: shell:
project_src: /opt/librespeed chdir: /opt/librespeed
pull: true cmd: "{{ docker_update_command }}"
remove_orphans: true
remove_volumes: true
state: "{{ item }}"
when: compose_file.changed when: compose_file.changed
loop:
- absent
- present

View file

@ -35,14 +35,8 @@
register: config_file register: config_file
become: true become: true
- name: Cycle nextcloud container - name: restart nextcloud
docker_compose: shell:
project_src: /opt/nextcloud chdir: /opt/nextcloud
pull: true cmd: "{{ docker_update_command }}"
remove_orphans: true
remove_volumes: true
state: "{{ item }}"
when: compose_file.changed or config_file.changed when: compose_file.changed or config_file.changed
loop:
- absent
- present

View file

@ -16,14 +16,8 @@
register: compose_file register: compose_file
become: true become: true
- name: Cycle quassel container - name: restart quassel
docker_compose: shell:
project_src: /opt/quassel chdir: /opt/quassel
pull: true cmd: "{{ docker_update_command }}"
remove_orphans: true
remove_volumes: true
state: "{{ item }}"
when: compose_file.changed when: compose_file.changed
loop:
- absent
- present

View file

@ -28,17 +28,11 @@
register: homeserver_config register: homeserver_config
become: true become: true
- name: Cycle synapse container - name: restart synapse
docker_compose: shell:
project_src: /opt/synapse chdir: /opt/synapse
pull: true cmd: "{{ docker_update_command }}"
remove_orphans: true
remove_volumes: true
state: "{{ item }}"
when: compose_file.changed or homeserver_config.changed when: compose_file.changed or homeserver_config.changed
loop:
- absent
- present
- name: Install helper scripts - name: Install helper scripts
git: git:

View file

@ -19,14 +19,8 @@
register: compose_file register: compose_file
become: true become: true
- name: Cycle todoist-github container - name: restart todoist-github
docker_compose: shell:
project_src: /opt/todoist-github chdir: /opt/todoist-github
pull: true cmd: "{{ docker_update_command }}"
remove_orphans: true
remove_volumes: true
state: "{{ item }}"
when: compose_file.changed when: compose_file.changed
loop:
- absent
- present

View file

@ -16,14 +16,8 @@
register: compose_file register: compose_file
become: true become: true
- name: Cycle torrent container - name: restart torrent
docker_compose: shell:
project_src: /opt/torrent chdir: /opt/torrent
pull: true cmd: "{{ docker_update_command }}"
remove_orphans: true
remove_volumes: true
state: "{{ item }}"
when: compose_file.changed when: compose_file.changed
loop:
- absent
- present

View file

@ -32,14 +32,8 @@
register: config_file register: config_file
become: true become: true
- name: Cycle tt-rss container - name: restart tt-rss
docker_compose: shell:
project_src: /opt/tt-rss chdir: /opt/tt-rss
pull: true cmd: "{{ docker_update_command }}"
remove_orphans: true
remove_volumes: true
state: "{{ item }}"
when: compose_file.changed or config_file.changed when: compose_file.changed or config_file.changed
loop:
- absent
- present

View file

@ -19,14 +19,8 @@
register: compose_file register: compose_file
become: true become: true
- name: Cycle wallabag container - name: restart wallabag
docker_compose: shell:
project_src: /opt/wallabag chdir: /opt/wallabag
pull: true cmd: "{{ docker_update_command }}"
remove_orphans: true
remove_volumes: true
state: "{{ item }}"
when: compose_file.changed when: compose_file.changed
loop:
- absent
- present

View file

@ -16,14 +16,8 @@
register: compose_file register: compose_file
become: true become: true
- name: Cycle web-rng container - name: restart web-rng
docker_compose: shell:
project_src: /opt/web-rng chdir: /opt/web-rng
pull: true cmd: "{{ docker_update_command }}"
remove_orphans: true
remove_volumes: true
state: "{{ item }}"
when: compose_file.changed when: compose_file.changed
loop:
- absent
- present

View file

@ -16,14 +16,8 @@
register: compose_file register: compose_file
become: true become: true
- name: Cycle whoami container - name: restart whoami
docker_compose: shell:
project_src: /opt/whoami chdir: /opt/whoami
pull: true cmd: "{{ docker_update_command }}"
remove_orphans: true when: compose_file.changed or config_file.changed
remove_volumes: true
state: "{{ item }}"
when: compose_file.changed
loop:
- absent
- present

View file

@ -0,0 +1,4 @@
- name: restart netdata
shell:
chdir: /opt/netdata
cmd: "{{ docker_update_command }}"

View file

@ -13,17 +13,5 @@
mode: "{{ docker_compose_file_mask }}" mode: "{{ docker_compose_file_mask }}"
owner: "{{ docker_user.name }}" owner: "{{ docker_user.name }}"
validate: /usr/bin/docker-compose -f %s config validate: /usr/bin/docker-compose -f %s config
register: compose_file notify: restart netdata
become: true become: true
- name: Cycle container
docker_compose:
project_src: /opt/netdata
pull: true
remove_orphans: true
remove_volumes: true
state: "{{ item }}"
when: compose_file.changed
loop:
- absent
- present

View file

@ -0,0 +1,4 @@
- name: restart socks proxy
shell:
chdir: /opt/3proxy
cmd: "{{ docker_update_command }}"

View file

@ -16,17 +16,5 @@
mode: "{{ docker_compose_file_mask }}" mode: "{{ docker_compose_file_mask }}"
owner: "{{ docker_user.name }}" owner: "{{ docker_user.name }}"
validate: /usr/bin/docker-compose -f %s config validate: /usr/bin/docker-compose -f %s config
register: compose_file notify: restart socks proxy
become: true become: true
- name: Cycle container
docker_compose:
project_src: /opt/3proxy
pull: true
remove_orphans: true
remove_volumes: true
state: "{{ item }}"
when: compose_file.changed
loop:
- absent
- present

View file

@ -0,0 +1,4 @@
- name: restart statping
shell:
chdir: /opt/statping
cmd: "{{ docker_update_command }}"

View file

@ -13,17 +13,5 @@
mode: "{{ docker_compose_file_mask }}" mode: "{{ docker_compose_file_mask }}"
owner: "{{ docker_user.name }}" owner: "{{ docker_user.name }}"
validate: /usr/bin/docker-compose -f %s config validate: /usr/bin/docker-compose -f %s config
register: compose_file notify: restart statping
become: true become: true
- name: Cycle container
docker_compose:
project_src: /opt/statping
pull: true
remove_orphans: true
remove_volumes: true
state: "{{ item }}"
when: compose_file.changed
loop:
- absent
- present

View file

@ -0,0 +1,4 @@
- name: restart traefik
shell:
chdir: /opt/traefik
cmd: "{{ docker_update_command }}"

View file

@ -20,7 +20,7 @@
mode: "{{ docker_compose_file_mask }}" mode: "{{ docker_compose_file_mask }}"
owner: "{{ docker_user.name }}" owner: "{{ docker_user.name }}"
validate: /usr/bin/docker-compose -f %s config validate: /usr/bin/docker-compose -f %s config
register: compose_file notify: restart traefik
become: true become: true
- name: Install config - name: Install config
@ -29,7 +29,7 @@
dest: /opt/traefik/traefik/traefik.yml dest: /opt/traefik/traefik/traefik.yml
mode: "{{ docker_compose_file_mask }}" mode: "{{ docker_compose_file_mask }}"
owner: "{{ docker_user.name }}" owner: "{{ docker_user.name }}"
register: config_file notify: restart traefik
become: true become: true
- name: Install file provider - name: Install file provider
@ -38,17 +38,5 @@
dest: /opt/traefik/traefik/file-provider.yml dest: /opt/traefik/traefik/file-provider.yml
mode: "{{ docker_compose_file_mask }}" mode: "{{ docker_compose_file_mask }}"
owner: "{{ docker_user.name }}" owner: "{{ docker_user.name }}"
register: file_provider notify: restart traefik
become: true become: true
- name: Cycle container
docker_compose:
project_src: /opt/traefik
pull: true
remove_orphans: true
remove_volumes: true
state: "{{ item }}"
when: compose_file.changed or config_file.changed or file_provider.changed
loop:
- absent
- present

View file

@ -0,0 +1,4 @@
- name: restart upload
shell:
chdir: /opt/upload
cmd: "{{ docker_update_command }}"

View file

@ -16,17 +16,5 @@
mode: "{{ docker_compose_file_mask }}" mode: "{{ docker_compose_file_mask }}"
owner: "{{ docker_user.name }}" owner: "{{ docker_user.name }}"
validate: /usr/bin/docker-compose -f %s config validate: /usr/bin/docker-compose -f %s config
register: compose_file notify: restart upload
become: true become: true
- name: Cycle container
docker_compose:
project_src: /opt/upload
pull: true
remove_orphans: true
remove_volumes: true
state: "{{ item }}"
when: compose_file.changed
loop:
- absent
- present

View file

@ -0,0 +1,4 @@
- name: restart watchtower
shell:
chdir: /opt/watchtower
cmd: "{{ docker_update_command }}"

View file

@ -13,17 +13,5 @@
mode: "{{ docker_compose_file_mask }}" mode: "{{ docker_compose_file_mask }}"
owner: "{{ docker_user.name }}" owner: "{{ docker_user.name }}"
validate: /usr/bin/docker-compose -f %s config validate: /usr/bin/docker-compose -f %s config
register: compose_file notify: restart watchtower
become: true become: true
- name: Cycle container
docker_compose:
project_src: /opt/watchtower
pull: true
remove_orphans: true
remove_volumes: true
state: "{{ item }}"
when: compose_file.changed
loop:
- absent
- present

View file

@ -0,0 +1,4 @@
- name: restart website
shell:
chdir: /opt/website
cmd: "{{ docker_update_command }}"

View file

@ -13,17 +13,5 @@
mode: "{{ docker_compose_file_mask }}" mode: "{{ docker_compose_file_mask }}"
owner: "{{ docker_user.name }}" owner: "{{ docker_user.name }}"
validate: /usr/bin/docker-compose -f %s config validate: /usr/bin/docker-compose -f %s config
register: compose_file notify: restart website
become: true become: true
- name: Cycle container
docker_compose:
project_src: /opt/theorangeone.net
pull: true
remove_orphans: true
remove_volumes: true
state: "{{ item }}"
when: compose_file.changed
loop:
- absent
- present