main.yml 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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. - name: We also need python38-jmespath
  45. become: yes
  46. package:
  47. name: python38-jmespath
  48. state: latest
  49. - name: We need java-17-openjdk-headless, too
  50. become: yes
  51. package:
  52. name: java-17-openjdk-headless
  53. state: latest
  54. - name: Get download confirmation code from Google Drive
  55. uri:
  56. url: "https://drive.google.com/uc?export=download&id={{ amq_file_id }}"
  57. creates: "{{ ansible_facts['user_dir'] }}/Downloads/amq-broker-{{ amq_z }}-bin.zip"
  58. return_content: yes
  59. status_code: 200
  60. register: amq_dl_cc
  61. - name: Store conf code as a fact
  62. set_fact:
  63. amq_src_url: "{{ amq_dl_cc.content | regex_replace('^.*action=\"', '') | regex_replace('\".*$', '') | regex_replace('amp;', '') }}"
  64. when: amq_dl_cc.content is defined
  65. - name: Download AMQ broker
  66. get_url:
  67. url: "{{ amq_src_url }}"
  68. dest: "{{ ansible_facts['user_dir'] }}/Downloads/amq-broker-{{ amq_z }}-bin.zip"
  69. mode: 0664
  70. when: amq_src_url is defined
  71. - name: Extract AMQ broker to /opt
  72. become: yes
  73. unarchive:
  74. src: "{{ ansible_facts['user_dir'] }}/Downloads/amq-broker-{{ amq_z }}-bin.zip"
  75. remote_src: yes
  76. creates: /opt/amq
  77. dest: /opt
  78. register: amq_ex_act
  79. - name: Rename wherever the archive extracted into /opt/amq
  80. become: yes
  81. command: mv /opt/{{ amq_extracted_dir }} /opt/amq
  82. when:
  83. - amq_ex_act is defined
  84. - amq_ex_act.changed
  85. - name: Make sure /opt/amq/bin is in PATH
  86. lineinfile:
  87. path: "{{ ansible_facts['user_dir'] }}/.bashrc"
  88. line: 'PATH="${PATH}:/opt/amq/bin"'
  89. regexp: '^PATH=.*/opt/amq/bin'
  90. insertafter: "^# User specific environment$"
  91. state: present
  92. - name: Verify cluster connectivity
  93. kubernetes.core.k8s_cluster_info:
  94. kubeconfig: tmp/kubeconfig-{{ item }}
  95. validate_certs: no
  96. loop: "{{ clusters }}"
  97. ...