如何匹配字典中支柱属性的值



我正在尝试编写一个与支柱值匹配的状态文件,但我不确定如何(或是否有可能)匹配字典中支柱属性的值。salt.module.match API 文档没有详细介绍这一点,也没有一个明显的方法富有成效:

root@ms-tapir:~ # salt clowder saltutil.refresh_pillar
clowder:
    None
root@ms-tapir:~ # salt clowder pillar.item wsgi_still
clowder:
    ----------
    wsgi_still:
        ----------
        foo:
            bar
        nginx_default:
            ----------
            directives:
                - return 444
root@ms-tapir:~ # salt clowder match.pillar 'wsgi_still["foo"]:bar'
clowder:
    False
root@ms-tapir:~ # salt clowder match.pillar "wsgi_still['foo']:bar"
clowder:
    False
root@ms-tapir:~ # salt clowder match.pillar "wsgi_still.foo:bar"
clowder:
    False

我试图调试这种情况的尝试甚至将pdb_trace()放在 match.py 并在前台运行 salt-minion,但这完全没用,导致通信错误而不是调试 shell,大概是由于 Salt 与 ØM:)Q 的奇怪交互

澄清一下,目标是在我的/srv/salt/top.sls文件中具有类似的工作方式:

base:
  'wsgi_still["foo"]:bar':
    - match: pillar
    - wsgi_distiller

我已经确认salt clowder match.pillar "foo:bar"适用于我的设置(返回True),当foo: bar在这个小黄人的支柱中时。

另外,我认为从不同的角度看这是同一个问题:

root@ms-tapir:~ # salt -I "foo:bar" test.ping
clowder:
    True
root@ms-tapir:~ # salt -I "wsgi_still['foo']:bar" test.ping

我只是包括它,因为"使用 -I"标志是我迄今为止收到的唯一建议。 :)

按以下方式访问支柱数据中的嵌套字典:

salt -I "wsgi_still:foo:bar" test.ping

顶部文件中的匹配也是如此:

base:
  'wsgi_still:foo:bar':
    - match: pillar
    - wsgi_distiller

最新更新