From fc39f77ab9119ca0f8eafb4456f29ef31f023d56 Mon Sep 17 00:00:00 2001 From: gjmzj Date: Sun, 9 Jun 2019 15:20:09 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0docker/containerd=E4=BA=92?= =?UTF-8?q?=E6=96=A5=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- example/hosts.allinone | 4 ++-- example/hosts.multi-node | 4 ++-- roles/containerd/tasks/main.yml | 8 +++++++ roles/docker/tasks/main.yml | 42 ++++++++++++++++++++------------- 4 files changed, 37 insertions(+), 21 deletions(-) diff --git a/example/hosts.allinone b/example/hosts.allinone index b469602..fe9d1d6 100644 --- a/example/hosts.allinone +++ b/example/hosts.allinone @@ -45,12 +45,12 @@ NODE_PORT_RANGE="20000-40000" # Cluster DNS Domain CLUSTER_DNS_DOMAIN="cluster.local." -# -------- Additional Variables -------------------- +# -------- Additional Variables (don't change the default value right now)--- # Binaries Directory bin_dir="/opt/kube/bin" # CA and other components cert/key Directory ca_dir="/etc/kubernetes/ssl" -# Deploy Directory (kubeasz workspace), don't change the default value right now +# Deploy Directory (kubeasz workspace) base_dir="/etc/ansible" diff --git a/example/hosts.multi-node b/example/hosts.multi-node index 562a61b..18472cc 100644 --- a/example/hosts.multi-node +++ b/example/hosts.multi-node @@ -49,12 +49,12 @@ NODE_PORT_RANGE="20000-40000" # Cluster DNS Domain CLUSTER_DNS_DOMAIN="cluster.local." -# -------- Additional Variables -------------------- +# -------- Additional Variables (don't change the default value right now) --- # Binaries Directory bin_dir="/opt/kube/bin" # CA and other components cert/key Directory ca_dir="/etc/kubernetes/ssl" -# Deploy Directory (kubeasz workspace), don't change the default value right now +# Deploy Directory (kubeasz workspace) base_dir="/etc/ansible" diff --git a/roles/containerd/tasks/main.yml b/roles/containerd/tasks/main.yml index 572ff5a..883963e 100644 --- a/roles/containerd/tasks/main.yml +++ b/roles/containerd/tasks/main.yml @@ -1,3 +1,11 @@ +- name: 获取是否已经安装docker + shell: 'systemctl status docker|grep Active' + register: docker_status + +- name: fail info1 + fail: msg="Docker already installed!" + when: '"running" in docker_status.stdout' + - name: 准备containerd相关目录 file: name={{ item }} state=directory with_items: diff --git a/roles/docker/tasks/main.yml b/roles/docker/tasks/main.yml index 3c48376..0be6be5 100644 --- a/roles/docker/tasks/main.yml +++ b/roles/docker/tasks/main.yml @@ -1,26 +1,34 @@ +- name: 获取是否已经安装containerd + shell: 'systemctl status containerd|grep Active' + register: containerd_status + +- name: fail info1 + fail: msg="Containerd already installed!" + when: '"running" in containerd_status.stdout' + - name: 获取是否运行名为'kubeasz'的容器 shell: 'systemctl status docker|grep Active && docker ps|grep kubeasz || echo "NOT FOUND"' register: install_info tags: upgrade_docker, download_docker -# 18.09.x 版本二进制名字有变化,需要做判断 -- name: 获取docker版本信息 - shell: "{{ base_dir }}/bin/dockerd --version|cut -d' ' -f3" - register: docker_ver - connection: local - run_once: true - tags: upgrade_docker, download_docker - -- name: 转换docker版本信息为浮点数 - set_fact: - DOCKER_VER: "{{ docker_ver.stdout.split('.')[0]|int + docker_ver.stdout.split('.')[1]|int/100 }}" - tags: upgrade_docker, download_docker - -- name: debug info - debug: var="DOCKER_VER" - tags: upgrade_docker, download_docker - - block: + # 18.09.x 版本二进制名字有变化,需要做判断 + - name: 获取docker版本信息 + shell: "{{ base_dir }}/bin/dockerd --version|cut -d' ' -f3" + register: docker_ver + connection: local + run_once: true + tags: upgrade_docker, download_docker + + - name: 转换docker版本信息为浮点数 + set_fact: + DOCKER_VER: "{{ docker_ver.stdout.split('.')[0]|int + docker_ver.stdout.split('.')[1]|int/100 }}" + tags: upgrade_docker, download_docker + + - name: debug info + debug: var="DOCKER_VER" + tags: upgrade_docker, download_docker + - name: 准备docker相关目录 file: name={{ item }} state=directory with_items: