From d937e8cd7a5cb959e540ebdc7368027ace8381b1 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 | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/tasks/main.yml b/tasks/main.yml index 2b1fd56..cddcbeb 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -106,13 +106,11 @@ 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: