main.yml 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. ---
  2. # Updates pip, installs the lab scripts.
  3. #
  4. # The following variables must exist:
  5. #
  6. # lab_sku: ad482 (or some other SKU)
  7. # lab_package: rht-labs-{{ lab_sku }}
  8. # lab_index_url: https://pypi.apps.tools-na.prod.nextcle.com/repository/labs/simple/
  9. # lab_files_fixes: a list of patch files to apply to lab materials
  10. # - patch: files/patch.patch
  11. # target: some/file.txt
  12. #
  13. # TODO: ansible.posix.patch not found if you just run from playbook (syntax
  14. # error?!?). Re-running goes well and finds the module.
  15. #
  16. # TODO: fix .m2/settings.xml
  17. #
  18. # TODO: set java to 11 (for the AD482 part)
  19. #
  20. # TODO: set java back to 21 (for the custom part)
  21. #
  22. - name: Upgrade pip
  23. ansible.builtin.pip:
  24. name: pip
  25. state: latest
  26. - name: Install the lab package
  27. ansible.builtin.pip:
  28. name: "{{ lab_package }}"
  29. state: present
  30. extra_args: "--extra-index-url {{ lab_index_url }}"
  31. - name: Set the grading_config_file fact for convenience
  32. set_fact:
  33. grading_config_file: "{{ ansible_facts['user_dir'] }}/.grading/config.yaml"
  34. - name: Check if the grading config is there
  35. ansible.builtin.stat:
  36. path: "{{ grading_config_file }}"
  37. register: grading_file
  38. - name: Load the current grading config
  39. set_fact:
  40. grading_cfg: "{{ lookup('ansible.builtin.file', grading_config_file) | from_yaml }}"
  41. when: grading_file.stat.exists
  42. - name: Extract the current SKU
  43. set_fact:
  44. current_sku: "{{ grading_cfg.rhtlab.course.sku }}"
  45. when: grading_cfg is defined
  46. - name: Activate the new labs
  47. ansible.builtin.shell: "lab select {{ lab_sku }}"
  48. when: (current_sku is not defined) or (current_sku != lab_sku)
  49. - name: Ensure ansible POSIX collection is there
  50. become: yes
  51. yum:
  52. name:
  53. - ansible-collection-ansible-posix
  54. state: latest
  55. - name: Apply all the patches to lab resources
  56. ansible.posix.patch:
  57. src: "{{ item.patch }}"
  58. dest: "{{ item.target }}"
  59. ignore_whitespace: yes
  60. loop: "{{ lab_files_fixes }}"
  61. ...