1. 程式人生 > >Centos 7 Saltstack自動化部署Haproxy+Keepalived

Centos 7 Saltstack自動化部署Haproxy+Keepalived

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