From f124bf87c21905304bce8203eec34a7a49bb1b3a Mon Sep 17 00:00:00 2001 From: nue Date: Thu, 7 May 2026 14:05:59 +0200 Subject: [PATCH 1/3] fix 55146 by merging YAML lists before processing --- changelog/55146.fixed.md | 2 ++ salt/pillar/nodegroups.py | 3 ++- tests/pytests/unit/pillar/test_nodegroups.py | 3 ++- 3 files changed, 6 insertions(+), 2 deletions(-) create mode 100644 changelog/55146.fixed.md diff --git a/changelog/55146.fixed.md b/changelog/55146.fixed.md new file mode 100644 index 000000000000..6ff8a469768c --- /dev/null +++ b/changelog/55146.fixed.md @@ -0,0 +1,2 @@ +Flatten yaml node lists to `L@` or `E@` before trying to do the ext_pillar parsing. +For nested Nodegroups this is already done, but on the first level nodegroup a list will fail parsing as compound match. diff --git a/salt/pillar/nodegroups.py b/salt/pillar/nodegroups.py index 29642c4acf00..4a70c6d5de9e 100644 --- a/salt/pillar/nodegroups.py +++ b/salt/pillar/nodegroups.py @@ -35,7 +35,7 @@ # Import futures -from salt.utils.minions import CkMinions +from salt.utils.minions import CkMinions, nodegroup_comp __version__ = "0.0.2" @@ -56,6 +56,7 @@ def ext_pillar(minion_id, pillar, pillar_name=None): ckminions = None for nodegroup_name in all_nodegroups.keys(): ckminions = ckminions or CkMinions(__opts__) + all_nodegroups[nodegroup_name] = nodegroup_comp(nodegroup_name, all_nodegroups) _res = ckminions.check_minions(all_nodegroups[nodegroup_name], "compound") match = _res["minions"] diff --git a/tests/pytests/unit/pillar/test_nodegroups.py b/tests/pytests/unit/pillar/test_nodegroups.py index 2c4d1bf24311..7732e702ea99 100644 --- a/tests/pytests/unit/pillar/test_nodegroups.py +++ b/tests/pytests/unit/pillar/test_nodegroups.py @@ -14,6 +14,7 @@ def fake_nodegroups(fake_minion_id): return { "groupA": fake_minion_id, "groupB": "another_minion_id", + "groupC": [fake_minion_id, "another_minion_id"] } @@ -48,5 +49,5 @@ def _side_effect(group_sel, t): def test_succeeds(fake_pillar_name, fake_minion_id): - ret = {fake_pillar_name: ["groupA"]} + ret = {fake_pillar_name: ["groupA", "groupC"]} _runner(ret, fake_minion_id, fake_pillar_name) From 65b1fda36ea7f42942204af975570e0ce720622a Mon Sep 17 00:00:00 2001 From: oeko2002 <79214500+oeko2002@users.noreply.github.com> Date: Tue, 19 May 2026 08:23:02 +0200 Subject: [PATCH 2/3] Fix tests for ext_pillar nodegroups --- tests/pytests/unit/pillar/test_nodegroups.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/pytests/unit/pillar/test_nodegroups.py b/tests/pytests/unit/pillar/test_nodegroups.py index 7732e702ea99..cd20d44bf021 100644 --- a/tests/pytests/unit/pillar/test_nodegroups.py +++ b/tests/pytests/unit/pillar/test_nodegroups.py @@ -35,7 +35,9 @@ def configure_loader_modules(fake_minion_id, fake_nodegroups): def _runner(expected_ret, fake_minion_id, fake_pillar_name, pillar_name=None): def _side_effect(group_sel, t): - if group_sel.find(fake_minion_id) != -1: + if not isinstance(group_sel, list): + group_sel = [group_sel] + if any(x for x in group_sel if x.find(fake_minion_id) != -1): return {"minions": [fake_minion_id], "missing": []} return {"minions": ["another_minion_id"], "missing": []} From 219727712633171cc391acadb8c9d4412da59dac Mon Sep 17 00:00:00 2001 From: oeko2002 <79214500+oeko2002@users.noreply.github.com> Date: Tue, 26 May 2026 10:53:27 +0200 Subject: [PATCH 3/3] Update test_nodegroups.py --- tests/pytests/unit/pillar/test_nodegroups.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/pytests/unit/pillar/test_nodegroups.py b/tests/pytests/unit/pillar/test_nodegroups.py index cd20d44bf021..b4c65ce3208a 100644 --- a/tests/pytests/unit/pillar/test_nodegroups.py +++ b/tests/pytests/unit/pillar/test_nodegroups.py @@ -14,7 +14,7 @@ def fake_nodegroups(fake_minion_id): return { "groupA": fake_minion_id, "groupB": "another_minion_id", - "groupC": [fake_minion_id, "another_minion_id"] + "groupC": [fake_minion_id, "another_minion_id"], }