Blame SOURCES/scap-security-guide-0.1.51-fix_ansible_template_mount_options_PR_5765.patch

c862b5
From 254cb60e722539032c6ea73616d6ab51eb1d4edf Mon Sep 17 00:00:00 2001
c862b5
From: Watson Sato <wsato@redhat.com>
c862b5
Date: Fri, 15 May 2020 23:36:18 +0200
c862b5
Subject: [PATCH] Ansible mount_option: split mount and option task
c862b5
c862b5
Separate task that adds mount options mounts the mountpoint into two tasks.
c862b5
Conditioning the "mount" task on the absence of the target mount option
c862b5
caused the task to always be skipped when mount option was alredy present,
c862b5
and could result in the mount point not being mounted.
c862b5
---
c862b5
 shared/templates/template_ANSIBLE_mount_option | 11 ++++++++---
c862b5
 1 file changed, 8 insertions(+), 3 deletions(-)
c862b5
c862b5
diff --git a/shared/templates/template_ANSIBLE_mount_option b/shared/templates/template_ANSIBLE_mount_option
c862b5
index 95bede25f9..a0cf8d6b7a 100644
c862b5
--- a/shared/templates/template_ANSIBLE_mount_option
c862b5
+++ b/shared/templates/template_ANSIBLE_mount_option
c862b5
@@ -26,14 +26,19 @@
c862b5
     - device_name.stdout is defined and device_name.stdout_lines is defined
c862b5
     - (device_name.stdout | length > 0)
c862b5
 
c862b5
-- name: Ensure permission {{{ MOUNTOPTION }}} are set on {{{ MOUNTPOINT }}}
c862b5
+- name: Make sure {{{ MOUNTOPTION }}} option is part of the to {{{ MOUNTPOINT }}} options
c862b5
+  set_fact:
c862b5
+    mount_info: "{{ mount_info | combine( {'options':''~mount_info.options~',{{{ MOUNTOPTION }}}' }) }}"
c862b5
+  when:
c862b5
+    - mount_info is defined and "{{{ MOUNTOPTION }}}" not in mount_info.options
c862b5
+
c862b5
+- name: Ensure {{{ MOUNTPOINT }}} is mounted with {{{ MOUNTOPTION }}} option
c862b5
   mount:
c862b5
     path: "{{{ MOUNTPOINT }}}"
c862b5
     src: "{{ mount_info.source }}"
c862b5
-    opts: "{{ mount_info.options }},{{{ MOUNTOPTION }}}"
c862b5
+    opts: "{{ mount_info.options }}"
c862b5
     state: "mounted"
c862b5
     fstype: "{{ mount_info.fstype }}"
c862b5
   when:
c862b5
-    - mount_info is defined and "{{{ MOUNTOPTION }}}" not in mount_info.options
c862b5
     - device_name.stdout is defined
c862b5
     - (device_name.stdout | length > 0)