-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
[BUG] salt-ssh does not merge complex pillar data provided in the command-line for jinja templates #59802
Comments
Hi there! Welcome to the Salt Community! Thank you for making your first contribution. We have a lengthy process for issues and PRs. Someone from the Core Team will follow up as soon as possible. In the meantime, here’s some information that may help as you continue your Salt journey.
There are lots of ways to get involved in our community. Every month, there are around a dozen opportunities to meet with other contributors and the Salt Core team and collaborate in real time. The best way to keep track is by subscribing to the Salt Community Events Calendar. |
Yep, looks like pillar merging doesn't work quite correctly for salt-ssh when it's passed in via the command line. Verified that
will overwrite the pillar value, while
works as expected, merging the dictionaries as documented in https://docs.saltproject.io/en/latest/ref/pillar/all/salt.pillar.stack.html I didn't track down why it's happening, but it definitely is, and appears only to affect salt-ssh. |
I've double checked on 3002.2 and salt-ssh and I am unable to see correct behavior, so I'm thinking that this was always (at least as far back as 3002) an issue with salt-ssh |
Having exact same issue with salt-ssh 3004. Are there plans to fix this issue? |
This is caused by the state wrapper just updating salt/salt/client/ssh/wrapper/state.py Line 175 in 560bacd
The Lines 29 to 34 in 560bacd
Lines 732 to 735 in 560bacd
Lines 768 to 781 in 560bacd
Edit3: SidetrackEdit: While writing a fix for this, I noticed I could not reproduce the failure. Part of the cause is that the (1) original pillar: complex:
value1: foo
value2: bar (2) override: complex:
value2: baz pillar.update(override): complex:
value2: baz and then I suspect this bug is caused by the combination of the aforementioned behavior PLUS the failure of properly compiling (1) for some reason - misalignment of master/minion opts somewhere? On a sidenote: popts = {}
popts.update(opts["__master_opts__"]) # actual master __opts__ are embedded one level down
popts.update(opts) # opts reported by the minion via salt-ssh minion test.opts_pkg, modified In addition, the current behavior results in unnecessary duplicate pillar compilations when applying states without pillar overrides, which were fixed for A proper fix would thus include updating the state wrapper in a similar way. Edit2: Pillar merging is no joke: By default, when running 'state.apply' (with or without
This becomes even funnier when |
Closing as fixed per #65067 (comment) |
Description
I am running
salt-ssh
to apply salt states to a remote minion. I am providing custom pillar data in the command line to override values that I have defined in the pillar SLS files. The pillar data is properly merged for use in the SLS files but fails to properly merge for jinja templates in afile.managed
state.The issue only appears for 'complex' pillar data, i.e. (see example below) when there is a top-level key (
complex
) with an object value that has several key-value pairs (key1:val1
,key2:val2
), top-level pillar data is not affected (e.g.top_level
).Setup
I have provided a working example to reproduce the issue in this repo: https://github.com/xmsk/salt-ssh-jinja-pillar-merge.
defaults.sls
complex.sls
jinja text template salt.txt.j2
Steps to Reproduce the behavior
Run the following command
Expected behavior
The following files are present on the minion
/tmp/salt-append.txt
/tmp/salt-managed.txt
Actual Behavior
The following files are present on the minion
(correct) /tmp/salt-append.txt
(
key1
has valueNone
instead ofval1
) /tmp/salt-managed.txtVersions Report
I tested using the latest commit on master and also tested with
salt-ssh
version3002.5
.salt --versions-report
Additional context
I have also tested with a master/minion (version
3002.2
) set up using thesalt
command and the problem is not present there.For the
salt
command I have found a related issue #18429 which seems to have been fixed a while ago. Another issue that seems to be related is #27494.The text was updated successfully, but these errors were encountered: