main.yml 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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. installPlanApproval: Automatic
  68. # TODO: Finish this at some point.
  69. #- name: Wait for installPlan to show up
  70. # k8s_info:
  71. # kubeconfig: tmp/kubeconfig-ocp4
  72. # validate_certs: no
  73. # api_version: operators.coreos.com/v1alpha1
  74. # kind: installplan
  75. # namespace: "{{ op_nsp }}"
  76. # register: installplan
  77. # until:
  78. # - installplan.resources is defined
  79. # - (installplan.resources | length) > 0
  80. # - installplan.resources[0].spec.approved
  81. # retries: 12
  82. # delay: 10
  83. - name: Wait for CSV to show up and complete
  84. k8s_info:
  85. kubeconfig: tmp/kubeconfig-ocp4
  86. validate_certs: no
  87. api_version: operators.coreos.com/v1alpha1
  88. kind: clusterserviceversion
  89. namespace: "{{ op_nsp }}"
  90. name: "{{ desired_csv }}"
  91. register: new_csv
  92. until:
  93. - new_csv.resources is defined
  94. - (new_csv.resources | length) > 0
  95. - new_csv.resources[0].status is defined
  96. - new_csv.resources[0].status.phase == "Succeeded"
  97. retries: 30
  98. delay: 10
  99. # TODO: Finish this at some point.
  100. #- name: Finally, wait for the pod
  101. # k8s_info:
  102. # kubeconfig: tmp/kubeconfig-ocp4
  103. # validate_certs: no
  104. # api_version: v1
  105. # kind: pod
  106. # namespace: rhsso
  107. # label_selectors:
  108. # - name = rhsso-operator
  109. # register: sso_pod
  110. # until:
  111. # - sso_pod.resources is defined
  112. # - (sso_pod.resources | length) > 0
  113. # - sso_pod.resources[0].status is defined
  114. # - sso_pod.resources[0].status.phase == "Running"
  115. # retries: 30
  116. # delay: 10
  117. ...