create_service_signer_cert.yml 3.0 KB

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