Fix incorrect override of minion node definition

A pillars dict in a minion node definition was not overridding
correctly the same dict in classes.

* salt/utils/saltclass.py (expanded_dict_from_minion): do not pass a
  reference to minion dict or it will be overridden by classes during
  expansion.

Fixes: #63933
This commit is contained in:
Daniel Dehennin 2024-09-26 21:50:24 +02:00 committed by Daniel Wozniak
parent 9ef879aee4
commit d1ca30c2ad
2 changed files with 8 additions and 1 deletions

4
changelog/63933.fixed.md Normal file
View file

@ -0,0 +1,4 @@
Issue 63933: Fixes an issue with `saltclass.expanded_dict_from_minion`
function where it was passing a reference to minion `dict` which was
overridden by nested classes during class expansion. Copy the node
definition with `copy.deepcopy` instead of passing a reference.

View file

@ -1,3 +1,4 @@
import copy
import glob
import logging
import os
@ -362,7 +363,9 @@ def expanded_dict_from_minion(minion_id, salt_data):
node_dict[minion_id] = {}
# Merge newly found pillars into existing ones
dict_merge(salt_data["__pillar__"], node_dict[minion_id].get("pillars", {}))
dict_merge(
salt_data["__pillar__"], copy.deepcopy(node_dict[minion_id]).get("pillars", {})
)
# Get 2 ordered lists:
# expanded_classes: A list of all the dicts