Blame SOURCES/scap-security-guide-0.1.58-fix_ansible_banner_remediation-PR_7228.patch

9be3b2
From a9660f01ecd85240df9460f141387dd2874eba82 Mon Sep 17 00:00:00 2001
9be3b2
From: Marcus Burghardt <marcus@mbsec.com.br>
9be3b2
Date: Fri, 9 Jul 2021 16:15:28 +0200
9be3b2
Subject: [PATCH] Bug 1857179 - Improved ansible fix for banner files. Replace
9be3b2
 files only when necessary.
9be3b2
9be3b2
---
9be3b2
 .../banner_etc_issue/ansible/shared.yml              | 12 +++---------
9be3b2
 .../banner_etc_motd/ansible/shared.yml               | 12 +++---------
9be3b2
 2 files changed, 6 insertions(+), 18 deletions(-)
9be3b2
9be3b2
diff --git a/linux_os/guide/system/accounts/accounts-banners/banner_etc_issue/ansible/shared.yml b/linux_os/guide/system/accounts/accounts-banners/banner_etc_issue/ansible/shared.yml
9be3b2
index ff6b6eab42b..4f6d64fd7ac 100644
9be3b2
--- a/linux_os/guide/system/accounts/accounts-banners/banner_etc_issue/ansible/shared.yml
9be3b2
+++ b/linux_os/guide/system/accounts/accounts-banners/banner_etc_issue/ansible/shared.yml
9be3b2
@@ -5,13 +5,7 @@
9be3b2
 # disruption = medium
9be3b2
 {{{ ansible_instantiate_variables("login_banner_text") }}}
9be3b2
 
9be3b2
-- name: "{{{ rule_title }}} - remove incorrect banner"
9be3b2
-  file:
9be3b2
-    state: absent
9be3b2
-    path: /etc/issue
9be3b2
-
9be3b2
-- name: "{{{ rule_title }}} - add correct banner"
9be3b2
-  lineinfile:
9be3b2
+- name: "{{{ rule_title }}} - ensure correct banner"
9be3b2
+  copy:
9be3b2
     dest: /etc/issue
9be3b2
-    line: '{{{ ansible_deregexify_banner_etc_issue("login_banner_text") }}}'
9be3b2
-    create: yes
9be3b2
+    content: '{{{ ansible_deregexify_banner_etc_issue("login_banner_text") }}}'
9be3b2
diff --git a/linux_os/guide/system/accounts/accounts-banners/banner_etc_motd/ansible/shared.yml b/linux_os/guide/system/accounts/accounts-banners/banner_etc_motd/ansible/shared.yml
9be3b2
index 15eb3cc1cbd..2c645889336 100644
9be3b2
--- a/linux_os/guide/system/accounts/accounts-banners/banner_etc_motd/ansible/shared.yml
9be3b2
+++ b/linux_os/guide/system/accounts/accounts-banners/banner_etc_motd/ansible/shared.yml
9be3b2
@@ -5,13 +5,7 @@
9be3b2
 # disruption = medium
9be3b2
 {{{ ansible_instantiate_variables("login_banner_text") }}}
9be3b2
 
9be3b2
-- name: "{{{ rule_title }}} - remove incorrect banner"
9be3b2
-  file:
9be3b2
-    state: absent
9be3b2
-    path: /etc/motd
9be3b2
-
9be3b2
-- name: "{{{ rule_title }}} - add correct banner"
9be3b2
-  lineinfile:
9be3b2
+- name: "{{{ rule_title }}} - ensure correct banner"
9be3b2
+  copy:
9be3b2
     dest: /etc/motd
9be3b2
-    line: '{{{ ansible_deregexify_banner_etc_issue("login_banner_text") }}}'
9be3b2
-    create: yes
9be3b2
+    content: '{{{ ansible_deregexify_banner_etc_issue("login_banner_text") }}}'