config.yml 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. ---
  2. - name: Set etcd facts needed for generating certs
  3. hosts: oo_etcd_to_config
  4. roles:
  5. - openshift_facts
  6. tasks:
  7. - openshift_facts:
  8. role: "{{ item.role }}"
  9. local_facts: "{{ item.local_facts }}"
  10. with_items:
  11. - role: common
  12. local_facts:
  13. hostname: "{{ openshift_hostname | default(None) }}"
  14. public_hostname: "{{ openshift_public_hostname | default(None) }}"
  15. deployment_type: "{{ openshift_deployment_type }}"
  16. - name: Check status of etcd certificates
  17. stat:
  18. path: "{{ item }}"
  19. with_items:
  20. - /etc/etcd/server.crt
  21. - /etc/etcd/peer.crt
  22. - /etc/etcd/ca.crt
  23. register: g_etcd_server_cert_stat_result
  24. - set_fact:
  25. etcd_server_certs_missing: "{{ g_etcd_server_cert_stat_result.results | map(attribute='stat.exists')
  26. | list | intersect([false])}}"
  27. etcd_cert_subdir: etcd-{{ openshift.common.hostname }}
  28. etcd_cert_config_dir: /etc/etcd
  29. etcd_cert_prefix:
  30. - name: Create temp directory for syncing certs
  31. hosts: localhost
  32. connection: local
  33. sudo: false
  34. gather_facts: no
  35. tasks:
  36. - name: Create local temp directory for syncing certs
  37. local_action: command mktemp -d /tmp/openshift-ansible-XXXXXXX
  38. register: g_etcd_mktemp
  39. changed_when: False
  40. - name: Configure etcd certificates
  41. hosts: oo_first_etcd
  42. vars:
  43. etcd_generated_certs_dir: /etc/etcd/generated_certs
  44. etcd_needing_server_certs: "{{ hostvars
  45. | oo_select_keys(groups['oo_etcd_to_config'])
  46. | oo_filter_list(filter_attr='etcd_server_certs_missing') }}"
  47. sync_tmpdir: "{{ hostvars.localhost.g_etcd_mktemp.stdout }}"
  48. roles:
  49. - etcd_certificates
  50. post_tasks:
  51. - name: Create a tarball of the etcd certs
  52. command: >
  53. tar -czvf {{ etcd_generated_certs_dir }}/{{ item.etcd_cert_subdir }}.tgz
  54. -C {{ etcd_generated_certs_dir }}/{{ item.etcd_cert_subdir }} .
  55. args:
  56. creates: "{{ etcd_generated_certs_dir }}/{{ item.etcd_cert_subdir }}.tgz"
  57. with_items: etcd_needing_server_certs
  58. - name: Retrieve the etcd cert tarballs
  59. fetch:
  60. src: "{{ etcd_generated_certs_dir }}/{{ item.etcd_cert_subdir }}.tgz"
  61. dest: "{{ sync_tmpdir }}/"
  62. flat: yes
  63. fail_on_missing: yes
  64. validate_checksum: yes
  65. with_items: etcd_needing_server_certs
  66. - name: Configure etcd hosts
  67. hosts: oo_etcd_to_config
  68. vars:
  69. sync_tmpdir: "{{ hostvars.localhost.g_etcd_mktemp.stdout }}"
  70. etcd_url_scheme: https
  71. etcd_peer_url_scheme: https
  72. etcd_peers_group: oo_etcd_to_config
  73. pre_tasks:
  74. - name: Ensure certificate directory exists
  75. file:
  76. path: "{{ etcd_cert_config_dir }}"
  77. state: directory
  78. - name: Unarchive the tarball on the etcd host
  79. unarchive:
  80. src: "{{ sync_tmpdir }}/{{ etcd_cert_subdir }}.tgz"
  81. dest: "{{ etcd_cert_config_dir }}"
  82. when: etcd_server_certs_missing
  83. roles:
  84. - etcd
  85. - role: nickhammond.logrotate
  86. - name: Delete temporary directory on localhost
  87. hosts: localhost
  88. connection: local
  89. sudo: false
  90. gather_facts: no
  91. tasks:
  92. - file: name={{ g_etcd_mktemp.stdout }} state=absent
  93. changed_when: False