厨师Powershell从文件运行

Der*_*gan 5 windows chef-infra

使用chef的powershell_script提供程序,如何引用存储在chef服务器上的文件,而不是在同一个文件中定义代码?基本上我如何从厨师客户端调用位于服务器上的.ps1?

Mat*_*att 6

powershell_script只要您的执行策略允许,您就可以直接在其中调用unsigned PowerShell脚本,默认情况下,Chef会执行此操作.

powershell_script "run some script" do
  code "c:/something/script.ps1"
end
Run Code Online (Sandbox Code Playgroud)

如果您希望厨师也部署脚本,您可以/files使用相应的菜单部分进行操作cookbook_file.

  • 那么DSL毕竟只是Ruby代码.您可以从任何地方将"code"字符串拉入客户端.您可以从本地cookbook缓存中"File.read("script.ps1")`.甚至`Net :: HTTP.get('example.com','script.ps1')` (2认同)