generate_certs.yml 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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: Delete old apiserver.crt
  17. file:
  18. path: "{{ generated_certs_dir }}/apiserver.crt"
  19. state: absent
  20. - name: Delete old apiserver.key
  21. file:
  22. path: "{{ generated_certs_dir }}/apiserver.key"
  23. state: absent
  24. - name: Generating server keys
  25. oc_adm_ca_server_cert:
  26. cert: "{{ generated_certs_dir }}/apiserver.crt"
  27. key: "{{ generated_certs_dir }}/apiserver.key"
  28. hostnames: "apiserver.kube-service-catalog.svc,apiserver.kube-service-catalog.svc.cluster.local,apiserver.kube-service-catalog"
  29. signer_cert: "{{ generated_certs_dir }}/ca.crt"
  30. signer_key: "{{ generated_certs_dir }}/ca.key"
  31. signer_serial: "{{ generated_certs_dir }}/apiserver.serial.txt"
  32. - name: Create apiserver-ssl secret
  33. oc_secret:
  34. state: present
  35. name: apiserver-ssl
  36. namespace: kube-service-catalog
  37. files:
  38. - name: tls.crt
  39. path: "{{ generated_certs_dir }}/apiserver.crt"
  40. - name: tls.key
  41. path: "{{ generated_certs_dir }}/apiserver.key"
  42. - name: Create service-catalog-ssl secret
  43. oc_secret:
  44. state: present
  45. name: service-catalog-ssl
  46. namespace: kube-service-catalog
  47. files:
  48. - name: tls.crt
  49. path: "{{ generated_certs_dir }}/apiserver.crt"
  50. - slurp:
  51. src: "{{ generated_certs_dir }}/ca.crt"
  52. register: apiserver_ca
  53. - shell: >
  54. {{ openshift.common.client_binary }} --config=/etc/origin/master/admin.kubeconfig get apiservices.apiregistration.k8s.io/v1beta1.servicecatalog.k8s.io -n kube-service-catalog || echo "not found"
  55. register: get_apiservices
  56. changed_when: no
  57. - name: Create api service
  58. oc_obj:
  59. state: present
  60. name: v1beta1.servicecatalog.k8s.io
  61. kind: apiservices.apiregistration.k8s.io
  62. namespace: "kube-service-catalog"
  63. content:
  64. path: /tmp/apisvcout
  65. data:
  66. apiVersion: apiregistration.k8s.io/v1beta1
  67. kind: APIService
  68. metadata:
  69. name: v1beta1.servicecatalog.k8s.io
  70. spec:
  71. group: servicecatalog.k8s.io
  72. version: v1beta1
  73. service:
  74. namespace: "kube-service-catalog"
  75. name: apiserver
  76. caBundle: "{{ apiserver_ca.content }}"
  77. groupPriorityMinimum: 20
  78. versionPriority: 10
  79. when: "'not found' in get_apiservices.stdout"