From 0141762b92cce483cc484f1e8ef3b2ce14c5db5f Mon Sep 17 00:00:00 2001 From: Jeff Geerling Date: Thu, 6 Sep 2018 23:36:16 -0500 Subject: [PATCH] Fixes #10: Set kubernetes_join_command more reliably. --- tasks/main.yml | 11 +++++++++-- tasks/node-setup.yml | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) 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