我想使用ansible sync将kube admin配置文件从Kubernetes主控主机复制到节点,但是由于缺少python解释器而失败,但是我已经在所有机器上安装了docker,没有任何问题。
查看我的任务
- name: admin conf file to nodes
environment:
ANSIBLE_PYTHON_INTERPRETER: python3
synchronize:
src: /home/{{ansible_ssh_user}}/.kube/config
dest: /home/{{ansible_ssh_user}}
delegate_to: "{{item}}"
loop: "{{groups.node}}"
答案 0 :(得分:2)
仅当在源服务器(在您的情况下为kube master)或kube节点中启用rsync时,才可以使用syncize模块。
默认情况下同步使用push
模式
- hosts: nodes
tasks:
- name: Transfer file from master to nodes
synchronize:
src: /etc/kubernetes/admin.conf
dest: $HOME/.kube/config
delegate_to: "{{ master }}"
- hosts: all
tasks:
- name: Fetch the file from the master to ansible
run_once: yes
fetch: src=/etc/kubernetes/admin.conf dest=temp/ flat=yes
when: "{{ ansible_hostname == 'master' }}"
- name: Copy the file from the ansible to nodes
copy: src=temp/admin.conf dest=$HOME/.kube/config
when: "{{ ansible_hostname != 'master' }}"
希望这会有所帮助。