这里的其他部分没有工作我无法找出原因,我如何成功地执行这个代码?厨师如果使用陈述,正确的方法是什么?
service 'McAfeeFramework' do
if{ supports :status =>true}
File.write('c:\chef-repo\n1.txt','running')
else
File.write('c:\chef-repo\n1.txt','not running')
end
这里的其他部分没有工作我无法找出原因,我如何成功地执行这个代码?厨师如果使用陈述,正确的方法是什么?
service 'McAfeeFramework' do
if{ supports :status =>true}
File.write('c:\chef-repo\n1.txt','running')
else
File.write('c:\chef-repo\n1.txt','not running')
end
正如您在上一个问题中指出的那样,您在那里的内容与字母代码无关。请从https://learn.chef.io教程开始,了解编写厨师食谱代码的基础知识。
这里是检查是否给定的过程与厨师运行的方式。您需要将procname替换为进程名称。然而,这是例如用于Linux,如果你需要的Windows,你需要only_if语句来更改为类似sc query | find "RUNNING
file 'running process' do
path '/tmp/running_process'
content 'services is running'
only_if 'pgrep procname && echo 0'
action :create
end
file 'stoped process' do
path '/tmp/stoped_process'
content 'services is not running'
only_if 'pgrep procname || echo 1'
action :create
end
的可能的复制[是有可能使用支持声明,如果声明的厨师?](HTTP://计算器.COM /问题/ 42482182/IS-IT-可以使用的,支持语句式-if语句,在厨师) – Tensibai
请在https://learn.chef.io读厨师教程一起,花一些时间阅读[旅游]和[问]。一次又一次询问同样的事情在StackOverflow上不受欢迎。 – Tensibai