main.yml 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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. # need_sso_zip
  12. # need_sso_patch
  13. # need_sso_hotfix
  14. #
  15. - name: Check for tools
  16. file:
  17. path: "{{ tools[item].final_name }}"
  18. state: file
  19. loop: "{{ tools.keys() | list }}"
  20. - name: Check for completion files
  21. file:
  22. path: /etc/bash_completion.d/{{ tools[item].completion_file }}
  23. state: file
  24. when: tools[item].completion
  25. loop: "{{ tools.keys() | list }}"
  26. - name: Make sure kubeconfig is there on utility
  27. delegate_to: utility.lab.example.com
  28. file:
  29. path: /home/lab/{{ item }}/auth/kubeconfig
  30. state: file
  31. loop: "{{ clusters }}"
  32. - name: Create a temp dir
  33. file:
  34. path: tmp
  35. state: directory
  36. - name: Copy over the kubeconfig
  37. delegate_to: utility.lab.example.com
  38. fetch:
  39. src: /home/lab/{{ item }}/auth/kubeconfig
  40. dest: tmp/kubeconfig-{{ item }}
  41. flat: yes
  42. loop: "{{ clusters }}"
  43. - name: "We need python-kubernetes >= 12"
  44. become: yes
  45. pip:
  46. name: kubernetes>=12.0.0
  47. # XXX This won't do if you install it using pip.
  48. - name: We also need python38-jmespath
  49. become: yes
  50. package:
  51. name: python38-jmespath
  52. state: latest
  53. - name: Verify cluster connectivity
  54. kubernetes.core.k8s_cluster_info:
  55. kubeconfig: tmp/kubeconfig-{{ item }}
  56. validate_certs: no
  57. loop: "{{ clusters }}"
  58. - name: Check RHSSO ZIP is there
  59. stat:
  60. path: "{{ ansible_facts['user_dir'] }}/Downloads/rh-sso-{{ sso_z }}-server-dist.zip"
  61. register: sso_zip
  62. when: need_sso_zip|bool
  63. - assert:
  64. that: sso_zip.stat.exists
  65. fail_msg: "ERROR: RHSSO ZIP not downloaded! Please go to section 'Before You Begin' in your book."
  66. success_msg: "OK: Found RHSSO ZIP file."
  67. when: need_sso_zip|bool
  68. - name: Check RHSSO patch is there
  69. stat:
  70. path: "{{ ansible_facts['user_dir'] }}/Downloads/rh-sso-{{ sso_p }}-patch.zip"
  71. register: sso_patch
  72. when: need_sso_zip|bool and need_sso_patch|bool
  73. - name: Check RHSSO hotfix is there
  74. stat:
  75. path: "{{ ansible_facts['user_dir'] }}/Downloads/rhsso-{{ sso_f }}.zip"
  76. register: sso_hotfix
  77. when: need_sso_zip|bool and need_sso_hotfix|bool
  78. - assert:
  79. that: sso_zip.stat.exists
  80. fail_msg: "ERROR: RHSSO ZIP not downloaded! Please go to section 'Before You Begin' in your book."
  81. success_msg: "OK: Found RHSSO ZIP file."
  82. when: need_sso_zip|bool
  83. - assert:
  84. that: sso_patch.stat.exists
  85. fail_msg: "ERROR: RHSSO patch not downloaded! Please go to section 'Before You Begin' in your book."
  86. success_msg: "OK: Found RHSSO patch file."
  87. when: need_sso_zip|bool and need_sso_patch|bool
  88. - assert:
  89. that: sso_hotfix.stat.exists
  90. fail_msg: "ERROR: RHSSO hotfix not downloaded! Please go to section 'Before You Begin' in your book."
  91. success_msg: "OK: Found RHSSO hotfix file."
  92. when: need_sso_zip|bool and need_sso_hotfix|bool
  93. ...