Stop containers before modifying files.

This commit is contained in:
yohan 2024-10-20 12:16:21 +02:00
parent 4c482c0b76
commit 7a5c71d998
15 changed files with 304 additions and 0 deletions

View File

@ -1,4 +1,42 @@
---
- name: Stop container service
ansible.builtin.systemd:
name: container-apache-scuttle
state: stopped
become: true
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
become: true
- name: Assert that no apache-scuttle container already exists
ansible.builtin.assert:
that:
- apache_scuttle_podman_info.containers | length == 0
- name: Stop container service
ansible.builtin.systemd:
name: container-php5-fpm
state: stopped
become: true
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
become: true
- name: Assert that no php5-fpm container already exists
ansible.builtin.assert:
that:
- php5_fpm_podman_info.containers | length == 0
- name: Check if restore from backup is already done
stat:
path: /mnt/volumes/restore_states/scuttle_restored

View File

@ -1,4 +1,23 @@
---
- name: Stop container service
ansible.builtin.systemd:
name: container-global-cron
state: stopped
become: true
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
become: true
- name: Assert that no global-cron container already exists
ansible.builtin.assert:
that:
- global_cron_podman_info.containers | length == 0
- name: Create /usr/local/docker-mounted-files/docker-global-cron-stack directory
ansible.builtin.file:
path: "/usr/local/docker-mounted-files/docker-global-cron-stack"

View File

@ -1,4 +1,23 @@
---
- name: Stop container service
ansible.builtin.systemd:
name: container-dovecot
state: stopped
become: true
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
become: true
- name: Assert that no dovecot container already exists
ansible.builtin.assert:
that:
- dovecot_podman_info.containers | length == 0
- name: Check if restore from backup is already done
stat:
path: /mnt/volumes/restore_states/dovecot_restored

View File

@ -1,4 +1,23 @@
---
- name: Stop container service
ansible.builtin.systemd:
name: container-feed2imap
state: stopped
become: true
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
become: true
- name: Assert that no feed2imap container already exists
ansible.builtin.assert:
that:
- feed2imap_podman_info.containers | length == 0
- name: Create /usr/local/docker-mounted-files/docker-mail-stack directory
ansible.builtin.file:
path: "/usr/local/docker-mounted-files/docker-mail-stack"

View File

@ -4,6 +4,25 @@
that:
- fetchmail_instance is defined
- name: Stop container service
ansible.builtin.systemd:
name: "container-fetchmail-{{ fetchmail_instance }}"
state: stopped
become: true
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
become: true
- name: Assert that no fetchmail-{{ fetchmail_instance }} container already exists
ansible.builtin.assert:
that:
- fetchmail_podman_info.containers | length == 0
- name: Create /usr/local/docker-mounted-files/docker-mail-stack directory
ansible.builtin.file:
path: "/usr/local/docker-mounted-files/docker-mail-stack"

View File

@ -1,4 +1,23 @@
---
- name: Stop container service
ansible.builtin.systemd:
name: container-grafana
state: stopped
become: true
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
become: true
- name: Assert that no grafana container already exists
ansible.builtin.assert:
that:
- grafana_podman_info.containers | length == 0
- name: Check if restore from backup is already done
stat:
path: /mnt/volumes/restore_states/grafana_restored

View File

@ -1,4 +1,23 @@
---
- name: Stop container service
ansible.builtin.systemd:
name: container-internal_named
state: stopped
become: true
register: result_internal_named_systemd_stop
failed_when: "result_internal_named_systemd_stop is failed and 'Could not find the requested service' not in result_internal_named_systemd_stop.msg"
- name: Check if internal_named container exists
containers.podman.podman_container_info:
name: internal_named
register: internal_named_podman_info
become: true
- name: Assert that no internal_named container already exists
ansible.builtin.assert:
that:
- internal_named_podman_info.containers | length == 0
- name: Create /usr/local/docker-mounted-files/docker-internal_named directory
ansible.builtin.file:
path: "/usr/local/docker-mounted-files/docker-internal_named"

View File

@ -1,4 +1,23 @@
---
- name: Stop container service
ansible.builtin.systemd:
name: container-nextcloud
state: stopped
become: true
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
become: true
- name: Assert that no nextcloud container already exists
ansible.builtin.assert:
that:
- nextcloud_podman_info.containers | length == 0
- name: Check if restore from backup is already done
stat:
path: /mnt/volumes/restore_states/nextcloud_restored

View File

@ -1,4 +1,23 @@
---
- name: Stop container service
ansible.builtin.systemd:
name: container-onlyoffice-document-server
state: stopped
become: true
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
become: true
- name: Assert that no onlyoffice-document-server container already exists
ansible.builtin.assert:
that:
- onlyoffice_document_server_podman_info.containers | length == 0
- name: Create volume directories
ansible.builtin.file:
path: "{{ item }}"

View File

@ -1,4 +1,23 @@
---
- name: Stop container service
ansible.builtin.systemd:
name: container-openvpn-server
state: stopped
become: true
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
become: true
- name: Assert that no openvpn-server container already exists
ansible.builtin.assert:
that:
- openvpn_server_podman_info.containers | length == 0
# Everything in this volume comes from Git. No need to back it up.
- name: Create /mnt/volumes/openvpn-server_conf directory
ansible.builtin.file:

View File

@ -1,4 +1,23 @@
---
- name: Stop container service
ansible.builtin.systemd:
name: container-registry
state: stopped
become: true
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
become: true
- name: Assert that no registry container already exists
ansible.builtin.assert:
that:
- registry_podman_info.containers | length == 0
- name: Check if restore from backup is already done
stat:
path: /mnt/volumes/restore_states/registry_restored

View File

@ -1,4 +1,23 @@
---
- name: Stop container service
ansible.builtin.systemd:
name: container-store-metrics-in-db
state: stopped
become: true
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
become: true
- name: Assert that no store-metrics-in-db container already exists
ansible.builtin.assert:
that:
- store_metrics_in_db_podman_info.containers | length == 0
- name: Create /usr/local/docker-mounted-files/docker-store-metrics-in-db-stack directory
ansible.builtin.file:
path: "/usr/local/docker-mounted-files/docker-store-metrics-in-db-stack"

View File

@ -1,4 +1,23 @@
---
- name: Stop container service
ansible.builtin.systemd:
name: container-gogs
state: stopped
become: true
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
become: true
- name: Assert that no gogs container already exists
ansible.builtin.assert:
that:
- gogs_podman_info.containers | length == 0
- name: Check if restore from backup is already done
stat:
path: /mnt/volumes/restore_states/gogs_restored

View File

@ -1,4 +1,23 @@
---
- name: Stop container service
ansible.builtin.systemd:
name: container-mysql-server
state: stopped
become: true
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
become: true
- name: Assert that no mysql-server container already exists
ansible.builtin.assert:
that:
- mysql_server_podman_info.containers | length == 0
- name: Check if restore from backup is already done
stat:
path: /mnt/volumes/restore_states/mysql_restored

View File

@ -1,4 +1,23 @@
---
- name: Stop container service
ansible.builtin.systemd:
name: container-reverse-proxy
state: stopped
become: true
register: result_reverse_proxy_systemd_stop
failed_when: "result_reverse_proxy_systemd_stop is failed and 'Could not find the requested service' not in result_reverse_proxy_systemd_stop.msg"
- name: Check if reverse-proxy container exists
containers.podman.podman_container_info:
name: reverse-proxy
register: reverse_proxy_podman_info
become: true
- name: Assert that no reverse-proxy container already exists
ansible.builtin.assert:
that:
- reverse_proxy_podman_info.containers | length == 0
- name: Check if restore from backup is already done
stat:
path: /mnt/volumes/restore_states/reverse-proxy_restored