45-oc-mirror.yml 2.0 KB

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