45-oc-mirror.yml 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. ---
  2. # Create image set config if necessary, start "oc mirror".
  3. - name: Ensure "oc mirror" has completed. (NON-IDEMPOTENT!)
  4. hosts: workstation.lab.example.com
  5. gather_subset: min
  6. become: no
  7. tasks:
  8. - name: Ensure working directory exists.
  9. ansible.builtin.file:
  10. path: "{{ ansible_facts['user_dir'] }}/mirror"
  11. state: directory
  12. mode: 0755
  13. owner: student
  14. group: student
  15. - name: Ensure image set config is correct.
  16. ansible.builtin.copy:
  17. dest: "{{ ansible_facts['user_dir'] }}/image-set-config.yaml"
  18. mode: 0644
  19. owner: student
  20. group: student
  21. content: |
  22. kind: ImageSetConfiguration
  23. apiVersion: mirror.openshift.io/v2alpha1
  24. mirror:
  25. platform:
  26. channels:
  27. - name: stable-4.18
  28. type: ocp
  29. minVersion: 4.18.6
  30. maxVersion: 4.18.6
  31. graph: true
  32. operators:
  33. - catalog: registry.redhat.io/redhat/redhat-operator-index:v4.18
  34. full: false
  35. packages:
  36. - name: node-maintenance-operator
  37. additionalImages:
  38. - name: registry.redhat.io/ubi9/ubi:latest
  39. - name: Kick off "oc mirror".
  40. ansible.builtin.command:
  41. cmd: oc mirror --v2 -c {{ ansible_facts['user_dir'] }}/image-set-config.yaml --workspace file://{{ ansible_facts['user_dir'] }}/mirror/ docker://registry.ocp4.example.com
  42. register: mirror_output
  43. - name: Show what happened on stdout.
  44. ansible.builtin.debug:
  45. var: mirror_output.stdout_lines
  46. - name: Show what happened on stderr.
  47. ansible.builtin.debug:
  48. var: mirror_output.stderr_lines
  49. ...