main.yml 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. ---
  2. # Variables affecting this role:
  3. #
  4. # tools:
  5. # - final_name: the path to the tool to check for
  6. # completion: look for bash_completion or no
  7. # completion_file: the name of the bash completion file
  8. # clusters:
  9. # just a simple list of clusters to check
  10. #
  11. - name: Check for tools
  12. file:
  13. path: "{{ tools[item].final_name }}"
  14. state: file
  15. loop: "{{ tools.keys() | list }}"
  16. - name: Check for completion files
  17. file:
  18. path: /etc/bash_completion.d/{{ tools[item].completion_file }}
  19. state: file
  20. when: tools[item].completion
  21. loop: "{{ tools.keys() | list }}"
  22. - name: Make sure kubeconfig is there on utility
  23. delegate_to: utility.lab.example.com
  24. file:
  25. path: /home/lab/{{ item }}/auth/kubeconfig
  26. state: file
  27. loop: "{{ clusters }}"
  28. - name: Create a temp dir
  29. file:
  30. path: tmp
  31. state: directory
  32. - name: Copy over the kubeconfig
  33. delegate_to: utility.lab.example.com
  34. fetch:
  35. src: /home/lab/{{ item }}/auth/kubeconfig
  36. dest: tmp/kubeconfig-{{ item }}
  37. flat: yes
  38. loop: "{{ clusters }}"
  39. - name: "We need python-kubernetes >= 12"
  40. become: yes
  41. pip:
  42. name: kubernetes>=12.0.0
  43. # XXX This won't do if you install it using pip.
  44. # TODO Move this to vars or defaults or something
  45. - name: We also need python3.11-jmespath
  46. become: yes
  47. package:
  48. name: python3.11-jmespath
  49. state: latest
  50. - name: We need some additional collections as well.
  51. become: yes
  52. yum:
  53. name:
  54. - ansible-core
  55. - ansible-collection-ansible-posix
  56. - ansible-collection-ansible-utils
  57. - ansible-collection-community-general
  58. - ansible-collection-containers-podman
  59. state: latest
  60. - name: Verify cluster connectivity
  61. kubernetes.core.k8s_cluster_info:
  62. kubeconfig: tmp/kubeconfig-{{ item }}
  63. validate_certs: no
  64. loop: "{{ clusters }}"
  65. ...