create_service_signer_cert.yml 3.0 KB

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