From 118dcf0f78d7129cd5e1b06bec9dae6ac125a02d Mon Sep 17 00:00:00 2001 From: yohan <783b8c87@scimetis.net> Date: Sun, 22 Oct 2023 16:00:58 +0200 Subject: [PATCH] Fix syntax error and refactor. --- tasks/backup_ovh1.yml | 11 ----------- tasks/bootstrap.yml | 16 ---------------- tasks/start.yml | 17 ++++++++++------- 3 files changed, 10 insertions(+), 34 deletions(-) diff --git a/tasks/backup_ovh1.yml b/tasks/backup_ovh1.yml index 8df339f..5293215 100755 --- a/tasks/backup_ovh1.yml +++ b/tasks/backup_ovh1.yml @@ -7,11 +7,6 @@ ansible.builtin.include_tasks: "tasks/assert_var_not_empty.yml" with_items: "{{ BACKUP_OVH1_REQUIRED_VARS }}" -- name: Create backup directory - ansible.builtin.file: - path: "{{ WORKDIR }}/backup" - state: directory - - name: Archive volumes ansible.builtin.command: "tar -czf {{ WORKDIR }}/backup/{{ item }}.tar.gz -C /mnt/volumes {{ item }}" with_items: "{{ BACKUP_OVH1_VOLUMES }}" @@ -28,12 +23,6 @@ ansible.builtin.command: "tar -czf {{ WORKDIR }}/backup/mysql-server_dumps.tar.gz -C /mnt/volumes {{ MySQL_dump.stdout_lines | last }} {{ DBs_dump.stdout_lines | last }}" with_items: "{{ BACKUP_OVH1_VOLUMES }}" -thon3-swiftclient is a requirement of duplicity -- name: Install python3-swiftclient - ansible.builtin.package: - name: python3-swiftclient - state: present - - name: Backup with duplicity ansible.builtin.command: "duplicity --num-retries 3 --full-if-older-than 1M --progress --archive-dir {{ ARCHIVE_DIR }} --name {{ lookup('env','BACKUP_WORKFLOW') }} --allow-source-mismatch '{{ WORKDIR }}/backup' swift://{{ lookup('env','BACKUP_WORKFLOW') }}" environment: "{{ DUPLICITY_ENVIRONMENT }}" diff --git a/tasks/bootstrap.yml b/tasks/bootstrap.yml index 30fb74a..1a5398f 100755 --- a/tasks/bootstrap.yml +++ b/tasks/bootstrap.yml @@ -12,11 +12,6 @@ url: "https://{{ CLOUD_SERVER }}/s/{{ lookup('env','KEY') }}/download?path=%2F&files=secrets.tar.gz.enc" dest: "{{ WORKDIR }}/secrets.tar.gz.enc" -- name: Install openssh-client - ansible.builtin.package: - name: openssh-client - state: present - - name: Create /root/.ssh directory ansible.builtin.file: path: /root/.ssh @@ -99,11 +94,6 @@ dest: "{{ WORKDIR }}/{{ item }}" with_items: "{{ BOOTSTRAP_REPOS }}" -- name: Create backup directory - ansible.builtin.file: - path: "{{ WORKDIR }}/backup" - state: directory - - name: Archive Git repository ansible.builtin.command: "tar -czf {{ WORKDIR }}/backup/{{ item }}.tar.gz -C {{ WORKDIR }} {{ item }}" with_items: "{{ BOOTSTRAP_REPOS }}" @@ -113,12 +103,6 @@ src: "{{ WORKDIR }}/secrets.tar.gz.enc" dest: "{{ WORKDIR }}/backup/secrets.tar.gz.enc" -thon3-swiftclient is a requirement of duplicity -- name: Install python3-swiftclient - ansible.builtin.package: - name: python3-swiftclient - state: present - - name: Backup with duplicity ansible.builtin.command: "duplicity --num-retries 3 --full-if-older-than 1M --progress --archive-dir {{ ARCHIVE_DIR }} --name {{ lookup('env','BACKUP_WORKFLOW') }} --allow-source-mismatch '{{ WORKDIR }}/backup' swift://{{ lookup('env','BACKUP_WORKFLOW') }}" environment: "{{ DUPLICITY_ENVIRONMENT }}" diff --git a/tasks/start.yml b/tasks/start.yml index bfe6007..a68c526 100755 --- a/tasks/start.yml +++ b/tasks/start.yml @@ -8,9 +8,13 @@ url: "https://{{ CLOUD_SERVER }}/s/{{ lookup('env','KEY') }}/download?path=%2F&files=secrets.tar.gz.enc" dest: /root/secrets.tar.gz.enc -- name: Install openssh-client +# python3-swiftclient is a requirement of duplicity +- name: Install package requirements ansible.builtin.package: - name: openssh-client + name: + - git + - python3-swiftclient + - openssh-client state: present - name: Create /root/.ssh directory @@ -114,11 +118,6 @@ - name: duplicity_cache size: 5 -- name: Install git - ansible.builtin.package: - name: git - state: present - - name: Install jsondiff from pip ansible.builtin.pip: name: jsondiff @@ -126,3 +125,7 @@ delegate_to: 172.17.0.1 become: true +- name: Create backup directory + ansible.builtin.file: + path: "{{ WORKDIR }}/backup" + state: directory