commit 021606d2d3830dc3bfb184efac29d56acfbed95f Author: Ludovic Cartier Date: Wed Sep 7 17:53:38 2022 +0200 initial commit 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 <