Skip to content
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] pillar.get on substructure is broken or i'm doing it wrong? #67143

Open
freemjohn opened this issue Jan 14, 2025 · 3 comments
Open

[BUG] pillar.get on substructure is broken or i'm doing it wrong? #67143

freemjohn opened this issue Jan 14, 2025 · 3 comments
Labels
Bug broken, incorrect, or confusing behavior needs-triage

Comments

@freemjohn
Copy link

freemjohn commented Jan 14, 2025

Description

pillar.get in jinja template behavior looks improper. When directly calling get substructure - it's returns it right way, when calling in jinja template - returns literally None

Setup

  • [ ESXi] VM (Virtualbox, KVM, etc. please specify)

Simple VM's for minions and server , runs same on any machine

Steps to Reproduce the behavior
pillar sls

ntp:
  servers:
    ntp.host1.net:
    ntp.host2.net:
    ntp1.host2.net:
  allow:
    0.0.0.0/0:

state sls for templating definition

chrony_rpm-redos-config:
  file.managed:
    - user: root
    - group: root
    - mode: '0644'
    - template: jinja
    - names:
        - /etc/chrony.conf:
          - source: salt://files/chrony/redos/chrony.conf

Tests with manual checking pillar.get

[root@salt]# salt 'salt.local' pillar.get ntp
salt.local:
    ----------
    allow:
        ----------
        0.0.0.0/0:
            None
    servers:
        ----------
        ntp.host1.net:
            None
        ntp.host2.net:
            None
        ntp1.host2.net:
            None


[root@salt ~]# salt 'salt.local' pillar.get ntp:servers
salt.local:
    ----------
    ntp.host1.net:
        None
    ntp.host2.net:
        None
    ntp1.host2.net:
        None

template part - not works as expected, returns None and sure no .items etc methods/substructures

#
{% for x,y in pillar.get('ntp:servers').items() %}
server {{ x }} iburst
{% endfor %}
#

But it's works if called with root element and driven to substructures in code. Therefore it's not definitely intended behavior cause other substructures can contain a LOT of data and even auto refresh of pillar data is disabled in saltstack due to this.

#
{% for x,y in pillar.get('ntp').servers.items() %}
server {{ x }} iburst
{% endfor %}
#

Expected behavior
Expected to get data substructures from yaml as described in pillar.get usage manual with : delimiter

#
{% for x,y in pillar.get('ntp:servers').items() %}
server {{ x }} iburst
{% endfor %}
#

iterated over .ntp.servers yaml path items, but it's returns None while directly calling salt 'host' pillar.get ntp:servers returns correct data

Versions Report
Salt Version:
Salt: 3007.0

Python Version:
Python: 3.11.10 (main, Sep 9 2024, 00:00:00) [GCC 12.4.1 20240730 (RED SOFT 12.4.0-1)]

Dependency Versions:
cffi: 1.15.1
cherrypy: unknown
dateutil: 2.8.2
docker-py: 5.0.3
gitdb: Not Installed
gitpython: Not Installed
Jinja2: 3.1.3
libgit2: Not Installed
looseversion: 1.3.0
M2Crypto: Not Installed
Mako: Not Installed
msgpack: 1.0.4
msgpack-pure: Not Installed
mysql-python: Not Installed
packaging: 24.1
pycparser: 2.20
pycrypto: Not Installed
pycryptodome: 3.15.0
pygit2: Not Installed
python-gnupg: 0.5.0
PyYAML: 6.0.1
PyZMQ: 23.2.0
relenv: Not Installed
smmap: Not Installed
timelib: 0.3.0
Tornado: 6.3.3
ZMQ: 4.3.4

Salt Package Information:
Package Type: Not Installed

System Versions:
dist: redos 8.0 n/a
locale: utf-8
machine: x86_64
release: 6.6.51-1.red80.x86_64
system: Linux
version: RED OS 8.0 n/a

But OS does not matters, reproducable on any host with same version, e.g. Ubuntu22, OEL8...

@freemjohn freemjohn added Bug broken, incorrect, or confusing behavior needs-triage labels Jan 14, 2025
Copy link

welcome bot commented Jan 14, 2025

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.
Please be sure to review our Code of Conduct. Also, check out some of our community resources including:

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.
If you have additional questions, email us at [email protected]. We’re glad you’ve joined our community and look forward to doing awesome things with you!

@freemjohn freemjohn changed the title [BUG] pillar.get on substructure is broken or i'm donig something wrong? [BUG] pillar.get on substructure is broken or i'm doing it wrong? Jan 14, 2025
@frebib
Copy link
Contributor

frebib commented Jan 14, 2025

You want salt.pillar.get('ntp:servers') as that calls the execution module function pillar.get.
Calling pillar.get(..) is actually acting on the dict named pillar and is the standard python .get() function

@freemjohn
Copy link
Author

You want salt.pillar.get('ntp:servers') as that calls the execution module function pillar.get. Calling pillar.get(..) is actually acting on the dict named pillar and is the standard python .get() function

Well, so where i can find API docs? There is no mention of salt. functions at all. Only pillar.get there https://docs.saltproject.io/en/latest/topics/tutorials/pillar.html#more-complex-data
And btw why pillar.get functions differs from module pillar.get? It's first time i've seen difference from modules/states methods.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug broken, incorrect, or confusing behavior needs-triage
Projects
None yet
Development

No branches or pull requests

2 participants