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:

 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?



     environment => ['USER=sensors', 'HOME=/home/sensors'],

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

 unless => "mountpoint -q /home/sensors/Rules/source"

which seems to work fine

  • Feel free to mark and accept your own answer. It helps the site to index which questions are resolved and which ones need more attention. Dec 17 '19 at 1:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.