我正在尝试在 puppet 中编写一个函数,fail
如果传递的目录路径不存在,它将执行。
if File["/some/path"]
始终返回true,并且if defined(File["/some/path"])
只有在puppet 中定义了资源时才返回true,而不管它是否实际存在。
有没有办法用一个简单的if
语句来做到这一点?
谢谢
Pas*_*iel 34
解决方法:在 exec "test" 上使用 onlyif 并在您要执行的操作中要求它:
exec {"check_presence":
command => '/bin/true',
onlyif => '/usr/bin/test -e /path/must/be/available',
}
whatever {"foo...":
.....
require => Exec["check_presence"],
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
66271 次 |
最近记录: |