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

Fix pillar propagation in salt-ssh when overriding pillar in module.run + state.apply #47504

Merged
merged 2 commits into from
May 16, 2018
Merged
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
28 changes: 28 additions & 0 deletions doc/ref/configuration/minion.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3219,3 +3219,31 @@ URL of the repository:
Replace ``<commit_id>`` with the SHA1 hash of a commit ID. Specifying a commit
ID is useful in that it allows one to revert back to a previous version in the
event that an error is introduced in the latest revision of the repo.

``ssh_merge_pillar``
--------------------

.. versionadded:: 2018.3.2

Default: ``True``

Merges the compiled pillar data with the pillar data already available globally.
This is useful when using ``salt-ssh`` or ``salt-call --local`` and overriding the pillar
data in a state file:

.. code-block:: yaml

apply_showpillar:
module.run:
- name: state.apply
- mods:
- showpillar
- kwargs:
pillar:
test: "foo bar"

If set to ``True`` the ``showpillar`` state will have access to the
global pillar data.

If set to ``False`` only the overriding pillar data will be available
to the ``showpillar`` state.
4 changes: 3 additions & 1 deletion salt/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -989,6 +989,7 @@ def _gather_buffer_space():
'ssh_identities_only': bool,
'ssh_log_file': six.string_types,
'ssh_config_file': six.string_types,
'ssh_merge_pillar': bool,

# Enable ioflo verbose logging. Warning! Very verbose!
'ioflo_verbose': int,
Expand Down Expand Up @@ -1485,6 +1486,7 @@ def _gather_buffer_space():
},
'discovery': False,
'schedule': {},
'ssh_merge_pillar': True
}

DEFAULT_MASTER_OPTS = {
Expand Down Expand Up @@ -2088,7 +2090,7 @@ def _validate_ssh_minion_opts(opts):

for opt_name in list(ssh_minion_opts):
if re.match('^[a-z0-9]+fs_', opt_name, flags=re.IGNORECASE) \
or 'pillar' in opt_name \
or ('pillar' in opt_name and not 'ssh_merge_pillar' == opt_name) \
or opt_name in ('fileserver_backend',):
log.warning(
'\'%s\' is not a valid ssh_minion_opts parameter, ignoring',
Expand Down
7 changes: 7 additions & 0 deletions salt/pillar/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1014,6 +1014,13 @@ def compile_pillar(self, ext=True):
mopts['file_roots'] = self.actual_file_roots
mopts['saltversion'] = __version__
pillar['master'] = mopts
if 'pillar' in self.opts and self.opts.get('ssh_merge_pillar', False):
pillar = merge(
self.opts['pillar'],
pillar,
self.merge_strategy,
self.opts.get('renderer', 'yaml'),
self.opts.get('pillar_merge_lists', False))
if errors:
for error in errors:
log.critical('Pillar render error: %s', error)
Expand Down