Skip to content

Commit

Permalink
ssh-client: fix merge order of options in run_wfunc (fix usage of min…
Browse files Browse the repository at this point in the history
…e.get in salt-ssh pillar)

This commit fixe a long standing issue: #36796

A first attempt to fix it is present in PR #41025
  • Loading branch information
Olivier MEDOC committed Nov 13, 2018
1 parent c64607a commit d245930
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion salt/client/ssh/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1075,8 +1075,22 @@ def run_wfunc(self):
opts_pkg['grains'][grain] = self.target['grains'][grain]

popts = {}
popts.update(opts_pkg['__master_opts__'])
popts.update(opts_pkg)

# Master centric operations such as mine.get must have master option loaded.
# The pillar must then be compiled by passing master opts found in opts_pkg['__master_opts__']
# which causes the pillar renderer to loose track of salt master options
#
# Depending on popts merge order, it will overwrite some options found in opts_pkg['__master_opts__']
master_centric_funcs = [
"pillar.items",
"mine.get"
]

# Pillar compilation is a master centric operation.
# Master options take precedence during Pillar compilation
popts.update(opts_pkg['__master_opts__'])

pillar = salt.pillar.Pillar(
popts,
opts_pkg['grains'],
Expand All @@ -1085,6 +1099,13 @@ def run_wfunc(self):
)
pillar_data = pillar.compile_pillar()

# Once pillar has been compiled, restore priority of minion opts
if self.fun not in master_centric_funcs:
log.debug(self.fun+" is a minion centric function")
popts.update(opts_pkg)
else:
log.debug(self.fun+" is a master centric function")

# TODO: cache minion opts in datap in master.py
data = {'opts': opts_pkg,
'grains': opts_pkg['grains'],
Expand Down

0 comments on commit d245930

Please sign in to comment.