将变量从 chef 传递到 powershell
Passing variables from chef to powershell
我正在使用 powershell_script 食谱。我想使用的 powershell 脚本接受命令行输入。有没有办法从 chef 传递变量并将它们传递到 powershell 脚本中?
input1 = "input1"
input2 = "input2"
powershell_script 'example' do
code "...\example.ps1"
end
因此,如果我的示例。ps1 将 input1 和 input2 作为命令行参数,我将如何将它们传递给:
code "...\example.ps1"
powershell_script
资源上的 code
属性 采用您想要 运行 的文字 PowerShell 代码,而不是它的路径。无论如何,您将通过字符串插值来处理它。例如:
execute "C:/path/to/example.ps1 #{node['foo']} #{node['bar']}"
我正在使用 powershell_script 食谱。我想使用的 powershell 脚本接受命令行输入。有没有办法从 chef 传递变量并将它们传递到 powershell 脚本中?
input1 = "input1"
input2 = "input2"
powershell_script 'example' do
code "...\example.ps1"
end
因此,如果我的示例。ps1 将 input1 和 input2 作为命令行参数,我将如何将它们传递给:
code "...\example.ps1"
powershell_script
资源上的 code
属性 采用您想要 运行 的文字 PowerShell 代码,而不是它的路径。无论如何,您将通过字符串插值来处理它。例如:
execute "C:/path/to/example.ps1 #{node['foo']} #{node['bar']}"