main.yml 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. ---
  2. - fail:
  3. msg: Interface {{ etcd_interface }} not found
  4. when: "'ansible_' ~ etcd_interface not in hostvars[inventory_hostname]"
  5. - fail:
  6. msg: IPv4 address not found for {{ etcd_interface }}
  7. when: "'ipv4' not in hostvars[inventory_hostname]['ansible_' ~ etcd_interface] or 'address' not in hostvars[inventory_hostname]['ansible_' ~ etcd_interface].ipv4"
  8. - name: Install etcd
  9. action: "{{ ansible_pkg_mgr }} name=etcd state=present"
  10. when: not openshift.common.is_containerized | bool
  11. - name: Pull etcd container
  12. command: docker pull {{ openshift.etcd.etcd_image }}
  13. when: openshift.common.is_containerized | bool
  14. - name: Install etcd container service file
  15. template:
  16. dest: "/etc/systemd/system/etcd_container.service"
  17. src: etcd.docker.service
  18. register: install_etcd_result
  19. when: openshift.common.is_containerized | bool
  20. - name: Ensure etcd datadir exists
  21. when: openshift.common.is_containerized | bool
  22. file:
  23. path: "{{ etcd_data_dir }}"
  24. state: directory
  25. mode: 0700
  26. - name: Disable system etcd when containerized
  27. when: openshift.common.is_containerized | bool
  28. service:
  29. name: etcd
  30. state: stopped
  31. enabled: no
  32. - name: Mask system etcd when containerized
  33. when: openshift.common.is_containerized | bool
  34. command: systemctl mask etcd
  35. - name: Reload systemd units
  36. command: systemctl daemon-reload
  37. when: openshift.common.is_containerized | bool and ( install_etcd_result | changed )
  38. - name: Validate permissions on the config dir
  39. file:
  40. path: "{{ etcd_conf_dir }}"
  41. state: directory
  42. owner: "{{ 'etcd' if not openshift.common.is_containerized | bool else omit }}"
  43. group: "{{ 'etcd' if not openshift.common.is_containerized | bool else omit }}"
  44. mode: 0700
  45. - name: Validate permissions on certificate files
  46. file:
  47. path: "{{ item }}"
  48. mode: 0600
  49. owner: "{{ 'etcd' if not openshift.common.is_containerized | bool else omit }}"
  50. group: "{{ 'etcd' if not openshift.common.is_containerized | bool else omit }}"
  51. when: etcd_url_scheme == 'https'
  52. with_items:
  53. - "{{ etcd_ca_file }}"
  54. - "{{ etcd_cert_file }}"
  55. - "{{ etcd_key_file }}"
  56. - name: Validate permissions on peer certificate files
  57. file:
  58. path: "{{ item }}"
  59. mode: 0600
  60. owner: "{{ 'etcd' if not openshift.common.is_containerized | bool else omit }}"
  61. group: "{{ 'etcd' if not openshift.common.is_containerized | bool else omit }}"
  62. when: etcd_peer_url_scheme == 'https'
  63. with_items:
  64. - "{{ etcd_peer_ca_file }}"
  65. - "{{ etcd_peer_cert_file }}"
  66. - "{{ etcd_peer_key_file }}"
  67. - name: Write etcd global config file
  68. template:
  69. src: etcd.conf.j2
  70. dest: /etc/etcd/etcd.conf
  71. backup: true
  72. notify:
  73. - restart etcd
  74. - name: Enable etcd
  75. service:
  76. name: "{{ etcd_service }}"
  77. state: started
  78. enabled: yes
  79. register: start_result
  80. - set_fact:
  81. etcd_service_status_changed: "{{ start_result | changed }}"