测试厨房salt_solo从平台传递变量

时间:2017-06-13 21:06:32

标签: salt test-kitchen

我使用salt_solo运行带有盐的测试厨房,如果我在平台中声明变量,我就无法将变量传递给公式。

例如,如果这是我的.kitchen.yml

---
driver:
  name: vagrant

platforms:
  - name: ubuntu-14.04
    grains:
      org:
        bat: batz

suites:
  - name: binary
    provisioner:
      name: salt_solo
      state_top:
        base:
          '*':
            - binary
      formula: binary
      grains:
        org:
          foo: bar  

然后,我的公式无法访问{{grains['org']['bat']}},但可以访问{{grains['org']['foo']}}

1 个答案:

答案 0 :(得分:0)

解决方案是在平台变量之前添加provisioner:。对上面示例.kitchen.yml的此修复将解决此问题:

---
driver:
  name: vagrant

platforms:
  - name: ubuntu-14.04
    provisioner:
      grains:
        org:
          bat: batz

suites:
  - name: binary
    provisioner:
      name: salt_solo
      state_top:
        base:
          '*':
            - binary
      formula: binary
      grains:
        org:
          foo: bar