Puppet "onlyif" 属性找不到 not(!) 运算符
Puppet "onlyif" attribute cannot find not(!) operator
我正在尝试使用以下人偶代码确定节点包 PM2 是否安装在路径中和可执行文件中。
exec { "create symbolic link for pm2":
cwd => "${pm2_link_dir}",
path => ['/usr/bin','/bin','/usr/sbin','/sbin'],
onlyif => "! which node &> /dev/null",
command => "ln -s ../lib/node_modules/pm2/bin/pm2 pm2"
}
它告诉我找不到命令“!”。这是查明某些程序是否已安装和可执行的正确方法吗?为什么 puppet 不能理解 not 运算符??我正在研究 Redhat master 和 slave。
And why puppet cannot understand The not operator?
!
运算符由shell提供;这不是命令。您正在使用 Exec
的默认提供程序 (posix
),它直接运行您的命令,而不是通过 shell。 (或者它被记录要做。最近发现,有时 posix
提供程序通过 shell 运行命令,这显然与其文档相矛盾。)
无论如何,在 Exec
的 onlyif
属性中使用 !
有点愚蠢,因为您可以删除 !
并切换到 unless
属性代替。并删除重定向,这也依赖于 shell.
Is this the right way to find out if some program is installed and executable?
通常最好知道程序是否应该在特定的目标节点上可用,并且在必要时确保它是 可用的。如果您必须查询节点状态,那么通常最好通过自定义事实来实现。
话虽如此,我认为您的方法本身并没有错,当然它只会在您在 Exec
.
中指定的路径中查找请求的程序
我正在尝试使用以下人偶代码确定节点包 PM2 是否安装在路径中和可执行文件中。
exec { "create symbolic link for pm2":
cwd => "${pm2_link_dir}",
path => ['/usr/bin','/bin','/usr/sbin','/sbin'],
onlyif => "! which node &> /dev/null",
command => "ln -s ../lib/node_modules/pm2/bin/pm2 pm2"
}
它告诉我找不到命令“!”。这是查明某些程序是否已安装和可执行的正确方法吗?为什么 puppet 不能理解 not 运算符??我正在研究 Redhat master 和 slave。
And why puppet cannot understand The not operator?
!
运算符由shell提供;这不是命令。您正在使用 Exec
的默认提供程序 (posix
),它直接运行您的命令,而不是通过 shell。 (或者它被记录要做。最近发现,有时 posix
提供程序通过 shell 运行命令,这显然与其文档相矛盾。)
无论如何,在 Exec
的 onlyif
属性中使用 !
有点愚蠢,因为您可以删除 !
并切换到 unless
属性代替。并删除重定向,这也依赖于 shell.
Is this the right way to find out if some program is installed and executable?
通常最好知道程序是否应该在特定的目标节点上可用,并且在必要时确保它是 可用的。如果您必须查询节点状态,那么通常最好通过自定义事实来实现。
话虽如此,我认为您的方法本身并没有错,当然它只会在您在 Exec
.