码迷,mamicode.com
首页 > 其他好文 > 详细

Centos 7 Saltstack自动化部署Haproxy+Keepalived

时间:2017-11-17 00:15:04      阅读:190      评论:0      收藏:0      [点我收藏+]

标签:centos 7 saltstack   haproxy keepalived

master   node   10.10.10.1 

minion   node   10.10.10.2




# cat /etc/salt/master |grep -v "#" |grep -v "^ *$"

interface: 10.10.10.1

state_top: top.sls

file_roots:

  base:

    - /etc/salt/base

  prod:

    - /etc/salt/prod

pillar_roots:

  base:

    - /etc/salt/pillar/base

  prod:

    - /etc/salt/pillar/prod



# cat /etc/redhat-release

CentOS Linux release 7.2.1511 (Core)


[root@app-LT-177 etc]# cat /etc/salt/minion |grep -v "#" |grep -v "^ *$"

master: 10.10.10.1

id: 10.10.10.2


mkdir -p /etc/salt/base   创建file目录base 存放集群top.sls文件   

mkdir -p /etc/salt/base/init   存放初始化系统sls文件(dns等)

mkdir -p /etc/salt/prod   创建file目录prod

mkdir -p /etc/salt/prod/cluster/       定义集群启动和配置文件拉取

mkdir -p /etc/salt/prod/cluster/files/ 存放keepalived.conf和haproxy.cfg文件

mkdir -p /etc/salt/prod/haproxy/   存放haproxy安装sls

mkdir -p /etc/salt/prod/haproxy/files  存放haproxy安装包等

mkdir -p /etc/salt/prod/keepalived  存放keepalived安装sls

mkdir -p /etc/salt/prod/keepalived/files 存放keepalived安装包等

mkdir -p /etc/salt/prod/pkg/      存放集群相关的安装包

mkdir -p /etc/salt/pillar/     创建存放pillar目录

mkdir -p /etc/salt/pillar/base/  创建pillar目录base  存放pillar的top.sls文件

mkdir -p /etc/salt/pillar/base/webservice/  存放集群pillar的sls文件

mkdir -p /etc/salt/pillar/prod/   创建pillar目录prod



######################################################

                            注意格式              一定要注意格式

######################################################

#tree base/

base/

├── init

│   ├── dns.sls            ---------------------------1

│   ├── env_init.sls     ---------------------------2

│   ├── epel.sls           ---------------------------3

│   ├── files           

│   │   └── resolv.conf--------------------------4

│   ├── history.sls       --------------------------5

│   └── pkg

│       └── epel-release-latest-7.noarch.rpm----6

└── top.sls                  ---------------------------7



1.dns.sls

/etc/resolv.conf:

  file.managed:

    - source: salt://init/files/resolv.conf

    - user: root

    - group: root

    - mode: 644


2.env_init.sls

include:

  - init.dns

  - init.history

  - init.epel


3.epel.sls 

epel-7:

  file.managed:

    - name: /etc/salt/epel-release-latest-7.noarch.rpm

    - source: salt://init/pkg/epel-release-latest-7.noarch.rpm

    - mode: 755

    - user: root

    - group: root


  cmd.run:

    - name:  rpm -ivh /etc/salt/epel-release-latest-7.noarch.rpm --nodeps --force && rpm -qa |grep epel-release-7-11.noarch



4.resolv.conf

nameserver 114.114.114.114


5.   history.sls

/etc/profile:

  file.append:

    - text:

      - export HISTTIMEFORMAT="%F %T `who`"


6.epel-release-latest-7.noarch.rpm

epel 7  rpm包


7.top.sls

base:

  ‘*‘:

    - init.env_init

prod:

  ‘*‘:

    - cluster.haproxy

    - cluster.keepalived-out



######################################################


# tree prod/

prod/

├── cluster

│   ├── files                                  

│   │   ├── haproxy.cfg                    ---------------1

│   │   └── keepalived-out.conf       ---------------2

│   ├── haproxy.sls                           ---------------3

│   └── keepalived-out.sls               ---------------4

├── haproxy

│   ├── files                                     

│   │   ├── haproxy-1.7.9.tar.gz       ---------------5

│   │   └── haproxy.init                    ---------------6

│   └── install.sls                              ---------------7

├── keepalived

│   ├── files

│   │   ├── chk_haproxy.sh              ----------------8

│   │   ├── keepalived-1.2.1.tar.gz  -----------------9

│   │   ├── keepalived.init               ----------------10

│   │   ├── keepalived.rh.init           ----------------11

│   │   └── keepalived.sysconfig     -----------------12

│   └── install.sls                              ----------------13

└── pkg

    └── pkg-init.sls                            ----------------14



睡觉去了  明天接着来。。。。哈哈










#########################################################

# tree pillar/

pillar/

├── base

│   ├── top.sls

│   └── webservice

│       └── web.sls

└── prod















本文出自 “运维成长之路” 博客,请务必保留此出处http://pankuo.blog.51cto.com/8651697/1982628

Centos 7 Saltstack自动化部署Haproxy+Keepalived

标签:centos 7 saltstack   haproxy keepalived

原文地址:http://pankuo.blog.51cto.com/8651697/1982628

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!