[英]exec command unless directory exists in puppet
如果puppet文件中不存在目录,如何执行命令?
exec { "my_exec_task":
command => "tar zxf /home/user/tmp/test.tar.gz",
unless => "test -d /home/user/tmp/new_directory",
path => "/usr/local/bin/:/bin/",
}
我收到错误:“无法评估:无法找到命令'test'”。 这也是检查目录是否不存在的最佳做法?
在/usr/bin
为我test
工作,所以将它添加到路径可以解决错误。
unless => 'bash -c "test -d /home/user/tmp/new_directory"',
也应该工作。 但我认为正确的方法是使用creates
:
exec { "my_exec_task":
command => "tar zxf /home/user/tmp/test.tar.gz",
creates => "/home/user/tmp/new_directory",
path => "/usr/local/bin/:/bin/",
}
实际问题在路径中:path => ['/ usr / local / bin','/ sbin','/ bin','/ usr / sbin','/ usr / bin']
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.