Setting facts on one host and reusing...
What am I missing here, when I run it I get an undefined variable on the workers.
- hosts: master
become: yes
gather_facts: true
tasks:
- name: get join command
shell: kubeadm token create --print-join-command
register: join_command_raw
- name: set join command
set_fact:
join_command: "{{ join_command_raw.stdout_lines[0] }}"
cacheable: true
- name: Check1
debug:
msg: "The output is: {{ join_command }}"
- hosts: workers
become: yes
tasks:
#- name: Join cluster
# shell: "{{ hostvars['master'].join_command }} >> node_joined.log"
# args:
# chdir: /home/ubuntu
# creates: node_joined.log
- name: Checking fact
debug:
msg: "The output is: {{ hostvars['k8-master'].join_command }}"