generate_certs.yml 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. ---
  2. - name: Create service catalog cert directory
  3. file:
  4. path: "{{ openshift.common.config_base }}/service-catalog"
  5. state: directory
  6. mode: 0755
  7. changed_when: False
  8. check_mode: no
  9. - set_fact:
  10. generated_certs_dir: "{{ openshift.common.config_base }}/service-catalog"
  11. - name: Generate signing cert
  12. command: >
  13. {{ openshift.common.client_binary }} adm --config=/etc/origin/master/admin.kubeconfig ca create-signer-cert
  14. --key={{ generated_certs_dir }}/ca.key --cert={{ generated_certs_dir }}/ca.crt
  15. --serial={{ generated_certs_dir }}/apiserver.serial.txt --name=service-catalog-signer
  16. - name: Generating server keys
  17. oc_adm_ca_server_cert:
  18. cert: "{{ generated_certs_dir }}/apiserver.crt"
  19. key: "{{ generated_certs_dir }}/apiserver.key"
  20. hostnames: "apiserver.kube-service-catalog.svc,apiserver.kube-service-catalog.svc.cluster.local,apiserver.kube-service-catalog"
  21. signer_cert: "{{ generated_certs_dir }}/ca.crt"
  22. signer_key: "{{ generated_certs_dir }}/ca.key"
  23. signer_serial: "{{ generated_certs_dir }}/apiserver.serial.txt"
  24. - name: Create apiserver-ssl secret
  25. oc_secret:
  26. state: present
  27. name: apiserver-ssl
  28. namespace: kube-service-catalog
  29. files:
  30. - name: tls.crt
  31. path: "{{ generated_certs_dir }}/apiserver.crt"
  32. - name: tls.key
  33. path: "{{ generated_certs_dir }}/apiserver.key"
  34. - name: Create service-catalog-ssl secret
  35. oc_secret:
  36. state: present
  37. name: service-catalog-ssl
  38. namespace: kube-service-catalog
  39. files:
  40. - name: tls.crt
  41. path: "{{ generated_certs_dir }}/apiserver.crt"
  42. - slurp:
  43. src: "{{ generated_certs_dir }}/ca.crt"
  44. register: apiserver_ca
  45. - shell: >
  46. oc get apiservices.apiregistration.k8s.io/v1beta1.servicecatalog.k8s.io -n kube-service-catalog || echo "not found"
  47. register: get_apiservices
  48. changed_when: no
  49. - name: Create api service
  50. oc_obj:
  51. state: present
  52. name: v1beta1.servicecatalog.k8s.io
  53. kind: apiservices.apiregistration.k8s.io
  54. namespace: "kube-service-catalog"
  55. content:
  56. path: /tmp/apisvcout
  57. data:
  58. apiVersion: apiregistration.k8s.io/v1beta1
  59. kind: APIService
  60. metadata:
  61. name: v1beta1.servicecatalog.k8s.io
  62. spec:
  63. group: servicecatalog.k8s.io
  64. version: v1beta1
  65. service:
  66. namespace: "kube-service-catalog"
  67. name: apiserver
  68. caBundle: "{{ apiserver_ca.content }}"
  69. groupPriorityMinimum: 20
  70. versionPriority: 10
  71. when: "'not found' in get_apiservices.stdout"