Centos 7 Saltstack自动化部署Haproxy+Keepalived

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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)


[[email protected] 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部署自动化软件

CentOS 7.2 部署Saltstack

CentOS 7.2 部署Saltstack

centOS 7 部署SaltStack

自动化运维集中式管理工具saltstack的基于各个平台的部署

centOS 6.5 部署SaltStack