I tried using both mount and stat modules. Both did not meet your requirements.
I only managed to work with the OS command. I tested the Redhat, Debian, and SLES families.
vars: - myvolume: /backup tasks: - command: mountpoint -q {{myvolume}} register: volume_stat failed_when: False changed_when: False - debug: msg: "This is a mountpoint!" when: volume_stat.rc == 0
The problem is that the mountpoint command generates stderr if the path is not a mount point, so you should use ignore_errors , because this is not a good solution.
EDIT 1 : @udondan is mentioned, failed_when is the best approach, then ignore_errors , since it does not output errors.
This may be what you want if you need to stop the game if the path is not a mount point.
I hope someone finds a better solution than this.
NOTE There are some platforms that do not have the mountpoint command, as far as I know Darwin (Mac OSX) and SunOS (Oracle Solaris), if you need these systems to work, you need to find another workaround.
source share