简体   繁体   English

厨师Powershell从文件运行

[英]Chef Powershell Run from File

Using chef's powershell_script provider how would I reference a file stored on the chef server instead of having the code defined in the same file? 使用chef的powershell_script提供程序,如何引用存储在chef服务器上的文件,而不是在同一个文件中定义代码? Basically how can I call on a .ps1 located on the server from a chef client? 基本上我如何从厨师客户端调用位于服务器上的.ps1?

You can call unsigned powershell scripts directly within powershell_script , as long as your execution policy allows it , which Chef does by default. 您可以直接在powershell_script调用unsigned powershell脚本,只要您的执行策略允许它 ,默认情况下Chef会执行

powershell_script "run some script" do
  code "c:/something/script.ps1"
end

If you want chef to deploy the script too, you can do it from the /files section of the cookbook with cookbook_file . 如果您希望chef也部署脚本,您可以使用cookbook_file从cookbook的/files部分执行此操作。

对于多行代码,不要忘记在powershell_script资源的代码参数中的每行末尾添加\\ n。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM