saltstack / salt

Software to automate the management and configuration of any infrastructure or application at scale. Get access to the Salt software package repository here:
https://repo.saltproject.io/
Apache License 2.0
14.15k stars 5.48k forks source link

Pillar: include item uses key from other item #55070

Open veym4os opened 4 years ago

veym4os commented 4 years ago

Description

When using include statements with and without specified "key" property in the same file, an include without key can get the value of another include item. This happens only, if the include key is set after an include without key.

Steps to reproduce

Only pillar required:

# basic.sls
include:
  - something
  - something_else:
      key: some_key
# something.sls
something: value
# something_else.sls
something_else: other value

Expected output:

# salt-call pillar.items
local:
    ----------
    something:
        some value
    something_else:
        other value

Observed output:

# salt-call pillar.items
local:
    ----------
    some_key:
        ----------
        something:
            some value
        something_else:
            other value

I have also tried to manually overwrite the key for the first include with the following options. This had no effect:

- something:
    key: ~
---
- something: {}
---
- something:
    key: ""

Changing the input order leads to the expected result:

# basic.sls
include:
  - something_else:
      key: some_key
  - something

Versions Report

# salt --versions-report
Salt Version:
           Salt: 2019.2.0

Dependency Versions:
           cffi: 1.6.0
       cherrypy: Not Installed
       dateutil: Not Installed
      docker-py: Not Installed
          gitdb: Not Installed
      gitpython: Not Installed
          ioflo: Not Installed
         Jinja2: 2.7.2
        libgit2: Not Installed
        libnacl: Not Installed
       M2Crypto: 0.31.0
           Mako: Not Installed
   msgpack-pure: Not Installed
 msgpack-python: 0.5.6
   mysql-python: Not Installed
      pycparser: 2.14
       pycrypto: 2.6.1
   pycryptodome: Not Installed
         pygit2: Not Installed
         Python: 2.7.5 (default, Aug  7 2019, 08:19:52)
   python-gnupg: 0.4.3
         PyYAML: 3.11
          PyZMQ: 15.3.0
           RAET: Not Installed
          smmap: Not Installed
        timelib: Not Installed
        Tornado: 4.2.1
            ZMQ: 4.1.4

System Versions:
           dist: oracle 7.7 
         locale: UTF-8
        machine: x86_64
        release: 4.1.12-124.32.3.el7uek.x86_64
         system: Linux
        version: Oracle Linux Server 7.7 
xeacott commented 4 years ago

Okay so I can reproduce this, and based on the output it seems like a simple logic error when using pillar and keys. Thanks for submitting.

hramrach commented 4 months ago

Can't reproduce with

Salt Version: Salt: 3006.0

Python Version: Python: 3.6.15 (default, Sep 23 2021, 15:41:43) [GCC]

Dependency Versions: cffi: 1.13.2 cherrypy: Not Installed dateutil: Not Installed docker-py: Not Installed gitdb: Not Installed gitpython: Not Installed Jinja2: 2.10.1 libgit2: Not Installed looseversion: 1.0.2 M2Crypto: 0.38.0 Mako: Not Installed msgpack: 0.5.6 msgpack-pure: Not Installed mysql-python: Not Installed packaging: 21.3 pycparser: 2.17 pycrypto: Not Installed pycryptodome: Not Installed pygit2: Not Installed python-gnupg: Not Installed PyYAML: 5.4.1 PyZMQ: 17.1.2 relenv: Not Installed smmap: Not Installed timelib: Not Installed Tornado: 4.5.3 ZMQ: 4.2.3