main.yml 1.7 KB

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