Skip to content

Commit

Permalink
Modified backup task to use the 'copy' module instead of 'shell' by p…
Browse files Browse the repository at this point in the history
…assing the 'remote_src' option. This helps to enforce a desired state model and reduces ambiguity on success/failure.
  • Loading branch information
kyleabenson authored and spetrosi committed Jun 11, 2024
1 parent ddd75bc commit 7cab93d
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,12 @@
when: __postfix_has_config_changed | d("") is search("True")
block:
- name: Backup configuration
shell: >-
set -euo pipefail;
cp /etc/postfix/main.cf
/etc/postfix/main.cf.{{ postfix_backup_multiple |
ternary("$(date -Iseconds)", "backup") }}
copy:
remote_src: yes
src: /etc/postfix/main.cf
dest: /etc/postfix/main.cf.{{ postfix_backup_multiple |
ternary(lookup('pipe', 'date -Iseconds'), "backup") }}
when: postfix_backup or postfix_backup_multiple
changed_when: true

- name: Ensure Last modified header is absent
lineinfile:
Expand Down

0 comments on commit 7cab93d

Please sign in to comment.