Table of contents
1.
Introduction
2.
Salt
3.
Advantages of Pillar Data
4.
Setting Up Pillar
5.
Parameterizing States with Pillar
6.
Pillar Makes Simple States Grow Easily
7.
Minion Config in Pillar
8.
Frequently Asked Questions
8.1.
What are pillars in Salt stack?
8.2.
How does SaltStack utilize pillars?
8.3.
What is SaltStack's top SLS?
8.4.
Is SaltStack push or pull?
8.5.
Where are Salt states stored?
9.
Conclusion
Last Updated: Aug 13, 2025
Medium

Pillar Walkthrough

Author Mayank Goyal
0 upvote
Career growth poll
Do you think IIT Guwahati certified course can help you in your career?

Introduction

Pillard is a tree-like data structure defined by salt masters that are passed on to minions. Pillar enables the secure transmission of specific, confidential data to the appropriate minion.Pillars and Grains are commonly confused. Remember that Grains are information about a minion that is saved or generated from the minion. Because of this, grains contain information on the OS and CPU type. Pillar is data on one or more minions that are generated or saved on the Salt Master.

pillar walkthrough

Before going through the Pillar walkthrough article, the reader must know about Salt.

Salt

Salt is an innovative method of managing infrastructure based on the notion that rapid communication with many systems might create new possibilities. With this method, Salt becomes a powerful multitasking system that can address many infrastructure-specific issues.

The remote execution engine, which builds a fast, secure, and bi-directional communication net for systems in groups, is the heart of Salt. Salt offers an incredibly quick, adaptable, and user-friendly configuration management solution, Salt States, on top of this communication infrastructure.

Now we know about Salt, let’s get started with the Pillar.

Advantages of Pillar Data

Feature Description
Highly Sensitive Data Since information transmitted via Pillar is guaranteed only to be seen by the intended minions, it is appropriate for managing security information, such as cryptographic keys and passwords.
Minion Configuration It is frequently possible to configure Minion modules, such as the execution modules, states, and returners, using data stored in a pillar.
Variables Through Pillar, variables that must be assigned to particular minions or groups of minions can be defined. From there, the variables can then be accessible in sls formulae and template files.
Arbitrary Data Pillar may store any fundamental data structure in dictionary form, allowing for developing a key/value store that makes it simple to iterate over a set of values in sls formulas.

So when utilizing Salt, one of the most crucial systems is the Pillar. This article aims to quickly set up a straightforward Pillar before delving into its features and the locations of the data sources.

Setting Up Pillar

By default, Salt is already running the Pillar. To view the pillar data for the minion:

salt '*' pillar.items


By default, all minions' pillars are loaded with the contents of the master configuration file. This makes it possible to configure minions globally using the master configuration file.

The Pillar is made of sls files and has a top file, just like the state tree. The Pillar is located by default in /srv/pillar.

The presence of the /srv/pillar directory is required to begin configuring the Pillar:

mkdir /srv/pillar


Next, make a straightforward top file using the same format as the top file for the states:

/srv/pillar/top.sls:
base:
  '*':
    - data


The data.sls file is linked to all minions by this top file. The /srv/pillar/data.sls file must now be populated out:

/srv/pillar/data.sls


Send a command to the minions instructing them to retrieve their pillars from the master to guarantee that they have the new pillar data:

salt '*' saltutil.refresh_pillar


It can now be retrieved since the minions have the new Pillar:

salt '*' pillar.items


The returned pillar data should now include the key information.

Parameterizing States with Pillar

To customize each minion's behavior, state files can access pillar data. Each minion's specific pillar (and grain) data is substituted into the state files through templating before being executed. Common applications include configuring directories suitable for the minion and bypassing irrelevant stages.

Setting up a mapping of package names for several Linux distributions in the Pillar is a straightforward example:

/srv/pillar/pkg/init.sls
base:
  '*':
    - data
    - users
    - pkg


The minions will automatically map values inside the Pillar based on the corresponding operating systems, allowing sls files to be parameterized safely.

/srv/salt/apache/init.sls:
apache:
  pkg.installed:
    - name: {{ pillar['pkgs']['apache'] }}


If the pillar value pillar['pkgs']['apache'] is not set in the minion's Pillar in the example above, then HTTPS will be utilized by default.

Pillar Makes Simple States Grow Easily

One of the design objectives of Pillar is to enable the easy expansion of straightforward sls formulas into more flexible formulas without modifying or adding complexity to the states.

An easy formula:

/srv/salt/edit/vim.sls:
vim:
  pkg.installed: []

/etc/vimrc:
  file.managed:
    - source: salt://edit/vimrc
    - mode: 644
    - user: root
    - group: root
    - require:
      - pkg: vim


Easily convertible into a strong, parameterized formula

/srv/salt/edit/vim.sls:
vim:
  pkg.installed:
    - name: {{ pillar['pkgs']['vim'] }}
/etc/vimrc:
  file.managed:
    - source: {{ pillar['vimrc'] }}
    - mode: 644
    - user: root
    - group: root
    - require:
      - pkg: vim


Where the vimrc source location can now be changed via Pillar:

/srv/pillar/edit/vim.sls:

{% if grains['id'].startswith('dev') %}
vimrc: salt://edit/dev_vimrc
{% elif grains['id'].startswith('qa') %}
vimrc: salt://edit/qa_vimrc
{% else %}
vimrc: salt://edit/vimrc
{% endif %}


The Salt master generates pillar data, which is then safely transferred to minions. When defining the Pillar, Salt can retrieve data from outside sources and is not limited to the pillar sls files. This can be helpful when data concerning infrastructure is kept in a different place.

Minion Config in Pillar

Options for Minion setup can be placed on pillars. Similar to how you configure the choices in the config file, any option you want to change should be in the first level of the pillars. For instance, to set the MySQL Salt execution module's MySQL root password configuration:

mysql.pass: hardtoguesspassword


This is quite practical when you need to make a dynamic configuration change that you want to apply immediately. There is a chicken-and-egg issue, for instance, if you carry out the following:

mysql-admin-passwd:
  mysql_user.present:
    - name: root
    - password: somepasswd
mydb:
  mysql_db.present


Because you altered the root password and the minion missed it, the second state will not succeed. Fixing the problem by setting mysql.pass in the Pillar. However, changing the root admin password would help if you always started.

That’s all from the article. Let’s see some frequently asked questions to discuss what we learned in this article.

Check out this article - Converting NFA to DFA

Frequently Asked Questions

What are pillars in Salt stack?

Using targets, the Salt Pillar system enables you to construct safe data that can be "assigned" to one or many minions. Values, including ports, file locations, configuration options, and passwords, are stored in salt pillar data.

How does SaltStack utilize pillars?

The pillar roots option in the master configuration file allows the pillar location to be set. It cannot be found in the state tree or file roots subdirectories. Minions can avoid any pillar targeting if it is under file roots. The returned pillar data should now include the key information.

What is SaltStack's top SLS?

The file that maps out which configuration roles should be applied to which groups of machines on a network is referred to as a top file in Salt. Top files always exist at the "top" of a directory hierarchy that contains state files, hence their default name of the top.sls.

Is SaltStack push or pull?

One example of a push-based configuration management tool that necessitates the installation of an agent (minion) on the nodes is SaltStack. In both situations, the main server initiates contact and delivers configuration information to the nodes without their request.

Where are Salt states stored?

On the master, states are kept in text files periodically sent over the master's file server to the minions. The State Tree is made up of several state files.

Conclusion

This article taught us about the Pillar and a brief overview of Salt. Later, we looked into the advantages of pillar data. Lastly, we learned how to set up pillar and minion configuration.

Refer to our Guided Path on Coding Ninjas Studio to upskill yourself in Data Structures and AlgorithmsCompetitive ProgrammingJavaScriptSystem DesignOperating SystemCompiler DesignAutomata Theory, and many more! If you want to test your competency in coding, check out the mock test series and participate in the contests hosted on Coding Ninjas Studio!

Nevertheless, consider our paid courses to give your career an edge over others.

Live masterclass