Skip to content
This repository has been archived by the owner on Oct 12, 2020. It is now read-only.

08. pillars

Khelil Sator edited this page Jan 22, 2018 · 5 revisions

Pillars are user defined variables:

  • sls files.
  • There is a top file.
    • top.sls file map minions to sls files.
  • default location for the pillars is in /srv/pillar.
  • The pillar location can be configured via the pillar_roots option inside the master configuration file.

master configuration file:
The configuration file for the salt-master is located at /etc/salt/master by default.

# more /etc/salt/master 
...
pillar_roots:
 base:
  - /srv/pillar
...

pillar folder:

# ls /srv/pillar/
common_settings.sls   top.sls             vsrx01-details.sls
ex4200-7-details.sls  vqfx01-details.sls

top file (map minions/proxies to sls files):

# more /srv/pillar/top.sls 
base:
  'ex4200-7':
     - ex4200-7-details
  'vsrx01':
     - vsrx01-details
  'vqfx01': 
     - vqfx01-details

pillars for proxyid vqfx01:

# more /srv/pillar/vqfx01-details.sls 
proxy:
      proxytype: junos
      host: 192.168.233.158
      username: root
      port: 8331
      passwd: Juniper
# salt "vq*" pillar.items
vqfx01:
    ----------
    proxy:
        ----------
        host:
            192.168.233.158
        passwd:
            Juniper
        port:
            8331
        proxytype:
            junos
        username:
            root

pillars for proxyid ex4200-7:

# more /srv/pillar/ex4200-7-details.sls 
proxy:
      proxytype: junos
      host: 172.30.179.107
      username: pytraining
#      port: 830
      passwd: Poclab123

name: testdevicename

include: 
  - common_settings
# more /srv/pillar/common_settings.sls 
name-server: 
 - 172.30.207.10
 - 172.30.179.2

banner: this is the banner

The below commands work only if you have a minion namedex4200-7, and if you accepted it. Or if you have a minion namedex4200-7 and if you enabled the auto accept feature in the salt master configuration file.
The below command prints the pillars (humans defined variables) for an existing minion. It doesn’t create a new minion and it doesn't accept a existing minion.

# salt ex4200-7 pillar.items
ex4200-7:
    ----------
    banner:
        this is the banner
    name:
        testdevicename
    name-server:
        - 172.30.207.10
        - 172.30.179.2
    proxy:
        ----------
        host:
            172.30.179.107
        passwd:
            Poclab123
        proxytype:
            junos
        username:
            pytraining
# salt ex4200-7 pillar.items proxy
ex4200-7:
    ----------
    proxy:
        ----------
        host:
            172.30.179.107
        passwd:
            Poclab123
        proxytype:
            junos
        username:
            pytraining