#在top.sls中定义对系统是CentOS的服务之星web.apached定义的状态信息
[iyunv@linux-node1 ~]# vim /srv/salt/base/top.sls
base:
'os:CentOS':
- match: grain
- web.apache
[iyunv@linux-node1 ~]# salt '*' state.highstate
linux-node2.example.com:
----------
ID: apache-install
Function: pkg.installed
Name: httpd
Result: True
Comment: All specified packages are already installed
Started: 14:28:57.612549
Duration: 2490.712 ms
Changes:
----------
ID: apache-service
Function: service.running
Name: httpd
Result: True
Comment: The service httpd is already running
Started: 14:29:00.104396
Duration: 41.901 ms
Changes:
Summary for linux-node2.example.com
------------
Succeeded: 2
Failed: 0
------------
Total states run: 2
Total run time: 2.533 s
linux-node1.example.com:
----------
ID: apache-install
Function: pkg.installed
Name: httpd
Result: True
Comment: All specified packages are already installed
Started: 14:29:12.061257
Duration: 11458.788 ms
Changes:
----------
ID: apache-service
Function: service.running
Name: httpd
Result: True
Comment: The service httpd is already running
Started: 14:29:23.520720
Duration: 46.868 ms
Changes:
apache-service:
service.running:
- name: {{ pillar['apache'] }}
- enable: True
[iyunv@linux-node1 ~]# salt '*' state.highstate
linux-node2.example.com:
----------
ID: apache-install
Function: pkg.installed
Name: httpd
Result: True
Comment: All specified packages are already installed
Started: 15:15:13.424547
Duration: 940.333 ms
Changes:
----------
ID: apache-service
Function: service.running
Name: httpd
Result: True
Comment: The service httpd is already running
Started: 15:15:14.366780
Duration: 55.706 ms
Changes:
Summary for linux-node2.example.com
------------
Succeeded: 2
Failed: 0
------------
Total states run: 2
Total run time: 996.039 ms
linux-node1.example.com:
----------
ID: apache-install
Function: pkg.installed
Name: httpd
Result: True
Comment: All specified packages are already installed
Started: 15:15:14.648492
Duration: 8242.769 ms
Changes:
----------
ID: apache-service
Function: service.running
Name: httpd
Result: True
Comment: The service httpd is already running
Started: 15:15:22.891907
Duration: 42.651 ms
Changes:
Summary for linux-node1.example.com
------------
Succeeded: 2
Failed: 0
------------
Total states run: 2
Total run time: 8.285 s