Salt's pillar component

Source: Internet
Author: User

Pillar is also one of the most important components of salt, and its role is to define any data related to the controlled host, and the defined data can be used by other components, such as templates, State, API, etc. The data defined in pillar is associated with the host of different business characteristics, so that the host can only see their own matching data, so pillar security is very high , suitable for some more sensitive data, which is different from grains the most critical point, such as defining the user ID, group ID, read and Write permissions, packages and other information of different business group hosts, the specification defined is in the form of a Python dictionary, that is, the key/value, the topmost key is usually the host's ID or group name.

Definition of pillar:

1. Master Profile Definition

Salt by default, all data in the master configuration file is defined in pillar, and open to all controlled hosts, you can define whether to open an account or disable this feature by modifying Pillar_opts:true or False in the/etc/salt/master configuration. Modify and then execute the salt ' * ' pillar.data to observe the effect.

2. sls file definition

Pillar supports defining data in a Slsy file, in a format that conforms to the YAML specification and is very similar to the salt and state components, with the same configuration format and entry file Top.sls of the file.

(1) Define Pillar's home directory

Modify the Pillar_roots parameter of the main profile/etc/salt/master, define the pillar home directory

Create pillar directory at the same time, execute command: install-d/srv/pillar

(2) Define the entry file Top.sls

The role of the portal file is generally defined as the pillar data coverage of the host's valid domain range, "*" represents any host, including a Data.sls file,

/srv/pillar/top.sls

Base

‘*‘:

-Data

/srv/pillar/data.sls

Appname:website

Flow

maxconn:30000

maxmem:6g

(3) Check pillar

The DATA.SLS data item defined above can be seen with the salt ' myhost ' pillar.data appname flow command. If the results do not meet expectations, you can try to refresh the pillar data of the managed machine.

Run Salt ' myhost ' saltutil.refresh_pillar to refresh

3, the use of pillar

After completing the pillar configuration, we can then refer to the state, template file, template format "{{pillar variable}}", for example:

{{pillar[' appname '}} (A dictionary of a level)

{{pillar[' flow ' [' Maxconn ']}} (Level two dictionary) or {{salt[' pillar.get '] (' flow:maxconn '), {}}}

The Python API format is as follows:

pillar[' flow ' [' Maxconn ']

Pillar.get (' Flow:appname ', {})

Salt's pillar component

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.