Use tmux. Run mariadb-upgrade. Only skip restore tasks on subsequent runs.

This commit is contained in:
yohan 2024-10-20 10:48:38 +02:00
parent 950666b3e0
commit 7a592f7fa1
11 changed files with 136 additions and 126 deletions

View File

@ -0,0 +1,3 @@
if [[ $- =~ i ]] && [[ -z "$TMUX" ]] && [[ -n "$SSH_TTY" ]]; then
tmux attach-session -t ssh_tmux || tmux new-session -s ssh_tmux
fi

View File

@ -75,6 +75,7 @@
- tcpdump
- net-tools
- bash-completion
- tmux
state: latest
become: true
@ -83,7 +84,6 @@
name:
- ioping
- sysbench
- screen
- atop
- iftop
enablerepo: epel
@ -331,3 +331,12 @@
- name: user.email
value: "{{ git_email }}"
- name: Create /home/{{ LINUX_USERNAME }}/.bashrc.d directory
ansible.builtin.file:
path: "/home/{{ LINUX_USERNAME }}/.bashrc.d"
state: directory
- name: deploy .bashrc.d/tmux
ansible.builtin.copy:
src: tmux
dest: "/home/{{ LINUX_USERNAME }}/.bashrc.d/tmux"

View File

@ -1,8 +1,8 @@
---
- name: Check if install from backup is already done
- name: Check if restore from backup is already done
stat:
path: /mnt/volumes/install_states/scuttle_installed
register: scuttle_installed_flag
path: /mnt/volumes/restore_states/scuttle_restored
register: scuttle_restored_flag
- name: Create php5-fpm network
containers.podman.podman_network:
@ -18,7 +18,7 @@
with_items:
- scuttle_code
- scuttle_php5-fpm_conf
when: not scuttle_installed_flag.stat.exists
when: not scuttle_restored_flag.stat.exists
- name: Create volumes data directories
ansible.builtin.file:
@ -33,7 +33,7 @@
user: 33
- name: scuttle_php5-fpm_conf
user: root
when: not scuttle_installed_flag.stat.exists
when: not scuttle_restored_flag.stat.exists
- name: change ownership of duplicity working directories
ansible.builtin.file:
@ -44,7 +44,7 @@
with_items:
- "{{ DUPLICITY_WORKDIR }}"
- "{{ DUPLICITY_ARCHIVE_DIR }}"
when: not scuttle_installed_flag.stat.exists
when: not scuttle_restored_flag.stat.exists
- name: restore volume backup
ansible.builtin.command:
@ -67,7 +67,7 @@
- scuttle_php5-fpm_conf
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 scuttle_installed_flag.stat.exists
when: not scuttle_restored_flag.stat.exists
- name: Login to {{ private_registry_domain }} and create ${XDG_RUNTIME_DIR}/containers/auth.json
containers.podman.podman_login:
@ -126,19 +126,19 @@
line: "127.0.0.1 scuttle.{{ DOMAIN }} scuttle"
become: true
# A local volume is needed to store install states
- name: Create /mnt/volumes/install_states directory if it does not exist
# A local volume is needed to store restore states
- name: Create /mnt/volumes/restore_states directory if it does not exist
ansible.builtin.file:
path: "/mnt/volumes/install_states"
path: "/mnt/volumes/restore_states"
state: directory
mode: '0755'
become: true
when: not scuttle_installed_flag.stat.exists
when: not scuttle_restored_flag.stat.exists
- name: Create scuttle_installed state file
- name: Create scuttle_restored state file
ansible.builtin.file:
path: "/mnt/volumes/install_states/scuttle_installed"
path: "/mnt/volumes/restore_states/scuttle_restored"
state: touch
mode: '0755'
become: true
when: not scuttle_installed_flag.stat.exists
when: not scuttle_restored_flag.stat.exists

View File

@ -1,8 +1,8 @@
---
- name: Check if install from backup is already done
- name: Check if restore from backup is already done
stat:
path: /mnt/volumes/install_states/dovecot_installed
register: dovecot_installed_flag
path: /mnt/volumes/restore_states/dovecot_restored
register: dovecot_restored_flag
- name: Setup volume
ansible.builtin.include_role:
@ -16,7 +16,7 @@
- name: mail_data_Sylvie
size: 10
vol_type: high-speed
when: not dovecot_installed_flag.stat.exists
when: not dovecot_restored_flag.stat.exists
- name: change ownership of duplicity working directories
ansible.builtin.file:
@ -27,7 +27,7 @@
with_items:
- "{{ DUPLICITY_WORKDIR }}"
- "{{ DUPLICITY_ARCHIVE_DIR }}"
when: not dovecot_installed_flag.stat.exists
when: not dovecot_restored_flag.stat.exists
- name: restore volume backup
ansible.builtin.command:
@ -50,7 +50,7 @@
- mail_data_Sylvie
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 dovecot_installed_flag.stat.exists
when: not dovecot_restored_flag.stat.exists
- name: Create /usr/local/docker-mounted-files/docker-mail-stack/certs directory
ansible.builtin.file:
@ -201,19 +201,19 @@
- imap
- sieve
# A local volume is needed to store install states
- name: Create /mnt/volumes/install_states directory if it does not exist
# A local volume is needed to store restore states
- name: Create /mnt/volumes/restore_states directory if it does not exist
ansible.builtin.file:
path: "/mnt/volumes/install_states"
path: "/mnt/volumes/restore_states"
state: directory
mode: '0755'
become: true
when: not dovecot_installed_flag.stat.exists
when: not dovecot_restored_flag.stat.exists
- name: Create dovecot_installed state file
- name: Create dovecot_restored state file
ansible.builtin.file:
path: "/mnt/volumes/install_states/dovecot_installed"
path: "/mnt/volumes/restore_states/dovecot_restored"
state: touch
mode: '0755'
become: true
when: not dovecot_installed_flag.stat.exists
when: not dovecot_restored_flag.stat.exists

View File

@ -1,8 +1,8 @@
---
- name: Check if install from backup is already done
- name: Check if restore from backup is already done
stat:
path: /mnt/volumes/install_states/grafana_installed
register: grafana_installed_flag
path: /mnt/volumes/restore_states/grafana_restored
register: grafana_restored_flag
- name: Create volumes directories
ansible.builtin.file:
@ -14,7 +14,7 @@
- etc_grafana
- var_lib_grafana
- var_log_grafana
when: not grafana_installed_flag.stat.exists
when: not grafana_restored_flag.stat.exists
- name: Create volumes data directories
ansible.builtin.file:
@ -31,7 +31,7 @@
user: 472
- name: var_log_grafana
user: 472
when: not grafana_installed_flag.stat.exists
when: not grafana_restored_flag.stat.exists
- name: change ownership of duplicity working directories
ansible.builtin.file:
@ -42,7 +42,7 @@
with_items:
- "{{ DUPLICITY_WORKDIR }}"
- "{{ DUPLICITY_ARCHIVE_DIR }}"
when: not grafana_installed_flag.stat.exists
when: not grafana_restored_flag.stat.exists
- name: restore volume backup
ansible.builtin.command:
@ -66,7 +66,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
when: not grafana_restored_flag.stat.exists
- name: Create podman networks
containers.podman.podman_network:
@ -75,7 +75,6 @@
with_items:
- reverse-proxy
- mysqlnet
when: not grafana_installed_flag.stat.exists
- name: Create grafana container
containers.podman.podman_container:
@ -94,7 +93,6 @@
generate_systemd:
path: /etc/systemd/system
become: true
when: not grafana_installed_flag.stat.exists
- name: start/enable container service
ansible.builtin.systemd:
@ -103,28 +101,26 @@
state: started
enabled: true
become: true
when: not grafana_installed_flag.stat.exists
- name: Add cloud.{{ DOMAIN }} to /etc/hosts
ansible.builtin.lineinfile:
path: "/etc/hosts"
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
# A local volume is needed to store restore states
- name: Create /mnt/volumes/restore_states directory if it does not exist
ansible.builtin.file:
path: "/mnt/volumes/install_states"
path: "/mnt/volumes/restore_states"
state: directory
mode: '0755'
become: true
when: not grafana_installed_flag.stat.exists
when: not grafana_restored_flag.stat.exists
- name: Create grafana_installed state file
- name: Create grafana_restored state file
ansible.builtin.file:
path: "/mnt/volumes/install_states/grafana_installed"
path: "/mnt/volumes/restore_states/grafana_restored"
state: touch
mode: '0755'
become: true
when: not grafana_installed_flag.stat.exists
when: not grafana_restored_flag.stat.exists

View File

@ -1,8 +1,8 @@
---
- name: Check if install from backup is already done
- name: Check if restore from backup is already done
stat:
path: /mnt/volumes/install_states/nextcloud_installed
register: nextcloud_installed_flag
path: /mnt/volumes/restore_states/nextcloud_restored
register: nextcloud_restored_flag
- name: Setup volume
ansible.builtin.include_role:
@ -13,7 +13,7 @@
- name: nextcloud
size: 10
vol_type: high-speed
when: not nextcloud_installed_flag.stat.exists
when: not nextcloud_restored_flag.stat.exists
- name: change ownership of duplicity working directories
ansible.builtin.file:
@ -24,7 +24,7 @@
with_items:
- "{{ DUPLICITY_WORKDIR }}"
- "{{ DUPLICITY_ARCHIVE_DIR }}"
when: not nextcloud_installed_flag.stat.exists
when: not nextcloud_restored_flag.stat.exists
- name: restore volume backup
ansible.builtin.command:
@ -46,7 +46,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
when: not nextcloud_restored_flag.stat.exists
- name: Create /usr/local/docker-mounted-files/docker-nextcloud-stack directory
ansible.builtin.file:
@ -54,7 +54,6 @@
state: directory
mode: '0755'
become: true
when: not nextcloud_installed_flag.stat.exists
- name: Deploy custom files
ansible.builtin.copy:
@ -65,7 +64,6 @@
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:
@ -74,7 +72,6 @@
registry: "{{ private_registry_domain }}"
changed_when: false
become: true
when: not nextcloud_installed_flag.stat.exists
- name: Create podman networks
containers.podman.podman_network:
@ -84,7 +81,6 @@
- reverse-proxy
- mysqlnet
- mailnet
when: not nextcloud_installed_flag.stat.exists
- name: Create nextcloud container
containers.podman.podman_container:
@ -102,7 +98,6 @@
generate_systemd:
path: /etc/systemd/system
become: true
when: not nextcloud_installed_flag.stat.exists
- name: start/enable container service
ansible.builtin.systemd:
@ -111,28 +106,26 @@
state: started
enabled: true
become: true
when: not nextcloud_installed_flag.stat.exists
- name: Add cloud.{{ DOMAIN }} to /etc/hosts
ansible.builtin.lineinfile:
path: "/etc/hosts"
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
# A local volume is needed to store restore states
- name: Create /mnt/volumes/restore_states directory if it does not exist
ansible.builtin.file:
path: "/mnt/volumes/install_states"
path: "/mnt/volumes/restore_states"
state: directory
mode: '0755'
become: true
when: not nextcloud_installed_flag.stat.exists
when: not nextcloud_restored_flag.stat.exists
- name: Create nextcloud_installed state file
- name: Create nextcloud_restored state file
ansible.builtin.file:
path: "/mnt/volumes/install_states/nextcloud_installed"
path: "/mnt/volumes/restore_states/nextcloud_restored"
state: touch
mode: '0755'
become: true
when: not nextcloud_installed_flag.stat.exists
when: not nextcloud_restored_flag.stat.exists

View File

@ -1,8 +1,8 @@
---
- name: Check if install from backup is already done
- name: Check if restore from backup is already done
stat:
path: /mnt/volumes/install_states/registry_installed
register: registry_installed_flag
path: /mnt/volumes/restore_states/registry_restored
register: registry_restored_flag
- name: Setup volume
ansible.builtin.include_role:
@ -13,7 +13,7 @@
- name: registry_data
size: 5
vol_type: classic
when: not registry_installed_flag.stat.exists
when: not registry_restored_flag.stat.exists
- name: Create volumes directories
ansible.builtin.file:
@ -24,7 +24,7 @@
with_items:
- registry_auth
- registry_certs
when: not registry_installed_flag.stat.exists
when: not registry_restored_flag.stat.exists
- name: Create volumes data directories
ansible.builtin.file:
@ -39,7 +39,7 @@
user: root
- name: registry_certs
user: root
when: not registry_installed_flag.stat.exists
when: not registry_restored_flag.stat.exists
- name: change ownership of duplicity working directories
ansible.builtin.file:
@ -50,7 +50,7 @@
with_items:
- "{{ DUPLICITY_WORKDIR }}"
- "{{ DUPLICITY_ARCHIVE_DIR }}"
when: not registry_installed_flag.stat.exists
when: not registry_restored_flag.stat.exists
- name: restore volume backup
ansible.builtin.command:
@ -74,7 +74,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
when: not registry_restored_flag.stat.exists
- name: Create podman networks
containers.podman.podman_network:
@ -82,7 +82,6 @@
become: true
with_items:
- reverse-proxy
when: not registry_installed_flag.stat.exists
- name: Create registry container
containers.podman.podman_container:
@ -106,7 +105,6 @@
generate_systemd:
path: /etc/systemd/system
become: true
when: not registry_installed_flag.stat.exists
- name: start/enable container service
ansible.builtin.systemd:
@ -115,28 +113,26 @@
state: started
enabled: true
become: true
when: not registry_installed_flag.stat.exists
- name: Add cloud.{{ DOMAIN }} to /etc/hosts
ansible.builtin.lineinfile:
path: "/etc/hosts"
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
# A local volume is needed to store restore states
- name: Create /mnt/volumes/restore_states directory if it does not exist
ansible.builtin.file:
path: "/mnt/volumes/install_states"
path: "/mnt/volumes/restore_states"
state: directory
mode: '0755'
become: true
when: not registry_installed_flag.stat.exists
when: not registry_restored_flag.stat.exists
- name: Create registry_installed state file
- name: Create registry_restored state file
ansible.builtin.file:
path: "/mnt/volumes/install_states/registry_installed"
path: "/mnt/volumes/restore_states/registry_restored"
state: touch
mode: '0755'
become: true
when: not registry_installed_flag.stat.exists
when: not registry_restored_flag.stat.exists

View File

@ -1,8 +1,8 @@
---
- name: Check if install from backup is already done
- name: Check if restore from backup is already done
stat:
path: /mnt/volumes/install_states/gogs_installed
register: gogs_installed_flag
path: /mnt/volumes/restore_states/gogs_restored
register: gogs_restored_flag
- name: Setup volume
ansible.builtin.include_role:
@ -13,7 +13,7 @@
- name: gogs_data
size: 1
vol_type: classic
when: not gogs_installed_flag.stat.exists
when: not gogs_restored_flag.stat.exists
- name: change ownership of duplicity working directories
ansible.builtin.file:
@ -24,7 +24,7 @@
with_items:
- "{{ DUPLICITY_WORKDIR }}"
- "{{ DUPLICITY_ARCHIVE_DIR }}"
when: not gogs_installed_flag.stat.exists
when: not gogs_restored_flag.stat.exists
- name: restore volume backup
ansible.builtin.command:
@ -46,7 +46,7 @@
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
become: true
when: not gogs_installed_flag.stat.exists
when: not gogs_restored_flag.stat.exists
- name: Create gogs container
containers.podman.podman_container:
@ -63,7 +63,6 @@
generate_systemd:
path: /etc/systemd/system
become: true
when: not gogs_installed_flag.stat.exists
- name: start/enable container service
ansible.builtin.systemd:
@ -72,28 +71,26 @@
state: started
enabled: true
become: true
when: not gogs_installed_flag.stat.exists
- name: Add git.{{ DOMAIN }} to /etc/hosts
ansible.builtin.lineinfile:
path: "/etc/hosts"
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
# A local volume is needed to store restore states
- name: Create /mnt/volumes/restore_states directory if it does not exist
ansible.builtin.file:
path: "/mnt/volumes/install_states"
path: "/mnt/volumes/restore_states"
state: directory
mode: '0755'
become: true
when: not gogs_installed_flag.stat.exists
when: not gogs_restored_flag.stat.exists
- name: Create gogs_installed state file
- name: Create gogs_restored state file
ansible.builtin.file:
path: "/mnt/volumes/install_states/gogs_installed"
path: "/mnt/volumes/restore_states/gogs_restored"
state: touch
mode: '0755'
become: true
when: not gogs_installed_flag.stat.exists
when: not gogs_restored_flag.stat.exists

View File

@ -1,16 +1,16 @@
---
- name: Check if install from backup is already done
- name: Check if restore from backup is already done
stat:
path: /mnt/volumes/install_states/mysql_installed
register: mysql_installed_flag
path: /mnt/volumes/restore_states/mysql_restored
register: mysql_restored_flag
- name: Include tasks/mysql-server_install_from_backup_stage_1.yml
ansible.builtin.include_tasks: "tasks/mysql-server_install_from_backup_stage_1.yml"
when: not mysql_installed_flag.stat.exists
when: not mysql_restored_flag.stat.exists
- name: Include tasks/mysql-server_install_from_backup_stage_2.yml
ansible.builtin.include_tasks: "tasks/mysql-server_install_from_backup_stage_2.yml"
when: not mysql_installed_flag.stat.exists
when: not mysql_restored_flag.stat.exists
- name: Login to {{ private_registry_domain }} and create ${XDG_RUNTIME_DIR}/containers/auth.json
containers.podman.podman_login:
@ -34,6 +34,7 @@
- /usr/local/docker-mounted-files/docker-mysql-server-stack/debian.cnf:/etc/mysql/debian.cnf:z
generate_systemd:
path: /etc/systemd/system
register: create_mysql_container
become: true
- name: start/enable container service
@ -46,4 +47,19 @@
- name: Include tasks/mysql-server_install_from_backup_stage_3.yml
ansible.builtin.include_tasks: "tasks/mysql-server_install_from_backup_stage_3.yml"
when: not mysql_installed_flag.stat.exists
when: not mysql_restored_flag.stat.exists
- name: mariadb-upgrade
containers.podman.podman_container_exec:
name: mysql-server
command: "bash -c 'mariadb-upgrade --force -u root -p{{ mysql_root_ovh1.password }}'"
become: true
when: create_mysql_container is changed
- name: restart mysql-server
ansible.builtin.systemd:
name: container-mysql-server
state: restarted
become: true
when: create_mysql_container is changed

View File

@ -1,8 +1,8 @@
---
- name: Check if install from backup is already done
- name: Check if restore from backup is already done
stat:
path: /mnt/volumes/install_states/reverse-proxy_installed
register: reverse_proxy_installed_flag
path: /mnt/volumes/restore_states/reverse-proxy_restored
register: reverse_proxy_restored_flag
- name: Create reverse-proxy network
containers.podman.podman_network:
@ -30,7 +30,7 @@
- name: duplicity_cache
size: 5
vol_type: high-speed
when: not reverse_proxy_installed_flag.stat.exists
when: not reverse_proxy_restored_flag.stat.exists
- name: change ownership of duplicity working directories
ansible.builtin.file:
@ -41,7 +41,7 @@
with_items:
- "{{ DUPLICITY_WORKDIR }}"
- "{{ DUPLICITY_ARCHIVE_DIR }}"
when: not reverse_proxy_installed_flag.stat.exists
when: not reverse_proxy_restored_flag.stat.exists
- name: restore volume backup
ansible.builtin.command:
@ -64,25 +64,25 @@
- 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
when: not reverse_proxy_restored_flag.stat.exists
become: true
# A local volume is needed to store install states
- name: Create /mnt/volumes/install_states directory if it does not exist
# A local volume is needed to store restore states
- name: Create /mnt/volumes/restore_states directory if it does not exist
ansible.builtin.file:
path: "/mnt/volumes/install_states"
path: "/mnt/volumes/restore_states"
state: directory
mode: '0755'
become: true
when: not reverse_proxy_installed_flag.stat.exists
when: not reverse_proxy_restored_flag.stat.exists
- name: Create reverse-proxy_installed state file
- name: Create reverse-proxy_restored state file
ansible.builtin.file:
path: "/mnt/volumes/install_states/reverse-proxy_installed"
path: "/mnt/volumes/restore_states/reverse-proxy_restored"
state: touch
mode: '0755'
become: true
when: not reverse_proxy_installed_flag.stat.exists
when: not reverse_proxy_restored_flag.stat.exists
- name: Login to {{ private_registry_domain }} and create ${XDG_RUNTIME_DIR}/containers/auth.json
containers.podman.podman_login:

View File

@ -28,7 +28,7 @@
- "{{ MySQL_dump.stdout_lines | last }}"
- "{{ DBs_dump.stdout_lines | last }}"
- name: Restore database
- name: Flush privileges after restore
containers.podman.podman_container_exec:
name: mysql-server
command: 'bash -c ''echo "FLUSH PRIVILEGES;" | mysql -u root -p{{ mysql_root_ovh1.password }}'''
@ -46,17 +46,17 @@
# - "{{ MySQL_dump.stdout_lines | last }}"
# - "{{ DBs_dump.stdout_lines | last }}"
# A local volume is needed to store install states
- name: Create /mnt/volumes/install_states directory if it does not exist
# A local volume is needed to store restore states
- name: Create /mnt/volumes/restore_states directory if it does not exist
ansible.builtin.file:
path: "/mnt/volumes/install_states"
path: "/mnt/volumes/restore_states"
state: directory
mode: '0755'
become: true
- name: Create mysql_installed state file
- name: Create mysql_restored state file
ansible.builtin.file:
path: "/mnt/volumes/install_states/mysql_installed"
path: "/mnt/volumes/restore_states/mysql_restored"
state: touch
mode: '0755'
become: true