From 661119e8fd1f226e77bc93c47408613f0973c13b Mon Sep 17 00:00:00 2001 From: Christian Steinle Date: Thu, 24 Apr 2025 11:41:26 +0200 Subject: [PATCH] Use external playbook for minisforum. --- minisforum.yaml | 64 ++----------------------------------------------- 1 file changed, 2 insertions(+), 62 deletions(-) diff --git a/minisforum.yaml b/minisforum.yaml index 52302e9..e48fe75 100644 --- a/minisforum.yaml +++ b/minisforum.yaml @@ -1,9 +1,5 @@ --- -# Version 1.1.0 -# Encrypt passwords with: "ansible-vault encrypt_string" -# Start playbook with: "ansible-playbook -i localhost, -u chsteinle -k playbook-yaml.yml --ask-vault-pass" - - name: Docker backup hosts: all gather_facts: True @@ -14,61 +10,5 @@ - name: Include container variables include_vars: vars/minisforum.yaml - # - name: Display container variables - # ansible.builtin.debug: - # msg: '{{ containers }}' - - - name: Create container backup directories - file: - path: "{{ backup_location }}{{ item.name }}" - state: directory - mode: 0755 - owner: chris - group: chris - loop: "{{ containers }}" - loop_control: - label: "{{ item.name }}" - - - name: Create backup of mysql database and store to backup directory - shell: docker exec {{ item[1].container }} mysqldump -u{{ item[1].user }} -p{{ item[1].pass }} {{ item[1].name }} > {{ backup_location }}{{ item[0].name }}/{{ item[1].container }}-{{ ansible_date_time.iso8601_basic_short }}.sql - when: item[1].type == "mysql" - loop: "{{ containers | subelements('database', skip_missing=True) }}" - loop_control: - label: "{{ item[1].name }}" - - - name: Create backup of postgres database and store to backup directory - ansible.builtin.debug: - msg: - - '{{ item[1] }}' # Database configuration @see: when - - '{{ item[0].name }}' # Container name - when: item[1].type == "psql" - loop: "{{ containers | subelements('database', skip_missing=True) }}" - loop_control: - label: "{{ item[1].name }}" - - - name: Compress all database backup files - shell: gzip {{ backup_location }}{{ item[0].name }}/{{ item[1].container }}-{{ ansible_date_time.iso8601_basic_short }}.sql - loop: "{{ containers | subelements('database', skip_missing=True) }}" - loop_control: - label: "{{ item[1].name }}" - - - name: Create backup of volume and store to backup directory - shell: tar cfz {{ backup_location }}{{ item[0].name }}/{{ item[1] }}-volume-{{ ansible_date_time.iso8601_basic_short }}.tar.gz -C /var/lib/docker/volumes/{{ item[1] }}/ _data - become: yes - become_method: sudo - become_user: root - loop: "{{ containers | subelements('volumes', skip_missing=True) }}" - loop_control: - label: "{{ item[1] }}" - - - name: Change ownership of volume backups - file: - path: "{{ backup_location }}{{ item[0].name }}/{{ item[1] }}-volume-{{ ansible_date_time.iso8601_basic_short }}.tar.gz" - owner: chris - group: chris - become: yes - become_method: sudo - become_user: root - loop: "{{ containers | subelements('volumes', skip_missing=True) }}" - loop_control: - label: "{{ item[1] }}" + - name: Include a play after another play + ansible.builtin.import_playbook: docker-backup.yaml