create_service_signer_cert.yml 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. ---
  2. - name: Create local temp directory for syncing certs
  3. hosts: localhost
  4. connection: local
  5. become: no
  6. gather_facts: no
  7. tasks:
  8. - name: Create local temp directory for syncing certs
  9. local_action: command mktemp -d /tmp/openshift-ansible-XXXXXXX
  10. register: local_cert_sync_tmpdir
  11. changed_when: false
  12. when: not (hostvars[groups.oo_first_master.0].service_signer_cert_stat.stat.exists | bool)
  13. - name: Create service signer certificate
  14. hosts: oo_first_master
  15. tasks:
  16. - name: Create remote temp directory for creating certs
  17. command: mktemp -d /tmp/openshift-ansible-XXXXXXX
  18. register: remote_cert_create_tmpdir
  19. changed_when: false
  20. when: not (hostvars[groups.oo_first_master.0].service_signer_cert_stat.stat.exists | bool)
  21. - name: Create service signer certificate
  22. command: >
  23. {{ openshift_client_binary }} adm ca create-signer-cert
  24. --cert="{{ remote_cert_create_tmpdir.stdout }}/"service-signer.crt
  25. --key="{{ remote_cert_create_tmpdir.stdout }}/"service-signer.key
  26. --name="{{ remote_cert_create_tmpdir.stdout }}/"openshift-service-serving-signer
  27. --serial="{{ remote_cert_create_tmpdir.stdout }}/"service-signer.serial.txt
  28. args:
  29. chdir: "{{ remote_cert_create_tmpdir.stdout }}/"
  30. when: not (hostvars[groups.oo_first_master.0].service_signer_cert_stat.stat.exists | bool)
  31. - name: Retrieve service signer certificate
  32. fetch:
  33. src: "{{ remote_cert_create_tmpdir.stdout }}/{{ item }}"
  34. dest: "{{ hostvars.localhost.local_cert_sync_tmpdir.stdout }}/"
  35. flat: yes
  36. fail_on_missing: yes
  37. validate_checksum: yes
  38. with_items:
  39. - "service-signer.crt"
  40. - "service-signer.key"
  41. when: not (hostvars[groups.oo_first_master.0].service_signer_cert_stat.stat.exists | bool)
  42. - name: Delete remote temp directory
  43. file:
  44. name: "{{ remote_cert_create_tmpdir.stdout }}"
  45. state: absent
  46. changed_when: false
  47. when: not (hostvars[groups.oo_first_master.0].service_signer_cert_stat.stat.exists | bool)
  48. - name: Deploy service signer certificate
  49. hosts: oo_masters_to_config
  50. tasks:
  51. - name: Deploy service signer certificate
  52. copy:
  53. src: "{{ hostvars.localhost.local_cert_sync_tmpdir.stdout }}/{{ item }}"
  54. dest: "{{ openshift.common.config_base }}/master/"
  55. with_items:
  56. - "service-signer.crt"
  57. - "service-signer.key"
  58. when: not (hostvars[groups.oo_first_master.0].service_signer_cert_stat.stat.exists | bool)
  59. - name: Delete local temp directory
  60. hosts: localhost
  61. connection: local
  62. become: no
  63. gather_facts: no
  64. tasks:
  65. - name: Delete local temp directory
  66. file:
  67. name: "{{ local_cert_sync_tmpdir.stdout }}"
  68. state: absent
  69. changed_when: false
  70. when: not (hostvars[groups.oo_first_master.0].service_signer_cert_stat.stat.exists | bool)