main.yml 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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 course 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: "{{ removed_catalog }}"
  35. state: absent
  36. - name: Make sure the pull secret will do for online sources
  37. k8s:
  38. kubeconfig: tmp/kubeconfig-ocp4
  39. validate_certs: no
  40. api_version: v1
  41. kind: secret
  42. namespace: openshift-config
  43. name: pull-secret
  44. src: files/pull-secret.yml
  45. - name: Ensure the standard catalog sources are there
  46. k8s:
  47. kubeconfig: tmp/kubeconfig-ocp4
  48. validate_certs: no
  49. api_version: operators.coreos.com/v1alpha1
  50. kind: catalogsource
  51. namespace: openshift-marketplace
  52. name: "{{ item.name }}"
  53. state: present
  54. definition:
  55. spec:
  56. displayName: "{{ item.displ }}"
  57. image: "{{ item.image }}"
  58. publisher: "Red Hat"
  59. sourceType: "grpc"
  60. loop: "{{ catalog_sources }}"
  61. loop_control:
  62. label: "{{ item.displ }}"
  63. - name: Wait for the catalogsources to be ready.
  64. k8s_info:
  65. kubeconfig: tmp/kubeconfig-ocp4
  66. validate_certs: no
  67. api_version: operators.coreos.com/v1alpha1
  68. kind: catalogsource
  69. namespace: openshift-marketplace
  70. name: "{{ item.name }}"
  71. register: cat_stat
  72. until:
  73. - (cat_stat.resources | length) == 1
  74. - cat_stat.resources[0].status is defined
  75. - cat_stat.resources[0].status.connectionState.lastObservedState == "READY"
  76. retries: 30
  77. delay: 10
  78. loop: "{{ catalog_sources }}"
  79. loop_control:
  80. label: "{{ item.displ }}"
  81. - name: Wait for the amq-broker-rhel8 packagemanifest to appear.
  82. k8s_info:
  83. kubeconfig: tmp/kubeconfig-ocp4
  84. validate_certs: no
  85. api_version: packages.operators.coreos.com/v1
  86. kind: packagemanifest
  87. namespace: openshift-marketplace
  88. name: "{{ op_pkg }}"
  89. register: op_mft
  90. until:
  91. - (op_mft.resources | length) == 1
  92. - op_mft.resources[0].status.catalogSource == op_cat
  93. - op_mft.resources[0].status.packageName == op_pkg
  94. retries: 60
  95. delay: 10
  96. - assert:
  97. that:
  98. - op_mft.resources is defined
  99. - (op_mft.resources | length) > 0
  100. - op_mft.resources[0].status.catalogSource == op_cat
  101. - 'desired_csv in (op_mft.resources[0] | community.general.json_query("status.channels[*].currentCSV") | list)'
  102. fail_msg: "ERROR: {{ op_pkg }} package manifest not deployed correctly."
  103. success_msg: "OK: {{ op_pkg }} package manifest configured correctly."
  104. ...