benzhou 发表于 2018-1-3 22:33:08

06-saltstack 之grains

# vim /etc/salt/master    # 注释取消,定义路径  
file_roots:
  base:
  - /srv/salt
  

  

  
# vim /srv/salt/top.sls   # 编写top.sls,入口文件
  
base:
  'web:nginx':
  - match: grain
  - apache
  

  

  
# salt '*' state.highstate# 执行命令,
  
salt-minion02:
  
----------
  ID: states
  Function: no.None
  Result: False
  Comment: No Top file or external nodes data matches found.   # 未匹配上,不执行
  Changes:
  

  
Summary for salt-minion02
  
------------
  
Succeeded: 0
  
Failed:    1
  
------------
  
Total states run:   1
  
Total run time:   0.000 ms
  
salt-master:
  
----------
  ID: states
  Function: no.None
  Result: False
  Comment: No Top file or external nodes data matches found.# 未匹配上,不执行
  Changes:
  

  
Summary for salt-master
  
------------
  
Succeeded: 0
  
Failed:    1
  
------------
  
Total states run:   1
  
Total run time:   0.000 ms
  
salt-minion01:
  
----------
  ID: apache-install
  Function: pkg.installed
  Name: httpd
  Result: True
  Comment: Package httpd is already installed   # 匹配上,执行
  Started: 08:38:12.103078
  Duration: 713.789 ms
  Changes:
  
----------
  ID: apache-install
  Function: pkg.installed
  Name: httpd-devel
  Result: True
  Comment: Package httpd-devel is already installed
  Started: 08:38:12.817233
  Duration: 0.892 ms
  Changes:
  
----------
  ID: apache-service
  Function: service.running
  Name: httpd
  Result: True
  Comment: The service httpd is already running
  Started: 08:38:12.819143
  Duration: 39.472 ms
  Changes:
  

  
Summary for salt-minion01
  
------------
  
Succeeded: 3
  
Failed:    0
  
------------
  
Total states run:   3
  
Total run time: 754.153 ms
  
ERROR: Minions returned with non-zero exit code
  
页: [1]
查看完整版本: 06-saltstack 之grains