Fix: Ensure docker-compose is restarted on docker restart

Previously restarting docker.service (e.g. on an update) caused
docker-compose to be shut down and not being restarted. This caused
services started by docker-compose not to be started and the system to
have no running containers. This fix chains docker-compose directly to
docker and therefore systemd will start docker-compose when docker comes
up again.

Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
Knut Ahlers 2018-01-07 13:02:32 +01:00
parent 7336f24368
commit 3087b329e5
Signed by: luzifer
GPG key ID: DC2729FDD34BE99E

View file

@ -36,6 +36,19 @@
# Install and start services
- name: '[Migration] Check multi-user.target dependency of service'
command: grep -Fxq 'WantedBy=multi-user.target' /etc/systemd/system/docker-compose.service
register: docker_compose_olddep
check_mode: no
ignore_errors: yes
changed_when: no
- name: '[Migration] Disable service still WantedBy=multi-user.target'
systemd:
name: docker-compose.service
enabled: no
when: docker_compose_olddep.rc == 0
- name: Install docker-compose.service
copy:
dest: /etc/systemd/system/docker-compose.service
@ -59,7 +72,7 @@
ExecReload=/usr/local/bin/docker-compose up -d --remove-orphans
[Install]
WantedBy=multi-user.target
WantedBy=docker.service
register: docker_compose_service
- name: Start and enable docker-compose service