fix: docker运行kubeasz时判断ansible控制端与deploy节点分离的条件

dev1
gjmzj 2019-06-12 16:03:17 +08:00
parent 89032bf0be
commit 3299c3beed
1 changed files with 8 additions and 1 deletions

View File

@ -117,6 +117,11 @@
- name: 移动 kube-proxy.kubeconfig - name: 移动 kube-proxy.kubeconfig
shell: "mv /root/kube-proxy.kubeconfig /etc/kubernetes/" shell: "mv /root/kube-proxy.kubeconfig /etc/kubernetes/"
# 检查deploy节点是否有 kubeasz 代码有的话说明deploy节点就是ansible控制节点
- name: 获取当前节点是否有 kubeasz 相关代码
shell: 'ls /etc/ansible/README.md || echo "NotFound"'
register: kubeasz_files
# --- 以下为兼容ansible执行节点与deploy节点分离情况------- # --- 以下为兼容ansible执行节点与deploy节点分离情况-------
- block: - block:
- name: 在 ansible 执行节点创建 .kube 目录 - name: 在 ansible 执行节点创建 .kube 目录
@ -143,4 +148,6 @@
- id_rsa.pub - id_rsa.pub
- known_hosts - known_hosts
run_once: true run_once: true
when: "ansible_env['SSH_CLIENT'].split(' ')[0] != inventory_hostname" when:
- "'NotFound' in kubeasz_files.stdout"
- "ansible_env['SSH_CLIENT'].split(' ')[0] != inventory_hostname"