config.yml 3.3 KB

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