Ununtu 16.04 and 18.04 (same problem on both)
I am trying to use sshfs to mount a directory on another system, it works fine from the command line but when I execute the same command from a puppet "exec" it appears to succeed but the mount point is not usable:
rful011@secmonprd10:~$ ls -l ~sensors/Rules/ ls: cannot access '/home/sensors/Rules/source': Permission denied total 4 drwxr-xr-x 2 sensors sensors 4096 Jun 5 13:03 raw lrwxrwxrwx 1 sensors sensors 33 Aug 21 12:32 sensor -> /usr/local/var/lib/suricata/rules d????????? ? ? ? ? ? source
where "source" is the directory in question
The command used to mount it is:
sshfs -o idmap=user sensors@<host>:Rules/raw /home/sensors/Rules/source
Puppet says the exec succeeded and I can't find anything in the logs to contradict this.
I wonder if sshfs is exepecting some environment vars set?
puppet code:
exec{"rule-source-share": command => "sshfs -o idmap=user sensors@<host>:Rules/raw /home/sensors/Rules/source", user => "sensors", path => "/usr/bin:/bin:/usr/local/bin", unless => "test -f /home/sensors/Rules/source/updated" }
The 'unless' is supposed to check if the mount is in place but does not work
Is there a better way to do ensure that the directory is mounted?
Adding:
to the exec in puppet seems to have fixed the mount issue, to detect whether or not the disk is mounted I am now using
which seems to work fine