pillar.item and pillar.items how are they different?

965 views
Skip to first unread message

Paul Mulvihill

unread,
Dec 4, 2015, 5:40:27 AM12/4/15
to Salt-users
Hi Everyone

I'm trying to get my head around something and would appreciate extra  experienced eyes.
I'm currently setting a Pillar value called eid (environment id) and using it within checks in other states/pillars.
Although I'm seeing some behavior that is just confusing me a little.

In my states I use the pillar.get command to pull the value back out. Although when I manually call this value using the below ways I get different results.
  pillar.item eid
  pillar.items eid
  piller.items
so.. right now the value is actually set to this in the pillar file.
eid:
  stg

however.... when I'm on the salt master I get the following.
[root@salt ~]# salt 'salt-stuart' pillar.item eid
salt-stuart:
    ----------
    eid:
        dev
[root@salt ~]# salt 'salt-stuart' pillar.items eid
salt-stuart:
    ----------
    eid:
        dev

if i then run straight pillar.items and scroll back up I see the following
[root@salt ~]# salt 'salt-stuart' pillar.items

    eid:
        stg

(other lines removed as irrelivant)

If i run a refresh pillar command it does bring them all inline. but why are they different in the first place?


If i go onto the salt-stuart minion (prior to pillar refresh) and run the same commands they all return stg back.

[root@salt-stuart minion.d]# salt-call pillar.item eid
local:
    ----------
    eid:
        stg
[root@salt-stuart minion.d]# salt-call pillar.items eid
local:
    ----------
    eid:
        stg
[root@salt-stuart minion.d]# salt-call pillar.items
..........
    eid:
        stg
.............

Am I missing something?
I thought Pillar data didn't auto refresh to the minions unless via a highstate or refresh command, if so why is the minion right but the master wrong?
Also how can I check which value is actually being used in my states/pillars if i can't get a consistent output on the master.

my goal is to set a CMEnforce pillar value which will include a scheduled highstate or not. This isn't working and now I'm not sure which pillar value it's actually checking against.

Any thoughts?

Thanks

Paul





Daniel Jagszent

unread,
Dec 4, 2015, 9:56:31 AM12/4/15
to salt-...@googlegroups.com

Hi Paul,

I thought Pillar data didn't auto refresh to the minions unless via a highstate or refresh command, if so why is the minion right but the master wrong?

You are using salt-call to get the pillar on the minion. salt-call always uses a fresh pillar (as it directly communicates with the master and not the local minion daemon, so it does not have a cached copy of the pillar that it can use).
The minion daemon on the other hand has a cached copy of the pillar and uses this unless you call pillar.items. The pillar.item module function (as well as pillar.raw and pillar.get) use the cached version of the pillar.
To refresh the cached version of the pillar data, you have to use saltutil.refresh_pillar (that gets automatically called on a state.highstate). Unless you call this module function (saltutil.refresh_pillar), pillar.item, pillar.raw and pillar.get all use the cached version of the pillar, even after you called pillar.items.

Calling pillar.items with an argument is actually deprecated. Internally it just redirects to pillar.item. That is why pillar.items with or without arguments behaves differently.
( see https://github.com/saltstack/salt/blob/develop/salt/modules/pillar.py#L104-L105 )

Paul Mulvihill

unread,
Dec 9, 2015, 9:18:13 AM12/9/15
to Salt-users
Hi Daniel

Awesome thanks for the reply. that makes it alot clearer.

Thanks

Paul
Reply all
Reply to author
Forward
0 new messages