From d7eea85c4b7be3bce92f6b19ad7a5ec31a3ecaad Mon Sep 17 00:00:00 2001 From: yohan <783b8c87@scimetis.net> Date: Sun, 20 Oct 2024 15:40:09 +0200 Subject: [PATCH] Do not fail when the registry is offline. Fix bug. --- .../tasks/main.yml | 26 ++++++++++--------- roles/role_deploy_cron/tasks/main.yml | 14 +++++----- roles/role_deploy_dovecot/tasks/main.yml | 14 +++++----- roles/role_deploy_feed2imap/tasks/main.yml | 14 +++++----- roles/role_deploy_fetchmail/tasks/main.yml | 14 +++++----- roles/role_deploy_grafana/tasks/main.yml | 12 ++++----- roles/role_deploy_nextcloud/tasks/main.yml | 14 +++++----- roles/role_deploy_onlyoffice/tasks/main.yml | 12 ++++----- .../role_deploy_openvpn-server/tasks/main.yml | 14 +++++----- roles/role_deploy_registry/tasks/main.yml | 12 ++++----- .../tasks/main.yml | 14 +++++----- tasks/deploy_gogs.yml | 12 ++++----- tasks/deploy_mysql-server.yml | 14 +++++----- 13 files changed, 102 insertions(+), 84 deletions(-) diff --git a/roles/role_deploy_SemanticScuttle/tasks/main.yml b/roles/role_deploy_SemanticScuttle/tasks/main.yml index ec82050..14116e6 100644 --- a/roles/role_deploy_SemanticScuttle/tasks/main.yml +++ b/roles/role_deploy_SemanticScuttle/tasks/main.yml @@ -7,16 +7,16 @@ register: result_apache_scuttle_systemd_stop failed_when: "result_apache_scuttle_systemd_stop is failed and 'Could not find the requested service' not in result_apache_scuttle_systemd_stop.msg" -- name: Check if apache-scuttle container exists - containers.podman.podman_container_info: - name: apache-scuttle - register: apache_scuttle_podman_info +- name: Check if apache-scuttle container is running + command: 'podman ps -q --filter "name=apache-scuttle"' + changed_when: false + register: podman_ps become: true -- name: Assert that no apache-scuttle container already exists +- name: Assert that no apache-scuttle container is running ansible.builtin.assert: that: - - apache_scuttle_podman_info.containers | length == 0 + - podman_ps.stdout_lines | length == 0 - name: Stop container service ansible.builtin.systemd: @@ -26,16 +26,16 @@ register: result_php5_fpm_systemd_stop failed_when: "result_php5_fpm_systemd_stop is failed and 'Could not find the requested service' not in result_php5_fpm_systemd_stop.msg" -- name: Check if php5-fpm container exists - containers.podman.podman_container_info: - name: php5-fpm - register: php5_fpm_podman_info +- name: Check if php5-fpm container is running + command: 'podman ps -q --filter "name=php5-fpm"' + changed_when: false + register: podman_ps become: true -- name: Assert that no php5-fpm container already exists +- name: Assert that no php5-fpm container is running ansible.builtin.assert: that: - - php5_fpm_podman_info.containers | length == 0 + - podman_ps.stdout_lines | length == 0 - name: Check if restore from backup is already done stat: @@ -113,6 +113,8 @@ password: "{{ private_registry_password }}" registry: "{{ private_registry_domain }}" changed_when: false + # We ignore failures because the image should be in the cache + failed_when: false become: true - name: Create apache-scuttle container diff --git a/roles/role_deploy_cron/tasks/main.yml b/roles/role_deploy_cron/tasks/main.yml index 2c22228..2e7e57b 100644 --- a/roles/role_deploy_cron/tasks/main.yml +++ b/roles/role_deploy_cron/tasks/main.yml @@ -7,16 +7,16 @@ register: result_global_cron_systemd_stop failed_when: "result_global_cron_systemd_stop is failed and 'Could not find the requested service' not in result_global_cron_systemd_stop.msg" -- name: Check if global-cron container exists - containers.podman.podman_container_info: - name: global-cron - register: global_cron_podman_info +- name: Check if global-cron container is running + command: 'podman ps -q --filter "name=global-cron"' + changed_when: false + register: podman_ps become: true -- name: Assert that no global-cron container already exists +- name: Assert that no global-cron container is running ansible.builtin.assert: that: - - global_cron_podman_info.containers | length == 0 + - podman_ps.stdout_lines | length == 0 - name: Create /usr/local/docker-mounted-files/docker-global-cron-stack directory ansible.builtin.file: @@ -113,6 +113,8 @@ password: "{{ private_registry_password }}" registry: "{{ private_registry_domain }}" changed_when: false + # We ignore failures because the image should be in the cache + failed_when: false become: true - name: Create cron container diff --git a/roles/role_deploy_dovecot/tasks/main.yml b/roles/role_deploy_dovecot/tasks/main.yml index 2c1db70..1ce141f 100644 --- a/roles/role_deploy_dovecot/tasks/main.yml +++ b/roles/role_deploy_dovecot/tasks/main.yml @@ -7,16 +7,16 @@ register: result_dovecot_systemd_stop failed_when: "result_dovecot_systemd_stop is failed and 'Could not find the requested service' not in result_dovecot_systemd_stop.msg" -- name: Check if dovecot container exists - containers.podman.podman_container_info: - name: dovecot - register: dovecot_podman_info +- name: Check if dovecot container is running + command: 'podman ps -q --filter "name=dovecot"' + changed_when: false + register: podman_ps become: true -- name: Assert that no dovecot container already exists +- name: Assert that no dovecot container is running ansible.builtin.assert: that: - - dovecot_podman_info.containers | length == 0 + - podman_ps.stdout_lines | length == 0 - name: Check if restore from backup is already done stat: @@ -171,6 +171,8 @@ password: "{{ private_registry_password }}" registry: "{{ private_registry_domain }}" changed_when: false + # We ignore failures because the image should be in the cache + failed_when: false become: true - name: Create podman networks diff --git a/roles/role_deploy_feed2imap/tasks/main.yml b/roles/role_deploy_feed2imap/tasks/main.yml index d4b4e0b..26801c7 100644 --- a/roles/role_deploy_feed2imap/tasks/main.yml +++ b/roles/role_deploy_feed2imap/tasks/main.yml @@ -7,16 +7,16 @@ register: result_feed2imap_systemd_stop failed_when: "result_feed2imap_systemd_stop is failed and 'Could not find the requested service' not in result_feed2imap_systemd_stop.msg" -- name: Check if feed2imap container exists - containers.podman.podman_container_info: - name: feed2imap - register: feed2imap_podman_info +- name: Check if feed2imap container is running + command: 'podman ps -q --filter "name=feed2imap"' + changed_when: false + register: podman_ps become: true -- name: Assert that no feed2imap container already exists +- name: Assert that no feed2imap container is running ansible.builtin.assert: that: - - feed2imap_podman_info.containers | length == 0 + - podman_ps.stdout_lines | length == 0 - name: Create /usr/local/docker-mounted-files/docker-mail-stack directory ansible.builtin.file: @@ -55,6 +55,8 @@ password: "{{ private_registry_password }}" registry: "{{ private_registry_domain }}" changed_when: false + # We ignore failures because the image should be in the cache + failed_when: false become: true - name: Create podman networks diff --git a/roles/role_deploy_fetchmail/tasks/main.yml b/roles/role_deploy_fetchmail/tasks/main.yml index 24fc6dc..cc078d9 100644 --- a/roles/role_deploy_fetchmail/tasks/main.yml +++ b/roles/role_deploy_fetchmail/tasks/main.yml @@ -12,16 +12,16 @@ register: result_fetchmail_systemd_stop failed_when: "result_fetchmail_systemd_stop is failed and 'Could not find the requested service' not in result_fetchmail_systemd_stop.msg" -- name: Check if fetchmail-{{ fetchmail_instance }} container exists - containers.podman.podman_container_info: - name: "fetchmail-{{ fetchmail_instance }}" - register: fetchmail_podman_info +- name: Check if fetchmail-{{ fetchmail_instance }} container is running + command: 'podman ps -q --filter "name=fetchmail-{{ fetchmail_instance }}"' + changed_when: false + register: podman_ps become: true -- name: Assert that no fetchmail-{{ fetchmail_instance }} container already exists +- name: Assert that no fetchmail-{{ fetchmail_instance }} container is running ansible.builtin.assert: that: - - fetchmail_podman_info.containers | length == 0 + - podman_ps.stdout_lines | length == 0 - name: Create /usr/local/docker-mounted-files/docker-mail-stack directory ansible.builtin.file: @@ -75,6 +75,8 @@ password: "{{ private_registry_password }}" registry: "{{ private_registry_domain }}" changed_when: false + # We ignore failures because the image should be in the cache + failed_when: false become: true - name: Create fetchmail-{{ fetchmail_instance }} container diff --git a/roles/role_deploy_grafana/tasks/main.yml b/roles/role_deploy_grafana/tasks/main.yml index 03f58cf..946b407 100644 --- a/roles/role_deploy_grafana/tasks/main.yml +++ b/roles/role_deploy_grafana/tasks/main.yml @@ -7,16 +7,16 @@ register: result_grafana_systemd_stop failed_when: "result_grafana_systemd_stop is failed and 'Could not find the requested service' not in result_grafana_systemd_stop.msg" -- name: Check if grafana container exists - containers.podman.podman_container_info: - name: grafana - register: grafana_podman_info +- name: Check if grafana container is running + command: 'podman ps -q --filter "name=grafana"' + changed_when: false + register: podman_ps become: true -- name: Assert that no grafana container already exists +- name: Assert that no grafana container is running ansible.builtin.assert: that: - - grafana_podman_info.containers | length == 0 + - podman_ps.stdout_lines | length == 0 - name: Check if restore from backup is already done stat: diff --git a/roles/role_deploy_nextcloud/tasks/main.yml b/roles/role_deploy_nextcloud/tasks/main.yml index 63e8cf7..8d1213b 100644 --- a/roles/role_deploy_nextcloud/tasks/main.yml +++ b/roles/role_deploy_nextcloud/tasks/main.yml @@ -7,16 +7,16 @@ register: result_nextcloud_systemd_stop failed_when: "result_nextcloud_systemd_stop is failed and 'Could not find the requested service' not in result_nextcloud_systemd_stop.msg" -- name: Check if nextcloud container exists - containers.podman.podman_container_info: - name: nextcloud - register: nextcloud_podman_info +- name: Check if nextcloud container is running + command: 'podman ps -q --filter "name=nextcloud"' + changed_when: false + register: podman_ps become: true -- name: Assert that no nextcloud container already exists +- name: Assert that no nextcloud container is running ansible.builtin.assert: that: - - nextcloud_podman_info.containers | length == 0 + - podman_ps.stdout_lines | length == 0 - name: Check if restore from backup is already done stat: @@ -90,6 +90,8 @@ password: "{{ private_registry_password }}" registry: "{{ private_registry_domain }}" changed_when: false + # We ignore failures because the image should be in the cache + failed_when: false become: true - name: Create podman networks diff --git a/roles/role_deploy_onlyoffice/tasks/main.yml b/roles/role_deploy_onlyoffice/tasks/main.yml index eaf06db..591a796 100644 --- a/roles/role_deploy_onlyoffice/tasks/main.yml +++ b/roles/role_deploy_onlyoffice/tasks/main.yml @@ -7,16 +7,16 @@ register: result_onlyoffice_document_server_systemd_stop failed_when: "result_onlyoffice_document_server_systemd_stop is failed and 'Could not find the requested service' not in result_onlyoffice_document_server_systemd_stop.msg" -- name: Check if onlyoffice-document-server container exists - containers.podman.podman_container_info: - name: onlyoffice-document-server - register: onlyoffice_document_server_podman_info +- name: Check if onlyoffice-document-server container is running + command: 'podman ps -q --filter "name=onlyoffice-document-server"' + changed_when: false + register: podman_ps become: true -- name: Assert that no onlyoffice-document-server container already exists +- name: Assert that no onlyoffice-document-server container is running ansible.builtin.assert: that: - - onlyoffice_document_server_podman_info.containers | length == 0 + - podman_ps.stdout_lines | length == 0 - name: Create volume directories ansible.builtin.file: diff --git a/roles/role_deploy_openvpn-server/tasks/main.yml b/roles/role_deploy_openvpn-server/tasks/main.yml index c0f426e..f6c6b51 100644 --- a/roles/role_deploy_openvpn-server/tasks/main.yml +++ b/roles/role_deploy_openvpn-server/tasks/main.yml @@ -7,16 +7,16 @@ register: result_openvpn_server_systemd_stop failed_when: "result_openvpn_server_systemd_stop is failed and 'Could not find the requested service' not in result_openvpn_server_systemd_stop.msg" -- name: Check if openvpn-server container exists - containers.podman.podman_container_info: - name: openvpn-server - register: openvpn_server_podman_info +- name: Check if openvpn-server container is running + command: 'podman ps -q --filter "name=openvpn-server"' + changed_when: false + register: podman_ps become: true -- name: Assert that no openvpn-server container already exists +- name: Assert that no openvpn-server container is running ansible.builtin.assert: that: - - openvpn_server_podman_info.containers | length == 0 + - podman_ps.stdout_lines | length == 0 # Everything in this volume comes from Git. No need to back it up. - name: Create /mnt/volumes/openvpn-server_conf directory @@ -92,6 +92,8 @@ password: "{{ private_registry_password }}" registry: "{{ private_registry_domain }}" changed_when: false + # We ignore failures because the image should be in the cache + failed_when: false become: true - name: Create openvpn-server container diff --git a/roles/role_deploy_registry/tasks/main.yml b/roles/role_deploy_registry/tasks/main.yml index 0d48eef..44b4e49 100644 --- a/roles/role_deploy_registry/tasks/main.yml +++ b/roles/role_deploy_registry/tasks/main.yml @@ -7,16 +7,16 @@ register: result_registry_systemd_stop failed_when: "result_registry_systemd_stop is failed and 'Could not find the requested service' not in result_registry_systemd_stop.msg" -- name: Check if registry container exists - containers.podman.podman_container_info: - name: registry - register: registry_podman_info +- name: Check if registry container is running + command: 'podman ps -q --filter "name=registry"' + changed_when: false + register: podman_ps become: true -- name: Assert that no registry container already exists +- name: Assert that no registry container is running ansible.builtin.assert: that: - - registry_podman_info.containers | length == 0 + - podman_ps.stdout_lines | length == 0 - name: Check if restore from backup is already done stat: diff --git a/roles/role_deploy_store-metrics-in-db/tasks/main.yml b/roles/role_deploy_store-metrics-in-db/tasks/main.yml index 6221c9f..349e40e 100644 --- a/roles/role_deploy_store-metrics-in-db/tasks/main.yml +++ b/roles/role_deploy_store-metrics-in-db/tasks/main.yml @@ -7,16 +7,16 @@ register: result_store_metrics_in_db_systemd_stop failed_when: "result_store_metrics_in_db_systemd_stop is failed and 'Could not find the requested service' not in result_store_metrics_in_db_systemd_stop.msg" -- name: Check if store-metrics-in-db container exists - containers.podman.podman_container_info: - name: store-metrics-in-db - register: store_metrics_in_db_podman_info +- name: Check if store-metrics-in-db container is running + command: 'podman ps -q --filter "name=store-metrics-in-db"' + changed_when: false + register: podman_ps become: true -- name: Assert that no store-metrics-in-db container already exists +- name: Assert that no store-metrics-in-db container is running ansible.builtin.assert: that: - - store_metrics_in_db_podman_info.containers | length == 0 + - podman_ps.stdout_lines | length == 0 - name: Create /usr/local/docker-mounted-files/docker-store-metrics-in-db-stack directory ansible.builtin.file: @@ -39,6 +39,8 @@ password: "{{ private_registry_password }}" registry: "{{ private_registry_domain }}" changed_when: false + # We ignore failures because the image should be in the cache + failed_when: false become: true - name: Create podman networks diff --git a/tasks/deploy_gogs.yml b/tasks/deploy_gogs.yml index 53c2674..bf2b53c 100644 --- a/tasks/deploy_gogs.yml +++ b/tasks/deploy_gogs.yml @@ -7,16 +7,16 @@ register: result_gogs_systemd_stop failed_when: "result_gogs_systemd_stop is failed and 'Could not find the requested service' not in result_gogs_systemd_stop.msg" -- name: Check if gogs container exists - containers.podman.podman_container_info: - name: gogs - register: gogs_podman_info +- name: Check if gogs container is running + command: 'podman ps -q --filter "name=gogs"' + changed_when: false + register: podman_ps become: true -- name: Assert that no gogs container already exists +- name: Assert that no gogs container is running ansible.builtin.assert: that: - - gogs_podman_info.containers | length == 0 + - podman_ps.stdout_lines | length == 0 - name: Check if restore from backup is already done stat: diff --git a/tasks/deploy_mysql-server.yml b/tasks/deploy_mysql-server.yml index a4d5245..9d5439d 100644 --- a/tasks/deploy_mysql-server.yml +++ b/tasks/deploy_mysql-server.yml @@ -7,16 +7,16 @@ register: result_mysql_server_systemd_stop failed_when: "result_mysql_server_systemd_stop is failed and 'Could not find the requested service' not in result_mysql_server_systemd_stop.msg" -- name: Check if mysql-server container exists - containers.podman.podman_container_info: - name: mysql-server - register: mysql_server_podman_info +- name: Check if mysql-server container is running + command: 'podman ps -q --filter "name=mysql-server"' + changed_when: false + register: podman_ps become: true -- name: Assert that no mysql-server container already exists +- name: Assert that no mysql-server container is running ansible.builtin.assert: that: - - mysql_server_podman_info.containers | length == 0 + - podman_ps.stdout_lines | length == 0 - name: Check if restore from backup is already done stat: @@ -37,6 +37,8 @@ password: "{{ private_registry_password }}" registry: "{{ private_registry_domain }}" changed_when: false + # We ignore failures because the image should be in the cache + failed_when: false become: true - name: Create mysql-server container