main.yml 3.7 KB

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