create_service_signer_cert.yml 2.7 KB

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