在使用powershell_script块时,是否有方法从厨师登录到控制台。
一个过于简化的例子:
powershell_script "Something Cool" do
ignore_failure true
code <<-EOH
write-host "Hello World"
EOH
end发布于 2015-08-20 17:57:59
您想要混合powershell_out,它以shell_out从其他shell读取输出的方式从powershell读取输出。据主厨变更,截至客户端12.4.0,powershell_out现在生活在核心厨师https://github.com/chef/chef/blob/master/CHANGELOG.md
编辑:终于让它在我的环境中工作了。记住,我被锁在了12.3.0的总括版本中,所以您的体验可能会有所不同。
为了公开powershell_out,您需要做几件事。
metadata.rb
...
depends 'windows'
<recipe that will be using powershell_out>.rb
...
::Chef::Recipe.send(:include, Chef::Mixin::PowershellOut)
#example usage
should_exist = powershell_out('$true').stdout #=> ['true']不完全是一个完整的教程,但许多博萨人为给你带来这些信息而死,我希望这是一个有用的起点。执行此方法会引发以下警告:
The powershell_out library in the windows cookbook is deprecated.
Please upgrade to Chef 12.4.0 or later where it is built-in to core chef.因此,在12.4.0+中,您应该能够直接使用powershell_out资源。
发布于 2015-08-21 12:27:57
由于红宝石代码可以在食谱中编写,所以可以使用“put”登录到控制台。
https://stackoverflow.com/questions/32098230
复制相似问题