【问题标题】:Include ip address of node in Chef InSpec test在 Chef InSpec 测试中包含节点的 IP 地址
【发布时间】:2018-01-23 07:31:02
【问题描述】:

我正在通过 Test Kitchen 运行 InSpec 测试

我的 InSpec 测试应确保 curl 命令的输出是“HelloWorld!”

以下代码块按需要工作:

describe command("curl localhost}") do
    its('stdout') { should match /HelloWorld!/ }
end

问题

如何在 curl 测试中包含节点属性(IP 地址)?

在 .erb 模板中我可以使用 <%= node['ipaddress'] %>

以下方法不起作用

describe command("curl #{:ipaddress}") do
    its('stdout') { should match /HelloWorld!/ }
end

【问题讨论】:

    标签: testing chef-infra


    【解决方案1】:

    这不是特别支持的。 InSpec 与 Chef 完全分开,并且对 Chef 和 Ohai 的东西一无所知。您可能想自己进行一些实现,但请检查 InSpec 中的 os 助手。

    【讨论】:

      猜你喜欢
      • 2018-03-11
      • 2017-12-14
      • 1970-01-01
      • 2018-03-30
      • 2019-01-06
      • 1970-01-01
      • 2021-10-30
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多