增加支持离线安装ex-lb

pull/641/head
gjmzj 2019-06-28 21:16:13 +08:00
parent b4df5ff604
commit 657d2c12d8
6 changed files with 74 additions and 18 deletions

View File

@ -13,3 +13,6 @@ BALANCE_ALG: "roundrobin"
INGRESS_NODEPORT_LB: "yes"
# 启用 ingress tls NodePort服务的负载均衡 (yes/no)
INGRESS_TLS_NODEPORT_LB: "yes"
# 离线安装 haproxy+keepalived (offline|online)
INSTALL_SOURCE: "offline"

View File

@ -13,15 +13,22 @@
set_fact: LB_IF={{ LB_IF_TMP.stdout }}
tags: restart_lb
- name: apt更新缓存刷新
apt: update_cache=yes cache_valid_time=72000
when: 'ansible_distribution in ["Ubuntu","Debian"]'
- name: 创建相关目录
file: name={{ item }} state=directory
with_items:
- /etc/haproxy
- /etc/keepalived
- name: 安装 haproxy
package: name=haproxy state=present
- name: 安装 haproxy+keepalived
package: name={{ item }} state=present
with_items:
- haproxy
- keepalived
when: 'INSTALL_SOURCE != "offline"'
- name: 创建haproxy配置目录
file: name=/etc/haproxy state=directory
# 离线安装 haproxy+keepalived
- import_tasks: offline.yml
when: 'INSTALL_SOURCE == "offline"'
- name: 修改centos的haproxy.service
template: src=haproxy.service.j2 dest=/usr/lib/systemd/system/haproxy.service
@ -32,12 +39,6 @@
template: src=haproxy.cfg.j2 dest=/etc/haproxy/haproxy.cfg
tags: restart_lb
- name: 安装 keepalived
package: name=keepalived state=present
- 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"

View File

@ -0,0 +1,56 @@
# 离线安装 haproxy
- name: 准备离线安装包目录
file: name=/opt/kube/packages/haproxy state=directory
- block:
- name: 分发 haproxy_xenial 离线包
copy:
src: "{{ base_dir }}/down/packages/haproxy_xenial.tar.gz"
dest: "/opt/kube/packages/haproxy/haproxy_xenial.tar.gz"
- name: 安装 haproxy_xenial 离线包
shell: 'cd /opt/kube/packages/haproxy && tar zxf haproxy_xenial.tar.gz && \
dpkg -i *.deb > /tmp/install_haproxy.log 2>&1'
when: ansible_distribution_release == "xenial"
- block:
- name: 分发 haproxy_centos7 离线包
copy:
src: "{{ base_dir }}/down/packages/haproxy_centos7.tar.gz"
dest: "/opt/kube/packages/haproxy/haproxy_centos7.tar.gz"
- name: 安装 haproxy_centos7 离线包
shell: 'cd /opt/kube/packages/haproxy && tar zxf haproxy_centos7.tar.gz && \
rpm -Uvh --nodeps *.rpm > /tmp/install_haproxy.log 2>&1'
when:
- 'ansible_distribution == "CentOS"'
- 'ansible_distribution_major_version == "7"'
# 离线安装 keepalived
- name: 准备离线安装包目录
file: name=/opt/kube/packages/keepalived state=directory
- block:
- name: 分发 keepalived_xenial 离线包
copy:
src: "{{ base_dir }}/down/packages/keepalived_xenial.tar.gz"
dest: "/opt/kube/packages/keepalived/keepalived_xenial.tar.gz"
- name: 安装 keepalived_xenial 离线包
shell: 'cd /opt/kube/packages/keepalived && tar zxf keepalived_xenial.tar.gz && \
dpkg -i *.deb > /tmp/install_keepalived.log 2>&1'
when: ansible_distribution_release == "xenial"
- block:
- name: 分发 keepalived_centos7 离线包
copy:
src: "{{ base_dir }}/down/packages/keepalived_centos7.tar.gz"
dest: "/opt/kube/packages/keepalived/keepalived_centos7.tar.gz"
- name: 安装 keepalived_centos7 离线包
shell: 'cd /opt/kube/packages/keepalived && tar zxf keepalived_centos7.tar.gz && \
rpm -Uvh --nodeps *.rpm > /tmp/install_keepalived.log 2>&1'
when:
- 'ansible_distribution == "CentOS"'
- 'ansible_distribution_major_version == "7"'

View File

@ -1,8 +1,6 @@
global
log /dev/log local1 warning
chroot /var/lib/haproxy
stats socket /run/haproxy/admin.sock mode 660 level admin
stats timeout 30s
user haproxy
group haproxy
daemon

View File

@ -1,4 +1,4 @@
# 离线安装基础系统包
# 离线安装 haproxy
- name: 准备离线安装包目录
file: name=/opt/kube/packages/haproxy state=directory

View File

@ -1,8 +1,6 @@
global
log /dev/log local1 warning
chroot /var/lib/haproxy
stats socket /run/haproxy/admin.sock mode 660 level admin
stats timeout 30s
user haproxy
group haproxy
daemon