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 committed Feb 15, 2018
1 parent 43eec56 commit 23db8ec
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
- name: Enable Postfix
service: name=postfix state=started enabled=yes

- name: Backup configuration
shell: cp /etc/postfix/main.cf /etc/postfix/main.cf.{{ postfix_backup_multiple | ternary("`date -Iseconds`", "backup") }}
when: postfix_backup or postfix_backup_multiple
- name: Backup configuration using copy
copy:
remote_src: yes
src: /etc/postfix/main.cf
dest: /etc/postfix/main.cf.{{ postfix_backup_multiple | ternary( lookup('pipe','date -Iseconds') , "backup") }}

- name: Add header 1 to configuration file
lineinfile:
Expand Down

0 comments on commit 23db8ec

Please sign in to comment.