main.yml 3.4 KB

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