Skip restore when already done. Use 127.0.0.1 for services in /etc/hosts.

This commit is contained in:
yohan 2024-03-30 12:03:53 +01:00
parent 96b1c4ce9f
commit a5776cad20
5 changed files with 153 additions and 5 deletions

View File

@ -1,4 +1,9 @@
---
- name: Check if install from backup is already done
stat:
path: /mnt/volumes/install_states/grafana_installed
register: grafana_installed_flag
- name: Create volumes directories
ansible.builtin.file:
path: "/mnt/volumes/{{ item }}"
@ -9,6 +14,7 @@
- etc_grafana
- var_lib_grafana
- var_log_grafana
when: not grafana_installed_flag.stat.exists
- name: Create volumes data directories
ansible.builtin.file:
@ -25,6 +31,7 @@
user: 472
- name: var_log_grafana
user: 472
when: not grafana_installed_flag.stat.exists
- name: change ownership of duplicity working directories
ansible.builtin.file:
@ -35,6 +42,7 @@
with_items:
- "{{ DUPLICITY_WORKDIR }}"
- "{{ DUPLICITY_ARCHIVE_DIR }}"
when: not grafana_installed_flag.stat.exists
- name: restore volume backup
ansible.builtin.command:
@ -57,6 +65,7 @@
- var_log_grafana
failed_when: duplicity_result is failed and (duplicity_result.rc is not defined or duplicity_result.rc != 11)
changed_when: duplicity_result.rc is defined and duplicity_result.rc == 0
when: not grafana_installed_flag.stat.exists
- name: Unarchive volume backup
ansible.builtin.command:
@ -66,6 +75,7 @@
- etc_grafana
- var_lib_grafana
- var_log_grafana
when: not grafana_installed_flag.stat.exists
- name: Create podman networks
containers.podman.podman_network:
@ -74,6 +84,7 @@
with_items:
- reverse-proxy
- mysqlnet
when: not grafana_installed_flag.stat.exists
- name: Create grafana container
containers.podman.podman_container:
@ -89,9 +100,28 @@
- /mnt/volumes/etc_grafana/data:/etc/grafana:Z
- /mnt/volumes/var_log_grafana/data:/var/log/grafana:Z
become: true
when: not grafana_installed_flag.stat.exists
- name: Add cloud.{{ DOMAIN }} to /etc/hosts
ansible.builtin.lineinfile:
path: "/etc/hosts"
line: "{{ ansible_host }} grafana.{{ DOMAIN }} grafana"
line: "127.0.0.1 grafana.{{ DOMAIN }} grafana"
become: true
when: not grafana_installed_flag.stat.exists
# A local volume is needed to store install states
- name: Create /mnt/volumes/install_states directory if it does not exist
ansible.builtin.file:
path: "/mnt/volumes/install_states"
state: directory
mode: '0755'
become: true
when: not grafana_installed_flag.stat.exists
- name: Create grafana_installed state file
ansible.builtin.file:
path: "/mnt/volumes/install_states/grafana_installed"
state: touch
mode: '0755'
become: true
when: not grafana_installed_flag.stat.exists

View File

@ -1,4 +1,9 @@
---
- name: Check if install from backup is already done
stat:
path: /mnt/volumes/install_states/nextcloud_installed
register: nextcloud_installed_flag
- name: Setup volume
ansible.builtin.include_role:
name: role_setup_volume
@ -8,6 +13,7 @@
- name: nextcloud
size: 10
vol_type: high-speed
when: not nextcloud_installed_flag.stat.exists
- name: change ownership of duplicity working directories
ansible.builtin.file:
@ -18,6 +24,7 @@
with_items:
- "{{ DUPLICITY_WORKDIR }}"
- "{{ DUPLICITY_ARCHIVE_DIR }}"
when: not nextcloud_installed_flag.stat.exists
- name: restore volume backup
ansible.builtin.command:
@ -38,6 +45,7 @@
- nextcloud
failed_when: duplicity_result is failed and (duplicity_result.rc is not defined or duplicity_result.rc != 11)
changed_when: duplicity_result.rc is defined and duplicity_result.rc == 0
when: not nextcloud_installed_flag.stat.exists
- name: Unarchive volume backup
ansible.builtin.command:
@ -45,6 +53,7 @@
become: true
with_items:
- nextcloud
when: not nextcloud_installed_flag.stat.exists
- name: Create /usr/local/docker-mounted-files/docker-nextcloud-stack directory
ansible.builtin.file:
@ -52,6 +61,7 @@
state: directory
mode: '0755'
become: true
when: not nextcloud_installed_flag.stat.exists
- name: Deploy custom files
ansible.builtin.copy:
@ -62,6 +72,7 @@
with_items:
- supervisord.conf
- run_elasticsearch.sh
when: not nextcloud_installed_flag.stat.exists
- name: Login to {{ private_registry_domain }} and create ${XDG_RUNTIME_DIR}/containers/auth.json
containers.podman.podman_login:
@ -69,6 +80,7 @@
password: "{{ private_registry_password }}"
registry: "{{ private_registry_domain }}"
become: true
when: not nextcloud_installed_flag.stat.exists
- name: Create podman networks
containers.podman.podman_network:
@ -78,6 +90,7 @@
- reverse-proxy
- mysqlnet
- mailnet
when: not nextcloud_installed_flag.stat.exists
- name: Create nextcloud container
containers.podman.podman_container:
@ -92,9 +105,28 @@
- /usr/local/docker-mounted-files/docker-nextcloud-stack/supervisord.conf:/supervisord.conf:z
- /usr/local/docker-mounted-files/docker-nextcloud-stack/run_elasticsearch.sh:/run_elasticsearch.sh:z
become: true
when: not nextcloud_installed_flag.stat.exists
- name: Add cloud.{{ DOMAIN }} to /etc/hosts
ansible.builtin.lineinfile:
path: "/etc/hosts"
line: "{{ ansible_host }} cloud.{{ DOMAIN }} cloud"
line: "127.0.0.1 cloud.{{ DOMAIN }} cloud"
become: true
when: not nextcloud_installed_flag.stat.exists
# A local volume is needed to store install states
- name: Create /mnt/volumes/install_states directory if it does not exist
ansible.builtin.file:
path: "/mnt/volumes/install_states"
state: directory
mode: '0755'
become: true
when: not nextcloud_installed_flag.stat.exists
- name: Create nextcloud_installed state file
ansible.builtin.file:
path: "/mnt/volumes/install_states/nextcloud_installed"
state: touch
mode: '0755'
become: true
when: not nextcloud_installed_flag.stat.exists

View File

@ -1,4 +1,9 @@
---
- name: Check if install from backup is already done
stat:
path: /mnt/volumes/install_states/registry_installed
register: registry_installed_flag
- name: Setup volume
ansible.builtin.include_role:
name: role_setup_volume
@ -8,6 +13,7 @@
- name: registry_data
size: 5
vol_type: classic
when: not registry_installed_flag.stat.exists
- name: Create volumes directories
ansible.builtin.file:
@ -18,6 +24,7 @@
with_items:
- registry_auth
- registry_certs
when: not registry_installed_flag.stat.exists
- name: Create volumes data directories
ansible.builtin.file:
@ -32,6 +39,7 @@
user: root
- name: registry_certs
user: root
when: not registry_installed_flag.stat.exists
- name: change ownership of duplicity working directories
ansible.builtin.file:
@ -42,6 +50,7 @@
with_items:
- "{{ DUPLICITY_WORKDIR }}"
- "{{ DUPLICITY_ARCHIVE_DIR }}"
when: not registry_installed_flag.stat.exists
- name: restore volume backup
ansible.builtin.command:
@ -64,6 +73,7 @@
- registry_certs
failed_when: duplicity_result is failed and (duplicity_result.rc is not defined or duplicity_result.rc != 11)
changed_when: duplicity_result.rc is defined and duplicity_result.rc == 0
when: not registry_installed_flag.stat.exists
- name: Unarchive volume backup
ansible.builtin.command:
@ -73,6 +83,7 @@
- registry_data
- registry_auth
- registry_certs
when: not registry_installed_flag.stat.exists
- name: Create podman networks
containers.podman.podman_network:
@ -80,6 +91,7 @@
become: true
with_items:
- reverse-proxy
when: not registry_installed_flag.stat.exists
- name: Create registry container
containers.podman.podman_container:
@ -100,9 +112,28 @@
REGISTRY_AUTH_HTPASSWD_PATH: /auth/htpasswd
REGISTRY_AUTH_HTPASSWD_REALM: Registry Realm
become: true
when: not registry_installed_flag.stat.exists
- name: Add cloud.{{ DOMAIN }} to /etc/hosts
ansible.builtin.lineinfile:
path: "/etc/hosts"
line: "{{ ansible_host }} registry.{{ DOMAIN }} registry"
line: "127.0.0.1 registry.{{ DOMAIN }} registry"
become: true
when: not registry_installed_flag.stat.exists
# A local volume is needed to store install states
- name: Create /mnt/volumes/install_states directory if it does not exist
ansible.builtin.file:
path: "/mnt/volumes/install_states"
state: directory
mode: '0755'
become: true
when: not registry_installed_flag.stat.exists
- name: Create registry_installed state file
ansible.builtin.file:
path: "/mnt/volumes/install_states/registry_installed"
state: touch
mode: '0755'
become: true
when: not registry_installed_flag.stat.exists

View File

@ -1,4 +1,9 @@
---
- name: Check if install from backup is already done
stat:
path: /mnt/volumes/install_states/gogs_installed
register: gogs_installed_flag
- name: Setup volume
ansible.builtin.include_role:
name: role_setup_volume
@ -8,6 +13,7 @@
- name: gogs_data
size: 1
vol_type: classic
when: not gogs_installed_flag.stat.exists
- name: change ownership of duplicity working directories
ansible.builtin.file:
@ -18,6 +24,7 @@
with_items:
- "{{ DUPLICITY_WORKDIR }}"
- "{{ DUPLICITY_ARCHIVE_DIR }}"
when: not gogs_installed_flag.stat.exists
- name: restore volume backup
ansible.builtin.command:
@ -38,6 +45,7 @@
- gogs_data
failed_when: duplicity_result is failed and (duplicity_result.rc is not defined or duplicity_result.rc != 11)
changed_when: duplicity_result.rc is defined and duplicity_result.rc == 0
when: not gogs_installed_flag.stat.exists
- name: Unarchive volume backup
ansible.builtin.command:
@ -45,6 +53,7 @@
become: true
with_items:
- gogs_data
when: not gogs_installed_flag.stat.exists
- name: Create gogs container
containers.podman.podman_container:
@ -58,9 +67,28 @@
volume:
- /mnt/volumes/gogs_data/data:/data:Z
become: true
when: not gogs_installed_flag.stat.exists
- name: Add git.{{ DOMAIN }} to /etc/hosts
ansible.builtin.lineinfile:
path: "/etc/hosts"
line: "{{ ansible_host }} git.{{ DOMAIN }} git"
line: "127.0.0.1 git.{{ DOMAIN }} git"
become: true
when: not gogs_installed_flag.stat.exists
# A local volume is needed to store install states
- name: Create /mnt/volumes/install_states directory if it does not exist
ansible.builtin.file:
path: "/mnt/volumes/install_states"
state: directory
mode: '0755'
become: true
when: not gogs_installed_flag.stat.exists
- name: Create gogs_installed state file
ansible.builtin.file:
path: "/mnt/volumes/install_states/gogs_installed"
state: touch
mode: '0755'
become: true
when: not gogs_installed_flag.stat.exists

View File

@ -1,9 +1,14 @@
---
# tasks file for role_deploy_reverse-proxy
- name: Check if install from backup is already done
stat:
path: /mnt/volumes/install_states/reverse-proxy_installed
register: reverse_proxy_installed_flag
- name: Create reverse-proxy network
containers.podman.podman_network:
name: reverse-proxy
become: true
when: not reverse_proxy_installed_flag.stat.exists
- name: Setup volume
ansible.builtin.include_role:
@ -26,6 +31,7 @@
- name: duplicity_cache
size: 5
vol_type: high-speed
when: not reverse_proxy_installed_flag.stat.exists
- name: change ownership of duplicity working directories
ansible.builtin.file:
@ -36,6 +42,7 @@
with_items:
- "{{ DUPLICITY_WORKDIR }}"
- "{{ DUPLICITY_ARCHIVE_DIR }}"
when: not reverse_proxy_installed_flag.stat.exists
- name: restore volume backup
ansible.builtin.command:
@ -58,6 +65,7 @@
- reverse-proxy_letsencrypt
failed_when: duplicity_result is failed and (duplicity_result.rc is not defined or duplicity_result.rc != 11)
changed_when: duplicity_result.rc is defined and duplicity_result.rc == 0
when: not reverse_proxy_installed_flag.stat.exists
- name: Unarchive volume backup
ansible.builtin.command:
@ -67,6 +75,24 @@
- reverse-proxy_conf
- reverse-proxy_conf_enabled
- reverse-proxy_letsencrypt
when: not reverse_proxy_installed_flag.stat.exists
# A local volume is needed to store install states
- name: Create /mnt/volumes/install_states directory if it does not exist
ansible.builtin.file:
path: "/mnt/volumes/install_states"
state: directory
mode: '0755'
become: true
when: not reverse_proxy_installed_flag.stat.exists
- name: Create reverse-proxy_installed state file
ansible.builtin.file:
path: "/mnt/volumes/install_states/reverse-proxy_installed"
state: touch
mode: '0755'
become: true
when: not reverse_proxy_installed_flag.stat.exists
- name: Get docker-reverse-proxy repo's last commit
ansible.builtin.git:
@ -108,3 +134,4 @@
- /mnt/volumes/reverse-proxy_conf_enabled/data:/etc/apache2/sites-enabled:Z
- /mnt/volumes/reverse-proxy_letsencrypt/data:/etc/letsencrypt:Z
become: true