Solved bugs

This commit is contained in:
Kevin Veen-Birkenbach 2023-11-16 16:40:45 +01:00
parent 8c42d38bca
commit 0cd2b109e4
7 changed files with 27 additions and 37 deletions

View File

@ -3,7 +3,7 @@
hosts: all hosts: all
become: true become: true
roles: roles:
- system-update - update
- name: servers host setup - name: servers host setup
hosts: servers hosts: servers

View File

@ -27,16 +27,17 @@ def print_bash(command):
return output return output
waiting_time=600 waiting_time=600
backup_running=True blocker_running=True
while backup_running: while blocker_running:
try: try:
bash("systemctl is-active --quiet docker-volume-backup.service") bash("systemctl is-active --quiet docker-volume-backup.service")
bash("systemctl is-active --quiet update-docker.service")
print("backup is running.") print("backup is running.")
print("trying again in " + str(waiting_time) + " seconds.") print("trying again in " + str(waiting_time) + " seconds.")
time.sleep(waiting_time) time.sleep(waiting_time)
except: except:
backup_running=False blocker_running=False
print("no backup is running.") print("No blocking service is running.")
unhealthy_container_names=print_bash('docker ps --filter health=unhealthy --format \'{{.Names}}\'') unhealthy_container_names=print_bash('docker ps --filter health=unhealthy --format \'{{.Names}}\'')
exited_container_names=print_bash('docker ps --filter status=exited --format \'{{.Names}}\'') exited_container_names=print_bash('docker ps --filter status=exited --format \'{{.Names}}\'')

View File

@ -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 - name: docker & docker compose install
pacman: pacman:

View File

@ -5,7 +5,7 @@
- name: configure update-docker.service - name: configure update-docker.service
template: template:
src: update-docker.service src: update-docker.service.j2
dest: /etc/systemd/system/update-docker.service dest: /etc/systemd/system/update-docker.service
- name: "reload update-docker.service" - name: "reload update-docker.service"

View File

@ -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 }

View File

@ -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