From c124a1313f3b550c439c6f86bbf845d1aca51351 Mon Sep 17 00:00:00 2001 From: MIchael Haehnel Date: Wed, 3 Apr 2024 15:59:37 +0200 Subject: [PATCH] Improve Harbor container restart after machine reboot with docker_compose_v2 --- patchday.yml | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/patchday.yml b/patchday.yml index fe1702b..b07f890 100644 --- a/patchday.yml +++ b/patchday.yml @@ -59,29 +59,30 @@ your automation-bofh -- hosts: harbor +- name: "Harbor" + hosts: harbor serial: 1 - become: yes + become: true tasks: - name: "Smardigo Patchday: update pkgs" ansible.builtin.apt: - upgrade: yes - update_cache: yes - autoremove: yes - autoclean: yes + upgrade: true + update_cache: true + autoremove: true + autoclean: true - name: "Smardigo Patchday: find docker_compose.yml files" ansible.builtin.find: paths: "{{ service_base_path }}" pattern: 'docker*.yml' - recurse: yes + recurse: true register: docker_compose_services - name: "Smardigo Patchday: shutdown services" - community.docker.docker_compose: + community.docker.docker_compose_v2: project_src: "{{ item | dirname }}" state: absent - loop: "{{ docker_compose_services.files | map(attribute='path') | select('match', '.*/'+stage+'-.*') }}" + loop: "{{ docker_compose_services.files | map(attribute='path') | select('match', '.*/' + stage + '-.*') }}" - name: "Smardigo Patchday: rebooting <{{ inventory_hostname }}>" ansible.builtin.reboot: @@ -89,7 +90,7 @@ reboot_timeout: 300 - name: "Smardigo Patchday: wait_for host after reboot" - become: no + become: false delegate_to: localhost ansible.builtin.wait_for: delay: 15 @@ -99,7 +100,7 @@ search_regex: OpenSSH - name: "Smardigo Patchday: start services" - community.docker.docker_compose: + community.docker.docker_compose_v2: project_src: "{{ item | dirname }}" state: present loop: "{{ docker_compose_services.files | map(attribute='path') }}"