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

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