【问题标题】:Passing variables from chef to powershell将变量从厨师传递到PowerShell
【发布时间】:2016-08-02 04:47:58
【问题描述】:

我正在使用 powershell_script 食谱。我想使用的 powershell 脚本需要命令行输入。有没有办法从 chef 传递变量并将它们传递到 powershell 脚本?

input1 = "input1"
input2 = "input2"

powershell_script 'example' do
  code "...\example.ps1"
end

因此,如果我的 example.ps1 将 input1 和 input2 作为命令行参数,我将如何将它们传递给:

code "...\example.ps1"

【问题讨论】:

标签: powershell chef-infra


【解决方案1】:

powershell_script 资源上的 code 属性采用您要运行的文字 PowerShell 代码,而不是它的路径。无论如何,您将通过字符串插值来处理它。例如:

execute "C:/path/to/example.ps1 #{node['foo']} #{node['bar']}"

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-03-08
    • 2013-07-15
    • 2021-04-18
    • 2015-12-29
    • 1970-01-01
    • 1970-01-01
    • 2019-09-12
    相关资源
    最近更新 更多