SHA256
1
0
forked from pool/salt
salt/option-to-merge-current-pillar-with-opts-pillar-duri.patch
Bo Maryniuk 7966fde1ef Accepting request 626472 from home:mdinca:branches:systemsmanagement:saltstack
- Update to 2018.3.2
  See https://docs.saltstack.com/en/latest/topics/releases/2018.3.2.html
  for full changelog
- Added:
  * accounting-for-when-files-in-an-archive-contain-non-.patch
  * add-all_versions-parameter-to-include-all-installed-.patch
  * add-custom-suse-capabilities-as-grains.patch
  * add-engine-relaying-libvirt-events.patch
  * add-environment-variable-to-know-if-yum-is-invoked-f.patch
  * add-other-attribute-to-gecos-fields-to-avoid-inconsi.patch
  * align-suse-salt-master.service-limitnofiles-limit-wi.patch
  * avoid-incomprehensive-message-if-crashes.patch
  * fix-deprecation-warning-bsc-1095507.patch
  * fix-diffing-binary-files-in-file.get_diff-bsc-109839.patch
  * fix-unboundlocalerror-in-file.get_diff.patch
  * fix-zypper.list_pkgs-to-be-aligned-with-pkg-state.patch
  * prevent-zypper-from-parsing-repo-configuration-from-.patch
  * remove-old-hack-when-reporting-multiversion-packages.patch
  * show-recommendations-for-salt-ssh-cross-version-pyth.patch
- Modified:
  * activate-all-beacons-sources-config-pillar-grains.patch
  * add-saltssh-multi-version-support-across-python-inte.patch
  * avoid-excessive-syslogging-by-watchdog-cronjob-58.patch
  * do-not-override-jid-on-returners-only-sending-back-t.patch
  * enable-passing-a-unix_socket-for-mysql-returners-bsc.patch
  * fall-back-to-pymysql.patch
  * feat-add-grain-for-all-fqdns.patch
  * fix-bsc-1065792.patch
  * fix-decrease-loglevel-when-unable-to-resolve-addr.patch
  * fix-for-ec2-rate-limit-failures.patch

OBS-URL: https://build.opensuse.org/request/show/626472
OBS-URL: https://build.opensuse.org/package/show/systemsmanagement:saltstack/salt?expand=0&rev=127
2018-07-30 11:52:13 +00:00

102 lines
3.4 KiB
Diff

From e8c1b2c5a8af5cc6f4551918f695d1463a6eb584 Mon Sep 17 00:00:00 2001
From: Matei Albu <malbu@suse.de>
Date: Sun, 6 May 2018 21:15:58 +0200
Subject: [PATCH] Option to merge current pillar with opts['pillar']
during pillar compile
Fixes #47501
(cherry picked from commit 2f1485e)
---
doc/ref/configuration/minion.rst | 28 ++++++++++++++++++++++++++++
salt/config/__init__.py | 4 +++-
salt/pillar/__init__.py | 7 +++++++
3 files changed, 38 insertions(+), 1 deletion(-)
diff --git a/doc/ref/configuration/minion.rst b/doc/ref/configuration/minion.rst
index c9010a702b..d9823b78d8 100644
--- a/doc/ref/configuration/minion.rst
+++ b/doc/ref/configuration/minion.rst
@@ -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.
diff --git a/salt/config/__init__.py b/salt/config/__init__.py
index 432364b201..feda0abac1 100644
--- a/salt/config/__init__.py
+++ b/salt/config/__init__.py
@@ -989,6 +989,7 @@ VALID_OPTS = {
'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,
@@ -1485,6 +1486,7 @@ DEFAULT_MINION_OPTS = {
},
'discovery': False,
'schedule': {},
+ 'ssh_merge_pillar': True
}
DEFAULT_MASTER_OPTS = {
@@ -2089,7 +2091,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',
diff --git a/salt/pillar/__init__.py b/salt/pillar/__init__.py
index fc1e34f75d..fc3ce0a5c0 100644
--- a/salt/pillar/__init__.py
+++ b/salt/pillar/__init__.py
@@ -1014,6 +1014,13 @@ class Pillar(object):
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)
--
2.13.7