34-clair-disable.yml 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. ---
  2. # Tasks required to disable Clair scanning (required before oc-mirror).
  3. - name: Disable Clair integration in Quay and stop Clair.
  4. hosts: registry.ocp4.example.com
  5. gather_subset: min
  6. remote_user: quay
  7. tasks:
  8. - name: Ensure the podman network is there.
  9. containers.podman.podman_network_info:
  10. name: quay
  11. register: quay_net
  12. ignore_errors: yes
  13. - ansible.builtin.assert:
  14. that:
  15. - not quay_net.failed
  16. - quay_net.networks is defined
  17. - quay_net.networks is iterable
  18. - quay_net.networks | length == 1
  19. fail_msg: "FATAL: Podman network 'quay' does not exist for 'quay' user. Ensure you deployed Quay before running this playbook."
  20. success_msg: "OK, network 'quay' found."
  21. - name: Ensure the quay service is defined.
  22. ansible.builtin.stat:
  23. path: "{{ ansible_facts['user_dir'] }}/.config/systemd/user/quay.service"
  24. get_attributes: no
  25. get_checksum: no
  26. get_mime: no
  27. register: quay_svc_unit
  28. - ansible.builtin.assert:
  29. that:
  30. - not quay_svc_unit.failed
  31. - quay_svc_unit.stat.exists
  32. fail_msg: "FATAL: User service 'quay.service' not found for 'quay' user. Ensure you deployed Quay before running this playbook."
  33. success_msg: "OK, service 'quay.service' found."
  34. - name: Ensure the clair service is defined.
  35. ansible.builtin.stat:
  36. path: "{{ ansible_facts['user_dir'] }}/.config/systemd/user/clair.service"
  37. get_attributes: no
  38. get_checksum: no
  39. get_mime: no
  40. register: clair_svc_unit
  41. - ansible.builtin.assert:
  42. that:
  43. - not clair_svc_unit.failed
  44. - clair_svc_unit.stat.exists
  45. fail_msg: "FATAL: User service 'clair.service' not found for 'quay' user. Ensure you deployed Clair before running this playbook."
  46. success_msg: "OK, service 'clair.service' found."
  47. - name: Patch Quay config if necessary.
  48. ansible.builtin.lineinfile:
  49. path: "{{ ansible_facts['user_dir'] }}/config/config.yaml"
  50. regexp: "FEATURE_SECURITY_SCANNER:"
  51. line: "FEATURE_SECURITY_SCANNER: false"
  52. notify:
  53. - restart quay and wait for ready
  54. - name: Disable and stop Clair.
  55. ansible.builtin.systemd_service:
  56. name: clair
  57. scope: user
  58. state: stopped
  59. enabled: no
  60. - name: Also, kill the container if necessary.
  61. containers.podman.podman_container:
  62. name: clair
  63. state: stopped
  64. stop_time: 10
  65. handlers:
  66. - name: restart quay
  67. listen: restart quay and wait for ready
  68. ansible.builtin.systemd_service:
  69. name: quay
  70. scope: user
  71. state: restarted
  72. - name: wait for quay to become ready again
  73. listen: restart quay and wait for ready
  74. ansible.builtin.uri:
  75. method: GET
  76. url: https://registry.ocp4.example.com/
  77. headers:
  78. Accept: application/json
  79. Content-Type: application/json
  80. validate_certs: no
  81. status_code:
  82. - 200
  83. - 404
  84. - 502
  85. register: startup_wait
  86. until: startup_wait.status == 200
  87. retries: 30
  88. delay: 5
  89. ...