main.yml 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. ---
  2. # Ensures all the operator artifacts are created and waits for CSV to succeed.
  3. #
  4. # The following variables must exist:
  5. #
  6. # added_operators: (list)
  7. # - catalog: the catalog of the manifest
  8. # package: the name of the packagemanifest
  9. # subscription: the name of the subscription (optional, defaults to package)
  10. # channel: which channel to install from
  11. # namespace: target namespace for subscription
  12. # desired_csv: for verification - wait for this CSV to appear
  13. # og_namespaces: (list) operatorgroup namespaces (XXX not currently used XXX)
  14. #
  15. # This role must then be applied as:
  16. #
  17. # - include_role:
  18. # name: deploy-operators
  19. # loop: "{{ added_operators }}"
  20. # loop_control:
  21. # loop_var: role
  22. #
  23. # What this means is that each item of added_operators is expected to be
  24. # placed in the "role" variable prior to iterating over this role.
  25. #
  26. # NOTE: Do NOT test by checking for presence of API resources - they do not always get cleaned up.
  27. #
  28. - name: Make sure the namespace is there
  29. k8s:
  30. kubeconfig: tmp/kubeconfig-ocp4
  31. validate_certs: no
  32. api_version: v1
  33. kind: namespace
  34. name: "{{ role.namespace }}"
  35. # TODO: Finish this at some point.
  36. # TODO: Just apply from role.og_namespaces - finding an OG or just applying a default name.
  37. #- name: Make sure the namespace has a properly configured OperatorGroup
  38. # k8s_info:
  39. # kubeconfig: tmp/kubeconfig-ocp4
  40. # validate_certs: no
  41. # api_version: operators.coreos.com/v1
  42. # kind: operatorgroup
  43. # namespace: "{{ op_nsp }}"
  44. # register: found_opgrp
  45. - name: Also make sure there is a subscription
  46. k8s:
  47. kubeconfig: tmp/kubeconfig-ocp4
  48. validate_certs: no
  49. api_version: operators.coreos.com/v1alpha1
  50. kind: subscription
  51. namespace: "{{ role.namespace }}"
  52. name: "{{ role.subscription | default(role.package) }}"
  53. definition:
  54. spec:
  55. source: "{{ role.catalog }}"
  56. sourceNamespace: openshift-marketplace
  57. name: "{{ role.package }}"
  58. channel: "{{ role.channel }}"
  59. startingCSV: "{{ role.desired_csv }}"
  60. installPlanApproval: Automatic
  61. # TODO: Finish this at some point.
  62. #- name: Wait for installPlan to show up
  63. # k8s_info:
  64. # kubeconfig: tmp/kubeconfig-ocp4
  65. # validate_certs: no
  66. # api_version: operators.coreos.com/v1alpha1
  67. # kind: installplan
  68. # namespace: "{{ op_nsp }}"
  69. # register: installplan
  70. # until:
  71. # - installplan.resources is defined
  72. # - (installplan.resources | length) > 0
  73. # - installplan.resources[0].spec.approved
  74. # retries: 12
  75. # delay: 10
  76. - name: Wait for CSV to show up and complete
  77. k8s_info:
  78. kubeconfig: tmp/kubeconfig-ocp4
  79. validate_certs: no
  80. api_version: operators.coreos.com/v1alpha1
  81. kind: clusterserviceversion
  82. namespace: "{{ role.namespace }}"
  83. name: "{{ role.desired_csv }}"
  84. register: new_csv
  85. until:
  86. - new_csv.resources is defined
  87. - (new_csv.resources | length) > 0
  88. - new_csv.resources[0].status is defined
  89. - new_csv.resources[0].status.phase == "Succeeded"
  90. retries: 30
  91. delay: 10
  92. # TODO: Finish this at some point.
  93. #- name: Finally, wait for the pod
  94. # k8s_info:
  95. # kubeconfig: tmp/kubeconfig-ocp4
  96. # validate_certs: no
  97. # api_version: v1
  98. # kind: pod
  99. # namespace: rhsso
  100. # label_selectors:
  101. # - name = rhsso-operator
  102. # register: sso_pod
  103. # until:
  104. # - sso_pod.resources is defined
  105. # - (sso_pod.resources | length) > 0
  106. # - sso_pod.resources[0].status is defined
  107. # - sso_pod.resources[0].status.phase == "Running"
  108. # retries: 30
  109. # delay: 10
  110. ...