Chinaunix首页 | 论坛 | 博客
  • 博客访问: 235577
  • 博文数量: 49
  • 博客积分: 1035
  • 博客等级: 少尉
  • 技术积分: 477
  • 用 户 组: 普通用户
  • 注册时间: 2006-03-14 17:23
文章分类

全部博文(49)

文章存档

2015年(15)

2014年(6)

2011年(1)

2008年(3)

2007年(11)

2006年(13)

我的朋友

分类: LINUX

2015-03-24 16:05:05

参考文献:   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



阅读(1097) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~