大网数据广告活动
服务器运维问答

Trying to use sshfs to mount directory from a puppet exec

· 52CE 我爱测

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…

问题原文

原帖链接 · Russell Fulton · CC BY-SA 4.0

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?

已采纳解答

原帖链接 · Russell Fulton · CC BY-SA 4.0

Adding:

     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

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2019-11-04)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。