From 23db8ec41073d7c2138486e4456dc17b7970716e Mon Sep 17 00:00:00 2001 From: Kyle Benson Date: Thu, 15 Feb 2018 15:29:38 -0500 Subject: [PATCH] Modified backup task to use the 'copy' module instead of 'shell' by passing the 'remote_src' option. This helps to enforce a desired state model and reduces ambiguity on success/failure. --- tasks/main.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tasks/main.yml b/tasks/main.yml index b7877a3..64dd533 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -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: