generate_certs.yml 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. - slurp:
  35. src: "{{ generated_certs_dir }}/ca.crt"
  36. register: apiserver_ca
  37. - shell: >
  38. oc get apiservices.apiregistration.k8s.io/v1alpha1.servicecatalog.k8s.io -n kube-service-catalog || echo "not found"
  39. register: get_apiservices
  40. changed_when: no
  41. - name: Create api service
  42. oc_obj:
  43. state: present
  44. name: v1alpha1.servicecatalog.k8s.io
  45. kind: apiservices.apiregistration.k8s.io
  46. namespace: "kube-service-catalog"
  47. content:
  48. path: /tmp/apisvcout
  49. data:
  50. apiVersion: apiregistration.k8s.io/v1beta1
  51. kind: APIService
  52. metadata:
  53. name: v1alpha1.servicecatalog.k8s.io
  54. spec:
  55. group: servicecatalog.k8s.io
  56. version: v1alpha1
  57. service:
  58. namespace: "kube-service-catalog"
  59. name: apiserver
  60. caBundle: "{{ apiserver_ca.content }}"
  61. groupPriorityMinimum: 20
  62. versionPriority: 10
  63. when: "'not found' in get_apiservices.stdout"