diff --git a/roles/calico/tasks/main.yml b/roles/calico/tasks/main.yml index e9b5c94..3566205 100644 --- a/roles/calico/tasks/main.yml +++ b/roles/calico/tasks/main.yml @@ -7,7 +7,7 @@ - /opt/kube/images - name: 复制CA 证书到calico 证书目录 - copy: src={{ ca_dir }}/ca.pem dest=/etc/calico/ssl/ca.pem + shell: "cp {{ ca_dir }}/ca.pem /etc/calico/ssl/ca.pem" - name: 创建calico 证书请求 template: src=calico-csr.json.j2 dest=/etc/calico/ssl/calico-csr.json diff --git a/roles/deploy/tasks/main.yml b/roles/deploy/tasks/main.yml index 344f8f0..3340e8c 100644 --- a/roles/deploy/tasks/main.yml +++ b/roles/deploy/tasks/main.yml @@ -117,3 +117,6 @@ - name: 移动 kube-proxy.kubeconfig shell: "mv /root/kube-proxy.kubeconfig /etc/kubernetes/" +# 兼容ansible执行节点与deploy节点分离情况 +- name: 复制 manifests至 deploy节点 + copy: src={{ base_dir }}/manifests dest={{ base_dir }}/manifests diff --git a/roles/kube-node/tasks/main.yml b/roles/kube-node/tasks/main.yml index c1b6b6a..44f6b63 100644 --- a/roles/kube-node/tasks/main.yml +++ b/roles/kube-node/tasks/main.yml @@ -32,7 +32,7 @@ - name: 安装bootstrap.kubeconfig配置文件 synchronize: src=/etc/kubernetes/bootstrap.kubeconfig dest=/etc/kubernetes/bootstrap.kubeconfig - delegate_to: "{{ hostvars[inventory_hostname].groups.deploy[0] }}" + delegate_to: "{{ groups.deploy[0] }}" - name: 准备 cni配置文件 template: src=cni-default.conf.j2 dest=/etc/cni/net.d/10-default.conf @@ -52,7 +52,7 @@ ##-------kube-proxy部分---------------- - name: 安装kube-proxy.kubeconfig配置文件 synchronize: src=/etc/kubernetes/kube-proxy.kubeconfig dest=/etc/kubernetes/kube-proxy.kubeconfig - delegate_to: "{{ hostvars[inventory_hostname].groups.deploy[0] }}" + delegate_to: "{{ groups.deploy[0] }}" - name: 创建kube-proxy 服务文件 tags: reload-kube-proxy, upgrade_k8s, restart_node diff --git a/roles/prepare/tasks/main.yml b/roles/prepare/tasks/main.yml index 85caf7c..cf3fc54 100644 --- a/roles/prepare/tasks/main.yml +++ b/roles/prepare/tasks/main.yml @@ -79,7 +79,7 @@ - name: 安装kubeconfig配置文件 synchronize: src=/root/.kube/config dest=/root/.kube/config - delegate_to: "{{ hostvars[inventory_hostname].groups.deploy[0] }}" + delegate_to: "{{ groups.deploy[0] }}" - name: 分发CA 证书 synchronize: src={{ ca_dir }}/{{ item }} dest={{ ca_dir }}/{{ item }} @@ -88,7 +88,7 @@ - ca-key.pem - ca.csr - ca-config.json - delegate_to: "{{ hostvars[inventory_hostname].groups.deploy[0] }}" + delegate_to: "{{ groups.deploy[0] }}" - name: 添加 kubectl 命令自动补全 lineinfile: