2019-05-30 21:37:01 +08:00
|
|
|
# kube-node 节点成员不能同时是 ex-lb 节点,因为它们都需要安装 haproxy
|
|
|
|
- name: fail info1
|
|
|
|
fail: msg="an 'kube-node' node CAN NOT be a 'ex-lb' node at the same time"
|
|
|
|
when: "inventory_hostname in groups['ex-lb']"
|
2019-06-01 09:24:43 +08:00
|
|
|
tags: restart_lb
|
2019-05-30 21:37:01 +08:00
|
|
|
|
2019-05-28 23:46:22 +08:00
|
|
|
- name: 安装 haproxy
|
|
|
|
package: name=haproxy state=present
|
|
|
|
|
|
|
|
- name: 创建haproxy配置目录
|
|
|
|
file: name=/etc/haproxy state=directory
|
|
|
|
|
|
|
|
- name: 修改centos的haproxy.service
|
|
|
|
template: src=haproxy.service.j2 dest=/usr/lib/systemd/system/haproxy.service
|
|
|
|
when: 'ansible_distribution in ["CentOS","RedHat","Amazon"]'
|
|
|
|
tags: restart_lb
|
|
|
|
|
|
|
|
- name: 配置 haproxy
|
|
|
|
template: src=haproxy.cfg.j2 dest=/etc/haproxy/haproxy.cfg
|
|
|
|
tags: restart_lb
|
|
|
|
|
|
|
|
- name: daemon-reload for haproxy.service
|
|
|
|
shell: systemctl daemon-reload
|
|
|
|
tags: restart_lb
|
|
|
|
|
|
|
|
- name: 开机启用haproxy服务
|
|
|
|
shell: systemctl enable haproxy
|
|
|
|
ignore_errors: true
|
|
|
|
|
2019-05-29 20:45:25 +08:00
|
|
|
- name: 停止haproxy服务
|
|
|
|
shell: systemctl stop haproxy
|
|
|
|
tags: restart_lb
|
|
|
|
|
|
|
|
- name: 开启haproxy服务
|
|
|
|
shell: systemctl start haproxy
|
|
|
|
when: "groups['kube-master']|length > 1"
|
2019-05-28 23:46:22 +08:00
|
|
|
tags: restart_lb
|