main.yml 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. ---
  2. # Fixes the openshift-marketplace catalogs by recreating them from original images.
  3. #
  4. # Needs the following vars from vars/main.yml:
  5. #
  6. # op_cat catalog source
  7. # op_pkg operator package name
  8. # desired_csv csv channel we look for
  9. # catalog_sources the catalog sources we recreate
  10. #
  11. # This is necessary immediately after lab create.
  12. - name: Wait for the marketplace-operator to be up
  13. k8s_info:
  14. kubeconfig: tmp/kubeconfig-ocp4
  15. validate_certs: no
  16. api_version: v1
  17. kind: pod
  18. namespace: openshift-marketplace
  19. label_selectors:
  20. - name=marketplace-operator
  21. register: mktplc_pod
  22. until:
  23. - (mktplc_pod.resources | length) == 1
  24. - mktplc_pod.resources[0].status.containerStatuses[0].ready
  25. retries: 30
  26. delay: 10
  27. - name: Make sure the do280-catalog is not there
  28. k8s:
  29. kubeconfig: tmp/kubeconfig-ocp4
  30. validate_certs: no
  31. api_version: operators.coreos.com/v1alpha1
  32. kind: catalogsource
  33. namespace: openshift-marketplace
  34. name: do280-catalog
  35. state: absent
  36. - name: Ensure the standard catalog sources are there
  37. k8s:
  38. kubeconfig: tmp/kubeconfig-ocp4
  39. validate_certs: no
  40. api_version: operators.coreos.com/v1alpha1
  41. kind: catalogsource
  42. namespace: openshift-marketplace
  43. name: "{{ item.name }}"
  44. state: present
  45. definition:
  46. spec:
  47. displayName: "{{ item.displ }}"
  48. image: "{{ item.image }}"
  49. publisher: "Red Hat"
  50. sourceType: "grpc"
  51. loop: "{{ catalog_sources }}"
  52. loop_control:
  53. label: "{{ item.displ }}"
  54. - name: Wait for the catalogsources to be ready.
  55. k8s_info:
  56. kubeconfig: tmp/kubeconfig-ocp4
  57. validate_certs: no
  58. api_version: operators.coreos.com/v1alpha1
  59. kind: catalogsource
  60. namespace: openshift-marketplace
  61. name: "{{ item.name }}"
  62. register: cat_stat
  63. until:
  64. - (cat_stat.resources | length) == 1
  65. - cat_stat.resources[0].status is defined
  66. - cat_stat.resources[0].status.connectionState.lastObservedState == "READY"
  67. retries: 30
  68. delay: 10
  69. loop: "{{ catalog_sources }}"
  70. loop_control:
  71. label: "{{ item.displ }}"
  72. - debug: var=cat_stat
  73. - name: Wait for the amq-broker-rhel8 packagemanifest to appear.
  74. k8s_info:
  75. kubeconfig: tmp/kubeconfig-ocp4
  76. validate_certs: no
  77. api_version: packages.operators.coreos.com/v1
  78. kind: packagemanifest
  79. namespace: openshift-marketplace
  80. name: "{{ op_pkg }}"
  81. register: op_mft
  82. until:
  83. - (op_mft.resources | length) == 1
  84. - op_mft.resources[0].status.catalogSource == op_cat
  85. - op_mft.resources[0].status.packageName == op_pkg
  86. retries: 30
  87. delay: 10
  88. - assert:
  89. that:
  90. - op_mft.resources is defined
  91. - (op_mft.resources | length) > 0
  92. - op_mft.resources[0].status.catalogSource == op_cat
  93. - 'desired_csv in (op_mft.resources[0] | community.general.json_query("status.channels[*].currentCSV") | list)'
  94. fail_msg: "ERROR: {{ op_pkg }} package manifest not deployed correctly."
  95. success_msg: "OK: {{ op_pkg }} package manifest configured correctly."
  96. ...