You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
'Smart' pillar_source_merging_strategy does not use aggregate for yamlex #26396
AluminiumRelease Post Mg and Pre SiConfirmedSalt engineer has confirmed bug/feature - often including a MCVECorerelates to code central or existential to SaltPillarbugbroken, incorrect, or confusing behaviorseverity-medium3rd level, incorrect or bad functionality, confusing and lacks a work around
I'm trying to use #!yamlex and !aggregate in some of my pillar files. As I understand the documentation of pillar_source_merging_strategy, the default 'smart' strategy should then switch to the aggregate when it finds a yamlex renderer. However, it doesn't. If I set the merge strategy to aggregate in the master config, it does work.
# salt --versions
Salt Version:
Salt: 2016.11.4
Dependency Versions:
cffi: 1.6.0
cherrypy: unknown
dateutil: 2.6.0
docker-py: Not Installed
gitdb: Not Installed
gitpython: Not Installed
ioflo: Not Installed
Jinja2: 2.7.2
libgit2: 0.21.4
libnacl: Not Installed
M2Crypto: Not Installed
Mako: Not Installed
msgpack-pure: Not Installed
msgpack-python: 0.4.8
mysql-python: Not Installed
pycparser: 2.17
pycrypto: 2.6.1
pycryptodome: 3.4.3
pygit2: 0.21.4
Python: 2.7.5 (default, Nov 6 2016, 00:28:07)
python-gnupg: Not Installed
PyYAML: 3.11
PyZMQ: 15.3.0
RAET: Not Installed
smmap: Not Installed
timelib: Not Installed
Tornado: 4.2.1
ZMQ: 4.1.4
System Versions:
dist: centos 7.3.1611 Core
machine: x86_64
release: 3.10.0-514.16.1.el7.x86_64
system: Linux
version: CentOS Linux 7.3.1611 Core
Here are the results for the default smart merging strategy. Here zabbix-agent has a bunch of keys and values, and testkey and testlist that are using yamlex aggregates for the list. The testlist pillar is not rendered properly, and seems to be using the overwrite strategy.
If the master.conf is updated to explicitly use the aggregate strategy, then the testlist is properly rendered, but the normal zabbix-agent keys and values are missing (expected as not all parts of that key use yamlex aggregate):
In this state, it seems the only way to have merged lists is to use the pillar_merge_lists option. However, this isn't quite optimal as this is a global setting for all lists. Aggregate seems to be the only pillar option allowing list merge while not merging for all lists, but as shown seems to break non aggregate pillars.
In #18665 it was mentioned that using a jinja include made the smart render function as expected: #!jinja|yamlex With that, my test pillars are rendered properly when master has pillar_merge_lists enabled. With pillar_merge_lists disabled, the testlist item only includes the test2 entry.
A few tests seem to show that the smart merging strategy simply isn't operational for yamlex (which makes it seem like yamlex isn't functional so all of this is begging for unit tests)
In utils/dictupdate.py, I added a few logging lines:
def merge(obj_a, obj_b, strategy='smart', renderer='yaml', merge_lists=False):
if strategy == 'smart':
log.info('Using strategy {0} with renderer {1}'.format(strategy, renderer))
This prints:
[INFO ][18338] Using strategy smart with renderer yaml
[INFO ][18338] Using strategy smart with renderer yaml_jinja
But this is a problem as I have a few pillar files such as:
From these, I would expect to see a yamlex renderer logged, but I do not.
Updating the the merge(... renderer=yamlex default causes the print to see the expected log items:
[salt.utils.dictupdate][INFO ][22046] Using strategy smart with renderer yamlex
[salt.utils.dictupdate][INFO ][22047] Using strategy smart with renderer yaml_jinja
[salt.utils.dictupdate][INFO ][22047] Using strategy smart with renderer yaml_jinja
[salt.utils.dictupdate][INFO ][22047] Using strategy smart with renderer yamlex
[salt.utils.dictupdate][INFO ][22047] Using strategy smart with renderer yaml_jinja
But this still doesn't seem to use the yamlex behavior. So yamlex seems pretty broken at the moment.
@rallytime or @cachedout is there anyone that could provide a comment hint for where to start investigating this issue? It currently appears that yamlex simply isn't working as designed with either the smart pillar merge strategy or simple aggregation.
As far as I know, this is the only mechanism salt possesses that could allow for pillar setting/merging/overriding with a distributed pillar environment (multiple git_pillar repos managed by layers of different support teams) and could be crucial for distributed management in an enterprise environment.
@carlpett just encountered this myself, it seems the 'renderer' that is used to control the merging strategy inside the 'smart' strategy is the default. so if you set master: renderer: yamlex_jinja it will behave how you expect. This is not obvious at all though, so I'll send in a doc patch to note it.
Guesses the best strategy based on the "renderer" setting
This refers to the renderer master config option. You'll need to set it to something like jinja|yamlex for this to work.
The documentation does incorrectly suggest that you can just use a !yamlex shebang, which is not true. I've fixed this with a documentation update in #59317.
AluminiumRelease Post Mg and Pre SiConfirmedSalt engineer has confirmed bug/feature - often including a MCVECorerelates to code central or existential to SaltPillarbugbroken, incorrect, or confusing behaviorseverity-medium3rd level, incorrect or bad functionality, confusing and lacks a work around
Activity
jfindlay commentedon Aug 17, 2015
@carlpett, thanks for the report.
mchugh19 commentedon Jun 7, 2017
This still seems to be the case.
Here are the results for the default smart merging strategy. Here zabbix-agent has a bunch of keys and values, and testkey and testlist that are using yamlex aggregates for the list. The testlist pillar is not rendered properly, and seems to be using the overwrite strategy.
If the master.conf is updated to explicitly use the aggregate strategy, then the testlist is properly rendered, but the normal zabbix-agent keys and values are missing (expected as not all parts of that key use yamlex aggregate):
mchugh19 commentedon Jun 7, 2017
In this state, it seems the only way to have merged lists is to use the
pillar_merge_listsoption. However, this isn't quite optimal as this is a global setting for all lists. Aggregate seems to be the only pillar option allowing list merge while not merging for all lists, but as shown seems to break non aggregate pillars.mchugh19 commentedon Jun 8, 2017
In #18665 it was mentioned that using a jinja include made the smart render function as expected:
#!jinja|yamlexWith that, my test pillars are rendered properly when master has pillar_merge_lists enabled. With pillar_merge_lists disabled, the testlist item only includes the test2 entry.mchugh19 commentedon Jun 13, 2017
A few tests seem to show that the smart merging strategy simply isn't operational for yamlex (which makes it seem like yamlex isn't functional so all of this is begging for unit tests)
In utils/dictupdate.py, I added a few logging lines:
This prints:
But this is a problem as I have a few pillar files such as:
From these, I would expect to see a yamlex renderer logged, but I do not.
Updating the the merge(... renderer=yamlex default causes the print to see the expected log items:
But this still doesn't seem to use the yamlex behavior. So yamlex seems pretty broken at the moment.
mchugh19 commentedon Jun 19, 2017
@rallytime or @cachedout is there anyone that could provide a comment hint for where to start investigating this issue? It currently appears that yamlex simply isn't working as designed with either the smart pillar merge strategy or simple aggregation.
As far as I know, this is the only mechanism salt possesses that could allow for pillar setting/merging/overriding with a distributed pillar environment (multiple git_pillar repos managed by layers of different support teams) and could be crucial for distributed management in an enterprise environment.
rallytime commentedon Jun 19, 2017
I think @terminalmage would be the best one to comment on this issue or talk to about troubleshooting this.
@terminalmage Do you have any feedback on this since you were recently in the pillar merge strategy code somewhat recently?
mattp- commentedon Apr 15, 2018
@carlpett just encountered this myself, it seems the 'renderer' that is used to control the merging strategy inside the 'smart' strategy is the default. so if you set master: renderer: yamlex_jinja it will behave how you expect. This is not obvious at all though, so I'll send in a doc patch to note it.
14 remaining items
stale commentedon Jan 8, 2020
Thank you for updating this issue. It is no longer marked as stale.
terminalmage commentedon Jan 18, 2021
From the documentation:
This refers to the renderer master config option. You'll need to set it to something like
jinja|yamlexfor this to work.The documentation does incorrectly suggest that you can just use a
!yamlexshebang, which is not true. I've fixed this with a documentation update in #59317.