__pillar___在自定义模块中为空

时间:2019-04-11 09:28:04

标签: salt-stack

我编写了一个简单的自定义模块,并希望访问支柱数据。

我这样测试(文件salt/_modules/foo.py):

def bar():
    assert 0, __pillar__

sls文件salt/tmp/test_pillar_in_custom_module.sls

{{ salt['foo.bar']() }}

我这样执行它:

salt-ssh --log-leve=all foohost state.sls tmp.test_pillar_in_custom_module pillar='{systems: [foosys]}' 2> tmp/o

tmp/o的相关部分:

Traceback (most recent call last):
  File "/var/tmp/.root_dcdf8c_salt/salt-call", line 27, in <module>
    salt_call()
  File "/var/tmp/.root_dcdf8c_salt/pyall/salt/scripts.py", line 431, in salt_call
    client.run()
  File "/var/tmp/.root_dcdf8c_salt/pyall/salt/cli/call.py", line 57, in run
    caller.run()
  File "/var/tmp/.root_dcdf8c_salt/pyall/salt/cli/caller.py", line 138, in run
    ret = self.call()
  File "/var/tmp/.root_dcdf8c_salt/pyall/salt/cli/caller.py", line 237, in call
    ret['return'] = self.minion.executors[fname](self.opts, data, func, args, kwargs)
  File "/var/tmp/.root_dcdf8c_salt/pyall/salt/executors/direct_call.py", line 12, in execute
    return func(*args, **kwargs)
  File "/var/tmp/.root_dcdf8c_salt/running_data/var/cache/salt/minion/extmods/modules/foo.py", line 2, in bar
    assert 0, __pillar__
AssertionError: {}

但是字典__pillar__是空的。

我阅读了以下文档:https://docs.saltstack.com/en/latest/topics/development/modules/developing.html#pillar

  

__pillar__字典包含相应的支柱   奴才。

     

虽然为每个模块都定义了__pillar__,但只为   一些。

在我的自定义模块中,它是空的。

是否可以访问自定义模块中的支柱?

0 个答案:

没有答案