# platform = multi_platform_all
# reboot = false
# strategy = configure
# complexity = low
# disruption = high
- (xccdf-var {{{ MOUNTPOINT }}})

- name: get back mount information associated to mountpoint
  command: findmnt --fstab '{{ {{{ MOUNTPOINT }}} }}'
  register: device_name
  failed_when: device_name.rc > 1
  changed_when: False

- name: create mount_info dictionary variable
  set_fact:
    mount_info: "{{ mount_info|default({})|combine({item.0: item.1}) }}"
  with_together:
    - "{{ device_name.stdout_lines[0].split() | list | lower }}"
    - "{{ device_name.stdout_lines[1].split() | list }}"
  when:
    - device_name.stdout is defined and device_name.stdout_lines is defined
    - (device_name.stdout | length > 0)

- name: Ensure permission {{{ MOUNTOPTION }}} are set on {{{ MOUNTPOINT }}}
  mount:
    path: "{{ {{{ MOUNTPOINT }}} }}"
    src: "{{ mount_info.source }}"
    opts: "{{ mount_info.options }},{{{ MOUNTOPTION }}}"
    state: "mounted"
    fstype: "{{ mount_info.fstype }}"
  when:
    - device_name.stdout is defined
    - (device_name.stdout | length > 0)
