ruby – exec命令除非目录存在于puppet中
发布时间:2020-12-17 03:06:34 所属栏目:百科 来源:网络整理
导读:如果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’”
如果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为我测试工作,所以将它添加到路径可以解决错误.
unless => 'bash -c "test -d /home/user/tmp/new_directory"', 也应该工作.但我认为正确的方法是使用创建: exec { "my_exec_task": command => "tar zxf /home/user/tmp/test.tar.gz",creates => "/home/user/tmp/new_directory",} (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |