saltstack (6) 配置管理(2)

简介:

以源码安装haproxy为例,介绍sls 配置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
[root@redis01-jp ~] # tree /srv/salt/
/srv/salt/
├── base
│   ├── apache
│   │   └── init.sls
│   ├── files
│   ├── nginx.sls
│   └──  top .sls
├── prod
│   ├── haproxy
│   │   ├── files
│   │   │   ├── haproxy-1.7.1. tar .gz
│   │   │   └── haproxy.init
│   │   └── init.sls
│   └── pkg
│       └── init.sls
└──  test
8 directories, 7 files
[root@redis01-jp ~] # cat /srv/salt/base/top.sls
base:
   'redis02-jp' :
     - apache
prod:
   'redis02-jp' :
     - haproxy
[root@redis01-jp ~] # cat /srv/salt/prod/pkg/init.sls
init:
   pkg.installed:
     - names:
       - gcc
       - gcc-c++
       - glibc
       -  make
       - autoconf
       - openssl
       - openssl-devel
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
[root@redis01-jp ~] # cat /srv/salt/prod/haproxy/init.sls
include:
   - pkg
haproxy- install :
   file .managed:
     - name:  /usr/local/src/haproxy-1 .7.1. tar .gz
     -  source : salt: //haproxy/files/haproxy-1 .7.1. tar .gz
     - user: root
     - group: root
     - mode: 644
   cmd.run:
     - name:  cd  /usr/local/src/  &&  tar  xfz haproxy-1.7.1. tar .gz &&  cd  haproxy-1.7.1 &&  make  TARGET=linux26 PREFIX= /usr/local/haproxy  &&  make  install  PREFIX= /usr/local/haproxy
     - unless:  test  -d  /usr/local/haproxy
     - require:
       - pkg: init
       -  file : haproxy- install
haproxy-init:
   file .managed:
     - name:  /etc/init .d /haproxy
     -  source : salt: //haproxy/files/haproxy .init
     - user: root
     - group: root
     - mode: 755
     - require:
       - cmd: haproxy- install
   cmd.run:
     - name: chkconfig --add haproxy
     - unless: chkconfig --list | grep  haproxy
     - require:
       -  file : haproxy-init
net.ipv4.ip_nonlocal_bind:
   sysctl.present:
     - value: 1
haproxy-config- dir :
   file .directory:
     - name:  /etc/haproxy
     - user: root
     - group: root
     - mode: 755

[root@redis01-jp ~]#










本文转自 meteor_hy 51CTO博客,原文链接:http://blog.51cto.com/caiyuanji/1885098,如需转载请自行联系原作者
目录
相关文章
|
应用服务中间件 Apache nginx
|
Apache 开发工具 数据安全/隐私保护
|
Apache 开发工具 网络协议