main.yml 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. ---
  2. # Ensures a CertManager instance is deployed and configured with a CA.
  3. #
  4. # TODO: oc patch featuregate/cluster --type=merge -p '{"spec": {"customNoUpgrade": {"enabled": ["RouteExternalCertificate"]}}}'
  5. #
  6. - name: See if the Cert Manager project is there.
  7. kubernetes.core.k8s_info:
  8. kubeconfig: tmp/kubeconfig-ocp4
  9. validate_certs: no
  10. api_version: v1
  11. kind: namespace
  12. name: cert-manager
  13. register: cmgr_ns
  14. - name: Fail if not so.
  15. ansible.builtin.assert:
  16. that:
  17. - cmgr_ns.resources is defined
  18. - cmgr_ns.resources | length == 1
  19. success_msg: "OK, CertManager namespace found."
  20. fail_msg: "FATAL: CertManager namespace is missing. Ensure the operator is deployed before proceeding."
  21. - name: See if the CertManager CSV is there as well.
  22. kubernetes.core.k8s_info:
  23. kubeconfig: tmp/kubeconfig-ocp4
  24. validate_certs: no
  25. api_version: operators.coreos.com/v1alpha1
  26. kind: clusterserviceversion
  27. namespace: cert-manager
  28. label_selectors:
  29. - operators.coreos.com/openshift-cert-manager-operator.cert-manager=
  30. register: cmgr_csv
  31. - name: Fail if not so.
  32. ansible.builtin.assert:
  33. that:
  34. - cmgr_csv.resources is defined
  35. - cmgr_csv.resources | length > 0
  36. success_msg: "OK, CertManager CSV found."
  37. fail_msg: "FATAL: CertManager CSV is missing. Ensure the operator is deployed before proceeding."
  38. - name: Read the CA cert on workstation as a fact
  39. ansible.builtin.slurp:
  40. src: "{{ ansible_facts['user_dir'] }}/ca/ca-cert.pem"
  41. register: ca_cert
  42. - name: Read the CA key on workstation as a fact
  43. ansible.builtin.slurp:
  44. src: "{{ ansible_facts['user_dir'] }}/ca/ca-key.pem"
  45. register: ca_key
  46. - name: Ensure a TLS secret containing the two is there
  47. kubernetes.core.k8s:
  48. kubeconfig: tmp/kubeconfig-ocp4
  49. validate_certs: no
  50. api_version: v1
  51. kind: secret
  52. namespace: cert-manager
  53. name: cert-manager-ca-secret
  54. resource_definition:
  55. type: kubernetes.io/tls
  56. data:
  57. tls.crt: "{{ ca_cert.content }}"
  58. tls.key: "{{ ca_key.content }}"
  59. - name: Ensure a cert manager instance is there
  60. kubernetes.core.k8s:
  61. kubeconfig: tmp/kubeconfig-ocp4
  62. validate_certs: no
  63. api_version: operator.openshift.io/v1alpha1
  64. kind: certmanager
  65. name: cluster
  66. resource_definition:
  67. spec: {}
  68. - name: Ensure a cluster issuer is there
  69. kubernetes.core.k8s:
  70. kubeconfig: tmp/kubeconfig-ocp4
  71. validate_certs: no
  72. api_version: cert-manager.io/v1
  73. kind: clusterissuer
  74. name: cluster-cert-issuer
  75. resource_definition:
  76. spec:
  77. ca:
  78. secretName: cert-manager-ca-secret
  79. ...