Skip to content

Commit

Permalink
Templated pre and post run scripts
Browse files Browse the repository at this point in the history
Allows one to configure 'tpre' and 'tpost' values which allow for dynamic
script creation.
No templates are provided since they're likely to be closely tied to the
related inventory.

Implementation for question in
First draft for Oefenweb#24
  • Loading branch information
goetzk committed Sep 19, 2023
1 parent 8f8b1b2 commit c718627
Showing 1 changed file with 34 additions and 2 deletions.
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 }}.j2"
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 }}.j2"
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

0 comments on commit c718627

Please sign in to comment.