Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Templated duply scripts #25

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,10 @@ None
* `duply_backup_profiles.key.conf.time_separator`: Enables duplicity `--time-separator` option (**optional**, **deprecated**, set to `true` to enable)
* `duply_backup_profiles.key.conf.short_filenames`: Enables duplicity `--short-filenames` option (**optional**, **deprecated**, set to `true` to enable)
* `duply_backup_profiles.key.conf.dupl_params`: Additional duplicity command line options. Don't forget to leave a separating space char at the end (**optional**)
* `duply_backup_profiles.key.pre`: Pre script (**optional**)
* `duply_backup_profiles.key.post`: Post script (**optional**)
* `duply_backup_profiles.key.pre`: Pre script; if set tpre is ignored (**optional**)
* `duply_backup_profiles.key.post`: Post script; if set tpost is ignored (**optional**)
* `duply_backup_profiles.key.tpre`: Pre script created from Ansible template (**optional**)
* `duply_backup_profiles.key.tpost`: Post script created from Ansible template (**optional**)
* `duply_backup_profiles.key.excludes`: A list of glob patterns of included or excluded files / folders (**optional**)

* `duply_backup_gpg_pub_keys`: [default: `[]`]: Public keys to import
Expand Down
36 changes: 34 additions & 2 deletions tasks/configuration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
path: "{{ duply_backup_profile_directory }}/{{ item.key }}/pre"
state: absent
with_dict: "{{ duply_backup_profiles }}"
when: item.value.pre is not defined or not item.value.pre
when: (item.value.pre is not defined or not item.value.pre) or (item.value.tpre is not defined or not item.value.tpre)
tags:
- duply-backup-configuration-profile-pre

Expand All @@ -45,12 +45,28 @@
tags:
- duply-backup-configuration-profile-pre

- name: template dynamic pre scripts
ansible.builtin.template:
src: "{{ item.value.tpre }}"
dest: "{{ duply_backup_profile_directory }}/{{ item.key }}/pre"
owner: root
group: root
mode: 0700
with_dict: "{{ duply_backup_profiles }}"
when:
- item.value.tpre is defined
- item.value.tpre
# Don't install templated version if static version is defined
- item.value.pre is not defined
tags:
- duply-backup-configuration-profile-pre

- name: remove obsolete post scripts
ansible.builtin.file:
path: "{{ duply_backup_profile_directory }}/{{ item.key }}/post"
state: absent
with_dict: "{{ duply_backup_profiles }}"
when: item.value.post is not defined or not item.value.post
when: (item.value.post is not defined or not item.value.post) or (item.value.tpost is not defined or not item.value.tpost)
tags:
- duply-backup-configuration-profile-post

Expand All @@ -68,6 +84,22 @@
tags:
- duply-backup-configuration-profile-post

- name: template dynamic post scripts
ansible.builtin.template:
src: "{{ item.value.tpost }}"
dest: "{{ duply_backup_profile_directory }}/{{ item.key }}/post"
owner: root
group: root
mode: 0700
with_dict: "{{ duply_backup_profiles }}"
when:
- item.value.tpost is defined
- item.value.tpost
# Don't install templated version if static version is defined
- item.post is not defined
tags:
- duply-backup-configuration-profile-post

- name: configure exclude files
ansible.builtin.template:
src: etc/duply/exclude.j2
Expand Down