I need to organize my pillars into sub-directories.
/srv/pillar/
├── app1
│ └── env1
│ └── conf.sls
├── data.sls
└── top.sls
I've put in top.sls:
base:
'*':
- data
- app1/env1/conf
When I request data.sls for variable info
, it works :
salt '*' pillar.get info
local:
some data
But when I request conf.sls for variable info
, nothing works:
salt '*' pillar.get app1.env1.info
shows nothing !
I already executed:
saltutil.refresh_pillar
and restarted salt process.
What should I do to make salt pillars recognize sub directories ?
There are several misconceptions in your example. Organizing your pillar files in subdirectories does not translate into a namespace on the resulting pillar variable. The variables in the subdirectory-nested-pillar file will still be at the root of the pillar dict.
To include subdirectories in your pillar top.sls file, you use dot notation:
Create pillar so/test/example.sls
cd /srv/pillar
mkdir -p so/test
echo 'foo: bar' > so/test/example.sls
Edit top.sls
base:
'*':
- users
lead:
- so.test.example
Refresh pillar on minion 'lead'
$ sudo salt lead saltutil.refresh_pillar
lead:
None
Extract value of foo from pillar
$ sudo salt lead pillar.get foo
lead:
bar
If you want to namespace the variable in the pillar dict, express that in so/test/example.sls:
$ cat /srv/pillar/so/test/examples.sls
so:
test:
foo: bar
$ sudo salt lead pillar.get so --out=json
{
"lead": {
"test": {
"foo": "bar"
}
}
}
$ sudo salt lead pillar.get so:test:foo --out=json
{
"lead": "bar"
}