I would like to copy the kube admin config file from the Kubernetes master host to the nodes using ansible synchronize but that fails due to a missing python interpreter, but I have already installed docker on all machines without any issue.
See my task
- 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}}"
You can use synchronize module only when rsync is enabled either in source server (kube master in your case) or in the kube nodes.
Synchronize use push
mode by default
- 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' }}"
Hope this helps.