mirror of https://github.com/easzlab/kubeasz.git
30 lines
874 B
YAML
30 lines
874 B
YAML
|
|
||
|
- name: 安装 haproxy
|
||
|
shell: "apt-get update && apt-get install haproxy -y"
|
||
|
|
||
|
- name: 创建haproxy配置目录
|
||
|
file: name=/etc/haproxy state=directory
|
||
|
|
||
|
- name: 配置 haproxy
|
||
|
template: src=haproxy.cfg.j2 dest=/etc/haproxy/haproxy.cfg
|
||
|
|
||
|
- name: 安装 keepalived
|
||
|
shell: "apt-get install keepalived -y"
|
||
|
|
||
|
- name: 创建keepalived配置目录
|
||
|
file: name=/etc/keepalived state=directory
|
||
|
|
||
|
- name: 配置 keepalived 主节点
|
||
|
template: src=keepalived-master.conf.j2 dest=/etc/keepalived/keepalived.conf
|
||
|
when: LB_ROLE == "master"
|
||
|
|
||
|
- name: 配置 keepalived 备节点
|
||
|
template: src=keepalived-backup.conf.j2 dest=/etc/keepalived/keepalived.conf
|
||
|
when: LB_ROLE == "backup"
|
||
|
|
||
|
- name: 重启haproxy服务
|
||
|
shell: systemctl enable haproxy && systemctl restart haproxy
|
||
|
|
||
|
- name: 重启keepalived服务
|
||
|
shell: systemctl enable keepalived && systemctl restart keepalived
|