forked from easzlab/kubeasz
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.yml
64 lines (49 loc) · 2 KB
/
main.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
- name: apt更新缓存刷新
apt: update_cache=yes cache_valid_time=72000
when: ansible_distribution == "Ubuntu" and ansible_distribution_major_version|int >= 16
- name: apt安装 haproxy
apt: name=haproxy state=latest
when: ansible_distribution == "Ubuntu" and ansible_distribution_major_version|int >= 16
- name: yum安装 haproxy
yum: name=haproxy state=latest
when: ansible_distribution == "CentOS" and ansible_distribution_major_version == "7"
- 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 == "CentOS" and ansible_distribution_major_version == "7"
tags: restart_lb
- name: 配置 haproxy
template: src=haproxy.cfg.j2 dest=/etc/haproxy/haproxy.cfg
tags: restart_lb
- name: apt安装 keepalived
apt: name=keepalived state=latest
when: ansible_distribution == "Ubuntu" and ansible_distribution_major_version|int >= 16
- name: yum安装 keepalived
yum: name=keepalived state=latest
when: ansible_distribution == "CentOS" and ansible_distribution_major_version == "7"
- 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"
tags: restart_lb
- name: 配置 keepalived 备节点
template: src=keepalived-backup.conf.j2 dest=/etc/keepalived/keepalived.conf
when: LB_ROLE == "backup"
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
- name: 重启haproxy服务
shell: systemctl restart haproxy
tags: restart_lb
- name: 开机启用keepalived服务
shell: systemctl enable keepalived
ignore_errors: true
- name: 重启keepalived服务
shell: systemctl restart keepalived
tags: restart_lb