diff --git a/roles/kube-node/defaults/main.yml b/roles/kube-node/defaults/main.yml index f94f29c..3691c9d 100644 --- a/roles/kube-node/defaults/main.yml +++ b/roles/kube-node/defaults/main.yml @@ -42,3 +42,6 @@ KUBE_APISERVER: "{%- if inventory_hostname in groups['kube-master'] -%} \ # 增加/删除 master 节点时,node 节点需要重新配置 haproxy 等 MASTER_CHG: "no" + +# 离线安装 haproxy (offline|online) +INSTALL_SOURCE: "offline" diff --git a/roles/kube-node/tasks/node_lb.yml b/roles/kube-node/tasks/node_lb.yml index 5ed4a7a..d749a24 100644 --- a/roles/kube-node/tasks/node_lb.yml +++ b/roles/kube-node/tasks/node_lb.yml @@ -6,6 +6,11 @@ - name: 安装 haproxy package: name=haproxy state=present + when: 'INSTALL_SOURCE != "offline"' + +# 离线安装 haproxy +- import_tasks: offline.yml + when: 'INSTALL_SOURCE == "offline"' - name: 创建haproxy配置目录 file: name=/etc/haproxy state=directory diff --git a/roles/kube-node/tasks/offline.yml b/roles/kube-node/tasks/offline.yml new file mode 100644 index 0000000..eed45ed --- /dev/null +++ b/roles/kube-node/tasks/offline.yml @@ -0,0 +1,27 @@ +# 离线安装基础系统包 +- 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"' diff --git a/roles/prepare/tasks/offline.yml b/roles/prepare/tasks/offline.yml index de867ad..79d584e 100644 --- a/roles/prepare/tasks/offline.yml +++ b/roles/prepare/tasks/offline.yml @@ -21,7 +21,7 @@ - name: 安装 basic_centos7 离线包 shell: 'cd /opt/kube/packages/basic && tar zxf basic_centos7.tar.gz && \ - basic -Uvh --nodeps *.rpm > /tmp/install_basic.log 2>&1' + rpm -Uvh --nodeps *.rpm > /tmp/install_basic.log 2>&1' when: - 'ansible_distribution == "CentOS"' - 'ansible_distribution_major_version == "7"'