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

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