diff --git a/playbook.yml b/playbook.yml index faef7fda..c3b77740 100644 --- a/playbook.yml +++ b/playbook.yml @@ -3,7 +3,7 @@ hosts: all become: true roles: - - system-update + - update - name: servers host setup hosts: servers diff --git a/roles/docker-compose-restart-unhealthy/files/docker-compose-restart-unhealthy.py b/roles/docker-compose-restart-unhealthy/files/docker-compose-restart-unhealthy.py index 7e0dee99..72da53fa 100644 --- a/roles/docker-compose-restart-unhealthy/files/docker-compose-restart-unhealthy.py +++ b/roles/docker-compose-restart-unhealthy/files/docker-compose-restart-unhealthy.py @@ -27,16 +27,17 @@ def print_bash(command): return output waiting_time=600 -backup_running=True -while backup_running: +blocker_running=True +while blocker_running: try: bash("systemctl is-active --quiet docker-volume-backup.service") + bash("systemctl is-active --quiet update-docker.service") print("backup is running.") print("trying again in " + str(waiting_time) + " seconds.") time.sleep(waiting_time) except: - backup_running=False - print("no backup is running.") + blocker_running=False + print("No blocking service is running.") unhealthy_container_names=print_bash('docker ps --filter health=unhealthy --format \'{{.Names}}\'') exited_container_names=print_bash('docker ps --filter status=exited --format \'{{.Names}}\'') diff --git a/roles/docker/tasks/main.yml b/roles/docker/tasks/main.yml index 52cf345c..f5936a39 100644 --- a/roles/docker/tasks/main.yml +++ b/roles/docker/tasks/main.yml @@ -1,25 +1,4 @@ --- -- name: Wait in a loop until the service update-docker.service is inactive - block: - - name: Check the status of update-docker.service - command: systemctl is-active update-docker.service - register: service_status - changed_when: false - failed_when: service_status.stdout == 'active' - - - name: Pause for 60 seconds if the service is still active - pause: - seconds: 60 - when: service_status.stdout == 'active' - become: true - until: service_status.stdout != 'active' - retries: 720 - delay: 10 - -- name: Abort if the service is still active after the maximum attempts - fail: - msg: "The update-docker.service is still active after the maximum number of attempts." - when: service_status.stdout == 'active' and service_status.attempts == 10 - name: docker & docker compose install pacman: diff --git a/roles/update-docker/tasks/main.yml b/roles/update-docker/tasks/main.yml index c026ec86..d57ae178 100644 --- a/roles/update-docker/tasks/main.yml +++ b/roles/update-docker/tasks/main.yml @@ -5,7 +5,7 @@ - name: configure update-docker.service template: - src: update-docker.service + src: update-docker.service.j2 dest: /etc/systemd/system/update-docker.service - name: "reload update-docker.service" diff --git a/roles/update/meta/main.yml b/roles/update/meta/main.yml deleted file mode 100644 index f24730d4..00000000 --- a/roles/update/meta/main.yml +++ /dev/null @@ -1,10 +0,0 @@ -tasks: - - name: "Check if {{path_docker_compose_files}} directory exists" - stat: - path: {{path_docker_compose_files}} - register: docker_compose_directory_stat - -roles: - - { role: update-pacman, when: ansible_distribution == 'Archlinux' } - - { role: update-apt, when: ansible_distribution == "Debian" } - - { role: update-docker, when: docker_compose_directory_stat.stat.exists } \ No newline at end of file diff --git a/roles/update/meta/README.md b/roles/update/tasks/README.md similarity index 100% rename from roles/update/meta/README.md rename to roles/update/tasks/README.md diff --git a/roles/update/tasks/main.yml b/roles/update/tasks/main.yml new file mode 100644 index 00000000..8a6dafc4 --- /dev/null +++ b/roles/update/tasks/main.yml @@ -0,0 +1,20 @@ +--- +- name: "Check if {{ path_docker_compose_files }} directory exists" + stat: + path: "{{ path_docker_compose_files }}" + register: docker_compose_directory_stat + +- name: "Update with pacman" + include_role: + name: update-pacman + when: ansible_distribution == 'Archlinux' and docker_compose_directory_stat.stat.exists + +- name: "Update with apt" + include_role: + name: update-apt + when: ansible_distribution == "Debian" and docker_compose_directory_stat.stat.exists + +- name: "Update Docker Images" + include_role: + name: update-docker + when: docker_compose_directory_stat.stat.exists \ No newline at end of file