main.yml 3.3 KB

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