参考文献: Python自动化运维:技术与最佳实践
管理端:10.1.1.91
客户端:10.1.1.92/93
目录结构
/srv/
|-- api
|-- pillar
| |-- top.sls
| `-- web1server.sls
`-- salt
|-- _grains
| `-- update_status.py
|-- httpd
| `-- httpd.conf
|-- httpd.sls
`-- top.sls
1. 管理端配置
1.1 管理端主配置文件
1.1.1 /etc/salt/master配置
interface: 0.0.0.0
auto_accept: True
file_roots:
base:
- /srv/salt/
pillar_roots:
base:
- /srv/pillar
nodegroups:
httpdgroup: 'L@my1-92.test.com,test1-93.test.com'
1.2 pillar配置
1.2.1 top.sls
base:
httpdgroup:
- match: nodegroup
- web1server
1.2.2 web1server.sls
httpd:
root: /etc/httpd/conf
1.3 state配置
1.3.1 top.sls文件
base:
'*':
- httpd
1.3.2 httpd.sls文件
httpd:
pkg:
- installed
service.running:
- enable: True
- reload: True
- watch:
- file: /etc/httpd/conf/httpd.conf
- pkg: httpd
file.managed:
- source: salt://httpd/httpd.conf
- name: /etc/httpd/conf/httpd.conf
- user: root
- group: root
- mode: 644
- template: jinja
2. 客户端配置
2.1 /etc/salt/minion
master: 10.1.1.91
id: my1-92.test.com
3. 验证key
在服务器端执行
salt-key -A 或 --a单独指定主机
4. 测试及相关命令
salt '*' state.highstate
阅读(1166) | 评论(0) | 转发(0) |