# platform = multi_platform_all
# reboot = false
# strategy = configure
# complexity = low
# disruption = high
- name: get back device associated to mountpoint
  shell: mount | grep ' {{{ MOUNTPOINT }}} ' |cut -d ' ' -f 1
  register: device_name
  check_mode: no
  tags:
    @ANSIBLE_TAGS@

- name: get back device previous mount option
  shell: mount | grep ' {{{ MOUNTPOINT }}} ' | sed -re 's:.*\((.*)\):\1:'
  register: device_cur_mountoption
  check_mode: no
  tags:
    @ANSIBLE_TAGS@

- name: get back device fstype
  shell: mount | grep ' {{{ MOUNTPOINT }}} ' | cut -d ' ' -f 5
  register: device_fstype
  check_mode: no
  tags:
    @ANSIBLE_TAGS@

- name: Ensure permission {{{ MOUNTOPTION }}} are set on {{{ MOUNTPOINT }}}
  mount:
    path: "{{{ MOUNTPOINT }}}"
    src: "{{device_name.stdout}}"
    opts: "{{device_cur_mountoption.stdout}},{{{ MOUNTOPTION }}}"
    state: "mounted"
    fstype: "{{device_fstype.stdout}}"
  tags:
    @ANSIBLE_TAGS@

