main.yml 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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. # removed_sources the catalog sources we remove
  7. # catalog_sources the catalog sources we recreate
  8. #
  9. # These would usually come from inventory, and should point to a single
  10. # manifest and its CSV that we can use to verify catalog sources were created
  11. # and populated successfully:
  12. #
  13. # vrfy_cat catalog source
  14. # vrfy_pkg operator package name
  15. # vrfy_csv csv we look for
  16. #
  17. # This is necessary immediately after lab create.
  18. - name: Wait for the marketplace-operator to be up
  19. k8s_info:
  20. kubeconfig: tmp/kubeconfig-ocp4
  21. validate_certs: no
  22. api_version: v1
  23. kind: pod
  24. namespace: openshift-marketplace
  25. label_selectors:
  26. - name=marketplace-operator
  27. register: mktplc_pod
  28. until:
  29. - (mktplc_pod.resources | length) == 1
  30. - mktplc_pod.resources[0].status.containerStatuses[0].ready
  31. retries: 30
  32. delay: 10
  33. - name: Make sure the course catalog is not there
  34. k8s:
  35. kubeconfig: tmp/kubeconfig-ocp4
  36. validate_certs: no
  37. api_version: operators.coreos.com/v1alpha1
  38. kind: catalogsource
  39. namespace: openshift-marketplace
  40. name: "{{ item }}"
  41. state: absent
  42. loop: "{{ removed_sources }}"
  43. - name: Make sure the pull secret will do for online sources
  44. k8s:
  45. kubeconfig: tmp/kubeconfig-ocp4
  46. validate_certs: no
  47. api_version: v1
  48. kind: secret
  49. namespace: openshift-config
  50. name: pull-secret
  51. state: present
  52. definition: "{{ lookup('file', 'files/pull-secret.yml') | from_yaml }}"
  53. - name: Ensure the standard catalog sources are there
  54. k8s:
  55. kubeconfig: tmp/kubeconfig-ocp4
  56. validate_certs: no
  57. api_version: operators.coreos.com/v1alpha1
  58. kind: catalogsource
  59. namespace: openshift-marketplace
  60. name: "{{ item.name }}"
  61. state: present
  62. definition:
  63. spec:
  64. displayName: "{{ item.displ }}"
  65. image: "{{ item.image }}"
  66. publisher: "Red Hat"
  67. sourceType: "grpc"
  68. loop: "{{ catalog_sources }}"
  69. loop_control:
  70. label: "{{ item.displ }}"
  71. - name: Wait for the catalogsources to be ready.
  72. k8s_info:
  73. kubeconfig: tmp/kubeconfig-ocp4
  74. validate_certs: no
  75. api_version: operators.coreos.com/v1alpha1
  76. kind: catalogsource
  77. namespace: openshift-marketplace
  78. name: "{{ item.name }}"
  79. register: cat_stat
  80. until:
  81. - (cat_stat.resources | length) == 1
  82. - cat_stat.resources[0].status is defined
  83. - cat_stat.resources[0].status.connectionState.lastObservedState == "READY"
  84. retries: 30
  85. delay: 10
  86. loop: "{{ catalog_sources }}"
  87. loop_control:
  88. label: "{{ item.displ }}"
  89. - name: Verify correct deployment
  90. block:
  91. - name: Wait for the operator packagemanifest to appear.
  92. k8s_info:
  93. kubeconfig: tmp/kubeconfig-ocp4
  94. validate_certs: no
  95. api_version: packages.operators.coreos.com/v1
  96. kind: packagemanifest
  97. namespace: openshift-marketplace
  98. name: "{{ vrfy_pkg }}"
  99. register: vrfy_mft
  100. until:
  101. - (vrfy_mft.resources | length) == 1
  102. - vrfy_mft.resources[0].status.catalogSource == vrfy_cat
  103. - vrfy_mft.resources[0].status.packageName == vrfy_pkg
  104. retries: 60
  105. delay: 10
  106. - assert:
  107. that:
  108. - vrfy_mft.resources is defined
  109. - (vrfy_mft.resources | length) > 0
  110. - vrfy_mft.resources[0].status.catalogSource == vrfy_cat
  111. - 'vrfy_csv in (vrfy_mft.resources[0] | community.general.json_query("status.channels[*].currentCSV") | list)'
  112. fail_msg: "ERROR: {{ vrfy_pkg }} package manifest not deployed correctly."
  113. success_msg: "OK: {{ vrfy_pkg }} package manifest configured correctly."
  114. when:
  115. - vrfy_cat is defined
  116. - vrfy_pkg is defined
  117. - vrfy_csv is defined
  118. ...