Saltstack managing the directory structure of the five Saltstack

Source: Internet
Author: User
Tags saltstack

Directory Structure of the Saltstack




Describe:

When we are learning automation operations tools, whether it is puppet or saltstack, to be proficient in use, we must first understand their directory structure, overall: Puppet and salt directory structure is very similar






The first part:

File_roots configuration-Managed directory structure:

Premise:

Using the configuration-managed directory structure, first configure it in the configuration file:

Vi/etc/salt/master

Find File_roots, about 31 lines

Add to:

file_roots:

Base

-/srv/salt

/etc/init.d/salt-master restart

Note: as can be seen from the above configuration, the root directory of configuration management is /srv/salt



Analysis:

The following is an analysis of the directory structure of configuration management/srv/salt:

[Email protected] salt]# Cd/srv/salt

[Email protected] salt]# tree

.

├──top.sls

└──web

├──files

│├──httpd.conf

│└──php.ini

├──httpd.sls

├──init.sls

└──php

└──conf.sls



1. entry file Top.sls:

In the/srv/salt/directory there is a portal file Top.sls, when the master service is started, the master process will first read the portal file

[email protected] salt]# cat Top.sls

Base

‘*‘:

-Web

First line: A fixed notation for the Top.sls file

Second line: Specify the Minion machine to be managed, * on behalf of all the Minion machine (must be quoted), if only one Minion machine, you can specify its IP, such as: ' 192.168.186.129 '

Line three: Specify the template to read, define a Web template (that is, create a web directory under the/srv/salt/directory), and define multiple template catalogs

Note: the first and second lines are followed by a colon

The second line specifies the Minion machine to be managed, which can be matched by a regular, grain module or group name, as follows:

To match by regular:

Base

‘*‘:

-Web


To match by grouping: must have-match:nodegroup

Base

' Bjwebgroup ':

-Match:nodegroup

-Web


Match by Grain module: must have-match:grain

Base

' Os:centos ':

-Match:grain

-Web



2. Template directory :

A Web Template directory is defined in the portal file Top.sls, so we will create a Web directory:

[Email protected] salt]# pwd

/srv/salt

[Email protected] salt]# mkdir web


[Email protected] salt]# CD web/

[Email protected] web]# VI Init.sls

Include

-WEB.HTTPD

-Web.php.conf

Note:The Init.sls file can be viewed simply as a template's entry file

This Init.sls file is read first when the template is called, so be sure to create this Init.sls file

First line: Fixed usage, means: Call the file defined below

Second line: Call the Httpd.sls file under the Web Template directory (so there is a Httpd.sls file in the Web directory)

Third line: Call the Web Template directory under the PHP directory Conf.sls file (so there is a PHP directory under the Web directory, in the PHP directory has a Conf.sls file)


[Email protected] web]# pwd

/srv/salt/web

[[email protected] web]# ls

Files Httpd.sls Init.sls php

As above: We need to create a Httpd.sls file, mkdir a PHP directory

Files directory can have no, mainly used to store some configuration files (can not be considered first)

Simply look at the contents of the Httpd.sls file:

[email protected] web]# cat Httpd.sls

httpd

Pkg

-Installed

Service

-Running

-Require:

-PKG:HTTPD


/tmp/salt/httpd.conf:

File

-Managed

-Source:salt://web/files/httpd.conf

-Require:

-PKG:HTTPD







Part II:

Pillar_roots variables related to the directory structure:





















This article is from the "See" blog, please be sure to keep this source http://732233048.blog.51cto.com/9323668/1640899

Saltstack managing the directory structure of the five Saltstack

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.