Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vault policy parser add pillar support #49343

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions salt/modules/vault.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,16 +93,16 @@
Policies that are assigned to minions when requesting a token. These can
either be static, eg saltstack/minions, or templated, eg
``saltstack/minion/{minion}``. ``{minion}`` is shorthand for grains[id].
Grains are also available, for example like this:
Grains and pillar are also available, for example like this:
``my-policies/{grains[os]}``

If a template contains a grain which evaluates to a list, it will be
If a template contains a value which evaluates to a list, it will be
expanded into multiple policies. For example, given the template
``saltstack/by-role/{grains[roles]}``, and a minion having these grains:
``saltstack/by-role/{pillar[roles]}``, and a minion having this pillar:

.. code-block: yaml

grains:
pillar:
roles:
- web
- database
Expand All @@ -116,6 +116,9 @@
Optional. If policies is not configured, ``saltstack/minions`` and
``saltstack/{minion}`` are used as defaults.

.. versionchanged:: Fluorine
Support for pillardata added.

keys
List of keys to use to unseal vault server with the vault.unseal runner.

Expand Down
4 changes: 2 additions & 2 deletions salt/runners/vault.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,12 +167,12 @@ def _get_policies(minion_id, config):
'''
Get the policies that should be applied to a token for minion_id
'''
_, grains, _ = salt.utils.minions.get_minion_data(minion_id, __opts__)
_, grains, pillar = salt.utils.minions.get_minion_data(minion_id, __opts__)
policy_patterns = config.get(
'policies',
['saltstack/minion/{minion}', 'saltstack/minions']
)
mappings = {'minion': minion_id, 'grains': grains or {}}
mappings = {'minion': minion_id, 'grains': grains or {}, 'pillar': pillar or {}}

policies = []
for pattern in policy_patterns:
Expand Down