From 021606d2d3830dc3bfb184efac29d56acfbed95f Mon Sep 17 00:00:00 2001 From: Ludovic Cartier Date: Wed, 7 Sep 2022 17:53:38 +0200 Subject: [PATCH] initial commit --- TODO | 3 ++ defaults/main.yml | 18 +++++++ tasks/duplicity.yml | 101 +++++++++++++++++++++++++++++++++++++ tasks/main.yml | 12 +++++ tasks/requirements.yml | 5 ++ templates/duplicity.cnf.j2 | 3 ++ templates/exclude.list.j2 | 21 ++++++++ 7 files changed, 163 insertions(+) create mode 100644 TODO create mode 100644 defaults/main.yml create mode 100644 tasks/duplicity.yml create mode 100644 tasks/main.yml create mode 100644 tasks/requirements.yml create mode 100644 templates/duplicity.cnf.j2 create mode 100644 templates/exclude.list.j2 diff --git a/TODO b/TODO new file mode 100644 index 0000000..987eccd --- /dev/null +++ b/TODO @@ -0,0 +1,3 @@ +- archive_dir ?? +- passer gpg et l'encryption en defaut +-- duplicity --no-encryption diff --git a/defaults/main.yml b/defaults/main.yml new file mode 100644 index 0000000..f85c227 --- /dev/null +++ b/defaults/main.yml @@ -0,0 +1,18 @@ +--- +# duplicity +duplicity_archive_dir: '/duplicity' + +duplicity_gpg_real_name: 'duplicity' +duplicity_gpg_email: 'backup@localhost' + +duplicity_cron_backup_minute: '0' +duplicity_cron_backup_hour: '3' +duplicity_cron_backup_day: '*' +duplicity_cron_backup_month: '*' +duplicity_cron_backup_weekday: '*' +duplicity_cron_backup_user: 'root' + +duplicity_full_older_than: '6' +duplicity_remove_older_than: '8' + +duplicity_exclude_filelist: '/etc/duplicity/exclude.list' diff --git a/tasks/duplicity.yml b/tasks/duplicity.yml new file mode 100644 index 0000000..88ee765 --- /dev/null +++ b/tasks/duplicity.yml @@ -0,0 +1,101 @@ +--- +- name: duplicity | check vars are defined + assert: + that: + - duplicity_archive_dir is defined + - duplicity_s3_path is defined + - duplicity_s3_passphrase is defined + - duplicity_s3_access_key is defined + - duplicity_s3_secret_key is defined + tags: ['backup_duplicity'] + +- name: duplicity | install packages + apt: + name: + - duplicity + state: present + tags: ['backup_duplicity'] + +- name: duplicity | check for dedicated GPG key + shell: | + gpg --list-options show-only-fpr-mbox --list-secret-keys -a "{{ duplicity_gpg_real_name }}" | awk '{print $1}' + register: duplicity_get_key + tags: ['backup_duplicity'] + +- set_fact: + duplicity_gpg_key: "{{ duplicity_get_key.stdout }}" + when: duplicity_get_key.stdout != '' + tags: ['backup_duplicity'] + +- name: duplicity | generate dedicated GPG key + shell: | + gpg --batch --gen-key <