main.yml 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. ---
  2. # Ensures all the operator artifacts are created and waits for CSV to succeed.
  3. #
  4. # The following variables must exist:
  5. #
  6. # desired_csv
  7. # op_nsp
  8. # op_cat
  9. # op_pkg
  10. # op_chn
  11. #
  12. # NOTE: Do NOT test by checking for presence of API resources - they do not always get cleaned up.
  13. #
  14. # TODO: Maybe someday fix the JSONPath expression below. And figure out why check for a CSV.
  15. #- name: Check if the CSV exists already
  16. # k8s_info:
  17. # kubeconfig: tmp/kubeconfig-ocp4
  18. # validate_certs: no
  19. # api_version: operators.coreos.com/v1alpha1
  20. # kind: clusterserviceversion
  21. # register: all_csv
  22. #
  23. #- name: Find the wanted CSV among all CSVs
  24. # set_fact:
  25. # found_csv: "{{ (all_csv | community.general.json_query(\"resources[?metadata.name == \" + desired_csv + \"]\")) }}"
  26. # when:
  27. # - all_csv.resources is defined
  28. # - (all_csv.resources | length) > 0
  29. #
  30. #- name: Get details about the CSV if found
  31. # set_fact:
  32. # csv_ns: "{{ found_csv[0] | community.general.json_query('metadata.namespace') }}"
  33. # csv_name: "{{ found_csv[0] | community.general.json_query('metadata.name') }}"
  34. # when:
  35. # - found_csv is defined
  36. # - (found_csv | length) > 0
  37. - name: Make sure the namespace is there
  38. k8s:
  39. kubeconfig: tmp/kubeconfig-ocp4
  40. validate_certs: no
  41. api_version: v1
  42. kind: namespace
  43. name: "{{ op_nsp }}"
  44. # TODO: Finish this at some point.
  45. #- name: Make sure it has a properly configured OperatorGroup
  46. # k8s_info:
  47. # kubeconfig: tmp/kubeconfig-ocp4
  48. # validate_certs: no
  49. # api_version: operators.coreos.com/v1
  50. # kind: operatorgroup
  51. # namespace: "{{ op_nsp }}"
  52. # register: found_opgrp
  53. - name: Also make sure there is a subscription
  54. k8s:
  55. kubeconfig: tmp/kubeconfig-ocp4
  56. validate_certs: no
  57. api_version: operators.coreos.com/v1alpha1
  58. kind: subscription
  59. namespace: "{{ op_nsp }}"
  60. name: "{{ op_pkg }}"
  61. definition:
  62. spec:
  63. source: "{{ op_cat }}"
  64. sourceNamespace: openshift-marketplace
  65. name: "{{ op_pkg }}"
  66. channel: "{{ op_chn }}"
  67. startingCSV: "{{ desired_csv }}"
  68. installPlanApproval: Automatic
  69. # TODO: Finish this at some point.
  70. #- name: Wait for installPlan to show up
  71. # k8s_info:
  72. # kubeconfig: tmp/kubeconfig-ocp4
  73. # validate_certs: no
  74. # api_version: operators.coreos.com/v1alpha1
  75. # kind: installplan
  76. # namespace: "{{ op_nsp }}"
  77. # register: installplan
  78. # until:
  79. # - installplan.resources is defined
  80. # - (installplan.resources | length) > 0
  81. # - installplan.resources[0].spec.approved
  82. # retries: 12
  83. # delay: 10
  84. - name: Wait for CSV to show up and complete
  85. k8s_info:
  86. kubeconfig: tmp/kubeconfig-ocp4
  87. validate_certs: no
  88. api_version: operators.coreos.com/v1alpha1
  89. kind: clusterserviceversion
  90. namespace: "{{ op_nsp }}"
  91. name: "{{ desired_csv }}"
  92. register: new_csv
  93. until:
  94. - new_csv.resources is defined
  95. - (new_csv.resources | length) > 0
  96. - new_csv.resources[0].status is defined
  97. - new_csv.resources[0].status.phase == "Succeeded"
  98. retries: 30
  99. delay: 10
  100. # TODO: Finish this at some point.
  101. #- name: Finally, wait for the pod
  102. # k8s_info:
  103. # kubeconfig: tmp/kubeconfig-ocp4
  104. # validate_certs: no
  105. # api_version: v1
  106. # kind: pod
  107. # namespace: rhsso
  108. # label_selectors:
  109. # - name = rhsso-operator
  110. # register: sso_pod
  111. # until:
  112. # - sso_pod.resources is defined
  113. # - (sso_pod.resources | length) > 0
  114. # - sso_pod.resources[0].status is defined
  115. # - sso_pod.resources[0].status.phase == "Running"
  116. # retries: 30
  117. # delay: 10
  118. ...