main.yml 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. - name: Upgrade pip
  17. ansible.builtin.pip:
  18. name: pip
  19. state: latest
  20. - name: Install the lab package
  21. ansible.builtin.pip:
  22. name: "{{ lab_package }}"
  23. state: present
  24. extra_args: "--extra-index-url {{ lab_index_url }}"
  25. - name: Set the grading_config_file fact for convenience
  26. set_fact:
  27. grading_config_file: "{{ ansible_facts['user_dir'] }}/.grading/config.yaml"
  28. - name: Check if the grading config is there
  29. ansible.builtin.stat:
  30. path: "{{ grading_config_file }}"
  31. register: grading_file
  32. - name: Load the current grading config
  33. set_fact:
  34. grading_cfg: "{{ lookup('ansible.builtin.file', grading_config_file) | from_yaml }}"
  35. when: grading_file.stat.exists
  36. - name: Extract the current SKU
  37. set_fact:
  38. current_sku: "{{ grading_cfg.rhtlab.course.sku }}"
  39. when: grading_cfg is defined
  40. - name: Activate the new labs
  41. ansible.builtin.shell: "lab select {{ lab_sku }}"
  42. when: (current_sku is not defined) or (current_sku != lab_sku)
  43. - name: Ensure ansible POSIX collection is there
  44. become: yes
  45. yum:
  46. name:
  47. - ansible-collection-ansible-posix
  48. state: latest
  49. - name: Apply all the patches to lab resources
  50. ansible.posix.patch:
  51. src: "{{ item.patch }}"
  52. dest: "{{ item.target }}"
  53. ignore_whitespace: yes
  54. loop: "{{ lab_files_fixes }}"
  55. ...