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

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