salt.modules.pillar

Extract the pillar data for this minion

salt.modules.pillar.ext(external, pillar=None)

Generate the pillar and apply an explicit external pillar

CLI 范例:

pillar : None

If specified, allows for a dictionary of pillar data to be made available to pillar and ext_pillar rendering. These pillar variables will also override any variables of the same name in pillar or ext_pillar.

2015.5.0 新版功能.

salt '*' pillar.ext '{libvirt: _}'
salt.modules.pillar.file_exists(path, saltenv=None)

2016.3.0 新版功能.

This is a master-only function. Calling from the minion is not supported.

Use the given path and search relative to the pillar environments to see if a file exists at that path.

If the saltenv argument is given, restrict search to that environment only.

Will only work with pillar_roots, not external pillars.

Returns True if the file is found, and False otherwise.

path
The path to the file in question. Will be treated as a relative path
saltenv
Optional argument to restrict the search to a specific saltenv

CLI 范例:

salt '*' pillar.file_exists foo/bar.sls
salt.modules.pillar.get(key, default=<type 'exceptions.KeyError'>, merge=False, delimiter=':')

0.14 新版功能.

Attempt to retrieve the named value from pillar, if the named value is not available return the passed default. The default return is an empty string except __opts__['pillar_raise_on_missing'] is set to True, in which case a KeyError will be raised.

If the merge parameter is set to True, the default will be recursively merged into the returned pillar data.

The value can also represent a value in a nested dict using a ":" delimiter for the dict. This means that if a dict in pillar looks like this:

{'pkg': {'apache': 'httpd'}}

To retrieve the value associated with the apache key in the pkg dict this key can be passed:

pkg:apache
merge

Specify whether or not the retrieved values should be recursively merged into the passed default.

2014.7.0 新版功能.

delimiter

Specify an alternate delimiter to use when traversing a nested dict

2014.7.0 新版功能.

CLI 范例:

salt '*' pillar.get pkg:apache
salt.modules.pillar.item(*args, **kwargs)

0.16.2 新版功能.

Return one or more pillar entries

pillar : none

if specified, allows for a dictionary of pillar data to be made available to pillar and ext_pillar rendering. these pillar variables will also override any variables of the same name in pillar or ext_pillar.

2015.5.0 新版功能.

CLI范例:

salt '*' pillar.item foo
salt '*' pillar.item foo bar baz
salt.modules.pillar.items(*args, **kwargs)

Calls the master for a fresh pillar and generates the pillar data on the fly

Contrast with raw() which returns the pillar data that is currently loaded into the minion.

pillar : none

if specified, allows for a dictionary of pillar data to be made available to pillar and ext_pillar rendering. these pillar variables will also override any variables of the same name in pillar or ext_pillar.

2015.5.0 新版功能.

CLI 范例:

salt '*' pillar.items
salt.modules.pillar.keys(key, delimiter=':')

2015.8.0 新版功能.

Attempt to retrieve a list of keys from the named value from the pillar.

The value can also represent a value in a nested dict using a ":" delimiter for the dict, similar to how pillar.get works.

delimiter
Specify an alternate delimiter to use when traversing a nested dict

CLI 范例:

salt '*' pillar.keys web:sites
salt.modules.pillar.ls(*args)

2015.8.0 新版功能.

Calls the master for a fresh pillar, generates the pillar data on the fly (same as items()), but only shows the available main keys.

CLI范例:

salt '*' pillar.ls
salt.modules.pillar.obfuscate(*args)

2015.8.0 新版功能.

Same as items(), but replace pillar values with a simple type indication.

This is useful to avoid displaying sensitive information on console or flooding the console with long output, such as certificates. For many debug or control purposes, the stakes lie more in dispatching than in actual values.

In case the value is itself a collection type, obfuscation occurs within the value. For mapping types, keys are not obfuscated. Here are some examples:

  • 'secret password' becomes '<str>'
  • ['secret', 1] becomes ['<str>', '<int>']
  • {'login': 'somelogin', 'pwd': 'secret'} becomes {'login': '<str>', 'pwd': '<str>'}

CLI范例:

salt '*' pillar.obfuscate
salt.modules.pillar.raw(key=None)

Return the raw pillar data that is currently loaded into the minion.

Contrast with items() which calls the master to fetch the most up-to-date Pillar.

CLI 范例:

salt '*' pillar.raw

With the optional key argument, you can select a subtree of the pillar raw data.:

salt '*' pillar.raw key='roles'