generate_certs.yml 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. ---
  2. - when: ansible_service_broker_certs_dir is undefined
  3. block:
  4. - name: Create ansible-service-broker cert directory
  5. file:
  6. path: "{{ openshift.common.config_base }}/ansible-service-broker"
  7. state: directory
  8. mode: 0755
  9. check_mode: no
  10. - name: Create self signing ca cert
  11. command: 'openssl req -nodes -x509 -newkey rsa:4096 -keyout {{ openshift.common.config_base }}/ansible-service-broker/key.pem -out {{ openshift.common.config_base }}/ansible-service-broker/cert.pem -days 365 -subj "/CN=asb-etcd.openshift-ansible-service-broker.svc"'
  12. args:
  13. creates: '{{ openshift.common.config_base }}/ansible-service-broker/cert.pem'
  14. - name: Create self signed client cert
  15. command: '{{ item.cmd }}'
  16. args:
  17. creates: '{{ item.creates }}'
  18. with_items:
  19. - cmd: openssl genrsa -out {{ openshift.common.config_base }}/ansible-service-broker/client.key 2048
  20. creates: '{{ openshift.common.config_base }}/ansible-service-broker/client.key'
  21. - cmd: 'openssl req -new -key {{ openshift.common.config_base }}/ansible-service-broker/client.key -out {{ openshift.common.config_base }}/ansible-service-broker/client.csr -subj "/CN=client"'
  22. creates: '{{ openshift.common.config_base }}/ansible-service-broker/client.csr'
  23. - cmd: openssl x509 -req -in {{ openshift.common.config_base }}/ansible-service-broker/client.csr -CA {{ openshift.common.config_base }}/ansible-service-broker/cert.pem -CAkey {{ openshift.common.config_base }}/ansible-service-broker/key.pem -CAcreateserial -out {{ openshift.common.config_base }}/ansible-service-broker/client.pem -days 1024
  24. creates: '{{ openshift.common.config_base }}/ansible-service-broker/client.pem'
  25. - set_fact:
  26. ansible_service_broker_certs_dir: "{{ openshift.common.config_base }}/ansible-service-broker"
  27. - name: Read in certs for etcd
  28. slurp:
  29. src: '{{ ansible_service_broker_certs_dir }}/{{ item }}'
  30. register: asb_etcd_certs
  31. with_items:
  32. - cert.pem
  33. - client.pem
  34. - client.key
  35. - set_fact:
  36. etcd_ca_cert: "{{ asb_etcd_certs.results.0.content | b64decode }}"
  37. etcd_client_cert: "{{ asb_etcd_certs.results.1.content | b64decode }}"
  38. etcd_client_key: "{{ asb_etcd_certs.results.2.content | b64decode }}"