---
# Variables affecting this role:
#
#  clusters:
#   just a simple list of clusters to check
#
- name: Make sure kubeconfig is there on utility
  delegate_to: utility.lab.example.com
  file:
    path: /home/lab/{{ item }}/auth/kubeconfig
    state: file
  loop: "{{ clusters }}"

- name: Create a temp dir
  file:
    path: tmp
    state: directory

- name: Copy over the kubeconfig
  delegate_to: utility.lab.example.com
  fetch:
    src: /home/lab/{{ item }}/auth/kubeconfig
    dest: tmp/kubeconfig-{{ item }}
    flat: yes
  loop: "{{ clusters }}"

- name: We need some packages to be there
  become: yes
  yum:
    name:
      - java-17-openjdk-headless
      - java-17-openjdk-devel
      - python3-jmespath
      - python3.11-jmespath
      - python3-kubernetes
      - ansible-collection-ansible-posix
      - ansible-collection-community-general
    state: latest

#- name: Make sure stuff is in PATH
#  lineinfile:
#    path: "{{ ansible_facts['user_dir'] }}/.bashrc"
#    line: 'PATH="${PATH}:/opt/amq/bin"'
#    regexp: '^PATH=.*/opt/amq/bin'
#    insertafter: "^# User specific environment$"
#    state: present
#  loop:
#    - KAFKA_HOME

- name: Verify cluster connectivity
  kubernetes.core.k8s_cluster_info:
    kubeconfig: tmp/kubeconfig-{{ item }}
    validate_certs: no
  loop: "{{ clusters }}"
...