diff --git a/tasks/main.yml b/tasks/main.yml index 638f7f9..c3fe22f 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -51,8 +51,15 @@ shell: kubeadm token create --print-join-command changed_when: False when: kubernetes_role == 'master' - run_once: True - register: kubernetes_join_command + register: kubernetes_join_command_result + +- name: Set the kubeadm join command globally. + set_fact: + kubernetes_join_command: "{{ kubernetes_join_command_result.stdout }}" + when: kubernetes_join_command_result.stdout is defined + delegate_to: "{{ item }}" + delegate_facts: True + with_items: "{{ groups['all'] }}" - include_tasks: node-setup.yml when: kubernetes_role == 'node' diff --git a/tasks/node-setup.yml b/tasks/node-setup.yml index 7a67963..442c353 100644 --- a/tasks/node-setup.yml +++ b/tasks/node-setup.yml @@ -1,5 +1,5 @@ --- - name: Join node to Kubernetes master shell: > - {{ kubernetes_join_command.stdout }} + {{ kubernetes_join_command }} creates=/etc/kubernetes/kubelet.conf