标签:pillar
/usr/lib/python2.6/site-packages/salt/runners/pillar.py
pillar runner模块提供一些在Master端与Pillar编译器交互的函数
返回指定minion的pillar的编译top数据,如果没有指定minion,就使用第一个找到的minion
def show_top(minion=None, saltenv=‘base‘): ‘‘‘ Returns the compiled top data for pillar for a specific minion. If no minion is specified, we use the first minion we find. CLI Example: .. code-block:: bash salt-run pillar.show_top ‘‘‘ id_, grains, _ = salt.utils.minions.get_minion_data(minion, __opts__) pillar = salt.pillar.Pillar( __opts__, grains, id_, saltenv) top, errors = pillar.get_top() if errors: salt.output.display_output(errors, ‘nested‘, __opts__) return errors salt.output.display_output(top, ‘nested‘, __opts__) return top
$ sudo salt-run pillar.show_top ‘jialebi-qa-server‘ base: ---------- *: - packages - services
def show_pillar(minion=‘*‘, **kwargs): ‘‘‘ Returns the compiled pillar either of a specific minion or just the global available pillars. I assume that no minion is using the id ``*``. CLI Example: shows minion specific pillar: .. code-block:: bash salt-run pillar.show_pillar ‘www.example.com‘ shows global pillar: .. code-block:: bash salt-run pillar.show_pillar shows global pillar for ‘dev‘ pillar environment: .. code-block:: bash salt-run pillar.show_pillar ‘saltenv=dev‘ API Example: .. code-block:: python import salt.config import salt.runner opts = salt.config.master_config(‘/etc/salt/master‘) runner = salt.runner.RunnerClient(opts) pillar = runner.cmd(‘pillar.show_pillar‘, []) print pillar ‘‘‘ saltenv = ‘base‘ id_, grains, _ = salt.utils.minions.get_minion_data(minion, __opts__) if grains is None: grains = {‘fqdn‘: minion} for key in kwargs: if key == ‘saltenv‘: saltenv = kwargs[key] else: grains[key] = kwargs[key] pillar = salt.pillar.Pillar( __opts__, grains, id_, saltenv) compiled_pillar = pillar.compile_pillar() salt.output.display_output(compiled_pillar, ‘nested‘, __opts__) return compiled_pillar
参考资料:
http://docs.saltstack.com/en/2014.7/ref/runners/all/salt.runners.pillar.html
本文出自 “Linux SA John” 博客,请务必保留此出处http://john88wang.blog.51cto.com/2165294/1656275
SaltStack runners模块分析之pillar模块
标签:pillar
原文地址:http://john88wang.blog.51cto.com/2165294/1656275