我有一个 Puppet 模块,用于挂载 CIFS 共享。Puppetmaster 和代理都运行 SLES 11。
使用此命令可以手动进行挂载:
mount.cifs //servername/path/to/share /opt/some/dir -o auto,credentials=/root/.smbcred
但是当 Puppet 尝试挂载它时,却失败了:
hostname:~ # puppet agent --test --verbose
notice: /Stage[main]/module_name/Mount[/opt/some/dir]/ensure: defined 'ensure' as 'mounted'
err: /Stage[main]/module_name/Mount[/opt/some/dir]: Could not evaluate: Field 'device' is required
以下是该模块的 init.pp 的相关部分:
file { "/opt/some/dir":
ensure => directory,
}
file { "/root/.smbcred":
owner => root,
group => root,
mode => 0644,
ensure => present,
content => "user=username\npass=password\ndomain=$domain\n",
}
mount {"/opt/some/dir":
device => "//servername/path/to/share",
name => "/opt/some/dir",
atboot => "true",
ensure => "mounted",
fstype => "cifs",
options => "auto,credentials=/root/.smbcred",
require => [ File["/root/.smbcred"], File["/opt/some/dir"] ],
}
凭证文件确实写入,目录也确实创建。但挂载失败。有什么想法吗?
答案1
名称字段是多余的
凭证文件写入并目录创建后,挂载是否可以工作?
使用--debug运行
/etc/fstab 中是否有错误?