salt icon indicating copy to clipboard operation
salt copied to clipboard

2015.5.3 Pillar include under nested key is broken

Open deuscapturus opened this issue 11 years ago • 7 comments

Problem is here https://github.com/saltstack/salt/blob/2015.5/salt/pillar/init.py#L418 Variable v is getting value of None.

pillar:

include:
  - narwhal:
    key: narwhal

error:

2015-09-01 10:45:36,531 [salt.loaded.int.render.yaml][DEBUG   ][32707] Results of YAML rendering: 
OrderedDict([('include', [OrderedDict([('narwhal', None), ('key', 'narwhal')])])])
2015-09-01 10:45:36,532 [salt.master      ][ERROR   ][32707] Error in function _pillar:
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/salt/master.py", line 1457, in run_func
    ret = getattr(self, func)(load)
  File "/usr/lib/python2.7/site-packages/salt/master.py", line 1220, in _pillar
    data = pillar.compile_pillar(pillar_dirs=pillar_dirs)
  File "/usr/lib/python2.7/site-packages/salt/pillar/__init__.py", line 579, in compile_pillar
    pillar, errors = self.render_pillar(matches)
  File "/usr/lib/python2.7/site-packages/salt/pillar/__init__.py", line 452, in render_pillar
    pstate, mods, err = self.render_pstate(sls, saltenv, mods)
  File "/usr/lib/python2.7/site-packages/salt/pillar/__init__.py", line 415, in render_pstate
    defaults = v.get('defaults', {})
AttributeError: 'NoneType' object has no attribute 'get'

deuscapturus avatar Sep 01 '15 16:09 deuscapturus

@deuscapturus, thanks for the report.

jfindlay avatar Sep 01 '15 18:09 jfindlay

Did this ever work? I don't know that this is a bug, this looks like bad syntax in the pillar sls file

thatch45 avatar Sep 08 '15 17:09 thatch45

Yes, this did work in the past. It's been in the documentation for a long time as well. https://docs.saltstack.com/en/latest/topics/pillar/#including-other-pillars

This feature solves a lot of big problems for us. Example: Making pillar data available to a Jenkins server to get application settings for a build process without colliding with other pillars or duplicating the pillars.

deuscapturus avatar Sep 08 '15 21:09 deuscapturus

I'm hitting this issue as well if I use the import key like shown in the example that @deuscapturus posted up top.

[edit: remove my previous guess at what was wrong, since after testing I was wrong]

acornett avatar Oct 08 '15 16:10 acornett

Here is my traceback using 2015.5.5 on CentOS 7

2015-10-08 12:10:26,031 [salt.master      ][ERROR   ][2274] Error in function _pillar:
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/salt/master.py", line 1460, in run_func
    ret = getattr(self, func)(load)
  File "/usr/lib/python2.7/site-packages/salt/master.py", line 1223, in _pillar
    data = pillar.compile_pillar(pillar_dirs=pillar_dirs)
  File "/usr/lib/python2.7/site-packages/salt/pillar/__init__.py", line 583, in compile_pillar
    pillar, errors = self.render_pillar(matches)
  File "/usr/lib/python2.7/site-packages/salt/pillar/__init__.py", line 456, in render_pillar
    pstate, mods, err = self.render_pstate(sls, saltenv, mods)
  File "/usr/lib/python2.7/site-packages/salt/pillar/__init__.py", line 419, in render_pstate
    defaults = v.get('defaults', {})
AttributeError: 'NoneType' object has no attribute 'get'

acornett avatar Oct 08 '15 16:10 acornett

Isn't this an indentation problem in the pillar file? Can you try it like follows?

include:
  - narwhal:
      key: narwhal

With the exact example posted in the original post, the same error happens on < 2015.5.5

frits-v avatar Oct 27 '15 23:10 frits-v

@frots, good catch! It looks like that does resolve the issue for my usage at least.

acornett avatar Oct 28 '15 02:10 acornett