generate_certs.yml 2.1 KB

1234567891011121314151617181920212223242526272829303132333435
  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. - set_fact:
  28. etcd_ca_cert: "{{ lookup('file', '{{ ansible_service_broker_certs_dir }}/cert.pem') }}"
  29. etcd_client_cert: "{{ lookup('file', '{{ ansible_service_broker_certs_dir }}/client.pem') }}"
  30. etcd_client_key: "{{ lookup('file', '{{ ansible_service_broker_certs_dir }}/client.key') }}"