From f2abf22b807c374d7a969ae6e5225d4466b3104e Mon Sep 17 00:00:00 2001 From: Markus Pesch Date: Fri, 22 Sep 2023 20:21:13 +0200 Subject: [PATCH] fix: execute separate shell scripts to start and stop renovate --- tasks/main.yml | 11 +++++++++++ templates/etc/systemd/system/renovate.service.j2 | 6 ++---- templates/usr/local/bin/start-renovate.sh.j2 | 7 +++++++ templates/usr/local/bin/stop-renovate.sh.j2 | 10 ++++++++++ 4 files changed, 30 insertions(+), 4 deletions(-) create mode 100644 templates/usr/local/bin/start-renovate.sh.j2 create mode 100644 templates/usr/local/bin/stop-renovate.sh.j2 diff --git a/tasks/main.yml b/tasks/main.yml index f4b7ce8..8eba94e 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -20,6 +20,17 @@ - srv/docker/renovate/docker-compose.yml - srv/docker/renovate/config.json +- name: Create start and stop scripts + ansible.builtin.template: + src: "{{ item }}.j2" + dest: "/{{ item }}" + owner: root + group: docker + mode: "0770" + with_items: + - usr/local/bin/start-renovate.sh + - usr/local/bin/stop-renovate.sh + - name: Create systemd unit files ansible.builtin.template: src: "{{ item }}.j2" diff --git a/templates/etc/systemd/system/renovate.service.j2 b/templates/etc/systemd/system/renovate.service.j2 index 4cb58da..e6a147e 100644 --- a/templates/etc/systemd/system/renovate.service.j2 +++ b/templates/etc/systemd/system/renovate.service.j2 @@ -12,7 +12,5 @@ OnFailure=status-email@%n.service [Service] Type=simple -ExecStart={{ renovate_docker_compose_bin }} up -ExecStop={{ renovate_docker_compose_bin }} down --volumes -ExecPostStop=/bin/rm --recursive --force {{ renovate_cache_dir }} -WorkingDirectory={{ renovate_dir }} \ No newline at end of file +ExecStart=/usr/local/bin/start-renovate.sh +ExecStop=/usr/local/bin/stop-renovate.sh diff --git a/templates/usr/local/bin/start-renovate.sh.j2 b/templates/usr/local/bin/start-renovate.sh.j2 new file mode 100644 index 0000000..c5c31d8 --- /dev/null +++ b/templates/usr/local/bin/start-renovate.sh.j2 @@ -0,0 +1,7 @@ +#!/bin/bash + +# +# {{ ansible_managed }} +# + +{{ renovate_docker_compose_bin }} --project-directory {{ renovate_dir }} up \ No newline at end of file diff --git a/templates/usr/local/bin/stop-renovate.sh.j2 b/templates/usr/local/bin/stop-renovate.sh.j2 new file mode 100644 index 0000000..b1acf26 --- /dev/null +++ b/templates/usr/local/bin/stop-renovate.sh.j2 @@ -0,0 +1,10 @@ +#!/bin/bash + +# +# {{ ansible_managed }} +# + +set -e + +{{ renovate_docker_compose_bin }} --project-directory {{ renovate_dir }} down +rm --force --recursive {{ renovate_cache_dir }} \ No newline at end of file