saltstack(六):saltstack配置管理-高级状态top.sls

saltstack(六):saltstack配置管理-高级状态top.sls

1.1  高级状态top.sls

如果我有很多sls文件,并不能一个文件一个文件执行的.这时就需要高级状态了.

这时候就需要top.sls入口文件了.

你可以打开vim /etc/salt/master文件查看高级状态的配置,如下图.

这个top.sls文件需要建立在file_root的base环境下面.

也就是 /src/salt/base/top.sls 如下.

base:   #环境名称
  'pe-db':
    - web.apache
  'test-tms':
    - web.apache

 

编辑好后,执行下面的命令.

[root@pe-jira base]# salt -E 'pe-db|test-tms' state.highstate
pe-db:
----------
          ID: apache-install
    Function: pkg.installed
        Name: httpd
      Result: True
     Comment: Package httpd is already installed.
     Started: 10:24:15.240027
    Duration: 817.036 ms
     Changes:
----------
          ID: apache-service
    Function: service.running
        Name: httpd
      Result: True
     Comment: Service httpd is already enabled, and is in the desired state
     Started: 10:24:16.057928
    Duration: 243.124 ms
     Changes:

Summary
------------
Succeeded: 2
Failed:    0
------------
Total states run:     2
test-tms:
----------
          ID: apache-install
    Function: pkg.installed
        Name: httpd
      Result: True
     Comment: The following packages were installed/updated: httpd
     Started: 10:24:14.839477
    Duration: 21092.645 ms
     Changes:
              ----------
              apr:
                  ----------
                  new:
                      1.4.8-3.el7_4.1
                  old:
              apr-util:
                  ----------
                  new:
                      1.5.2-6.el7
                  old:
              httpd:
                  ----------
                  new:
                      2.4.6-89.el7.centos
                  old:
              httpd-tools:
                  ----------
                  new:
                      2.4.6-89.el7.centos
                  old:
              mailcap:
                  ----------
                  new:
                      2.1.41-2.el7
                  old:
----------
          ID: apache-service
    Function: service.running
        Name: httpd
      Result: True
     Comment: Service httpd has been enabled, and is running
     Started: 10:24:35.951348
    Duration: 989.74 ms
     Changes:
              ----------
              httpd:
                  True

Summary
------------
Succeeded: 2 (changed=2)
Failed:    0
------------
Total states run:     2
[root@pe-jira base]#
posted on 2019-05-31 10:58  光阴8023  阅读(1164)  评论(0编辑  收藏  举报