Rookie play Cloud computing 21: Saltstack's Pillar
Reference:
Click to open link
View Pillar Data:
# salt ' * ' Pillar.items
The default root directory for pillar in:/srv/pillar, you can change the configuration file/etc/salt/master with the following parameters:
Pillar_roots:your_dir
Build the following pillar root directory and create the Portal file: Top.sls
# mkdir/srv/pillar# Vi/srv/pillar/top.sls
Top.sls:
Base: ' * ': -Data
The above entry file specifies the/srv/pillar/data.sls file, which applies to all minions. (‘*‘).
Data.sls:
Info:somedata
Refresh the pillar of all nodes:
# salt ' * ' saltutil.refresh_pillar
202:
True
203:
True
Look at the pillar of the node again:
# salt ' * ' Pillar.items
202:
----------
Info
Some data
...
203:
----------
Info
Some data
...
If you create a subdirectory users/below/srv/pillar/, you can refer directly to Init.sls in Top.sls. For example:
# mkdir/srv/pillar/users# Vi/srv/pillar/users/init.sls
Init.sls content is as follows:
Users: jhonson:2001 tom:2993 peter:3098 tex:18990
In order to be able to refer to users in Top.sls, you need to change to:
Base: ' * ': -Data -users
Refresh and display:
# salt ' * ' saltutil.refresh_pillar# salt ' * ' Pillar.item users
203:
----------
Users
----------
Jhonson:
2001
Peter
2098
Tex
18900
Tom
2993
202:
----------
Users
----------
Jhonson:
2001
Peter
2098
Tex
18900
Tom
2993
One more example:
# mkdir/srv/pillar/hadoop# Vi/srv/pillar/hadoop/params.sls
Params.sls:
HDFs: namenode:192.168.122.201 stadbynode:192.168.122.202hbase: master:192.168.122.201
# Vi/srv/pillar/top.sls
Top.sls:
Base: ' * ': -Data -users -Hadoop.params
Test using:
# salt ' * ' saltutil.refresh_pillar# salt ' * ' Pillar.items
Rookie play Cloud computing 21: Saltstack's Pillar