Ansible - using facts from one host to perform actions on another host
I found a solution - the trick here is delegate_to and delegate_facts:
- hosts: all
  remote_user: ansible
  become: false

  tasks:
  - name: read join line from controlPlane
    shell: kubeadm token create --print-join-command
    when: inventory_hostname in groups['workerNodes']
    register: joinCmd
    delegate_to: &quot;{{ item }}&quot;
    delegate_facts: true
    with_items: &quot;{{ groups['controlPlane'] }}&quot;

  - name: join all worker nodes to cluster
    command: &quot;{{ joinCmd.results[0].stdout }}&quot;
    become: yes
    when: inventory_hostname in groups['workerNodes']

The first task kind of reads backwards to my mind - when says 'run this task on all the  workerNode hosts...' but delegate_to says '..but actually run it on a different host'. It works for me though (I've only got 1 host in controlPlane group, not sure of outcome with more hosts).