main.yml 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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: Check for etcd service presence
  33. command: systemctl show etcd.service
  34. register: etcd_show
  35. - name: Mask system etcd when containerized
  36. when: openshift.common.is_containerized | bool and 'LoadState=not-found' not in etcd_show.stdout
  37. command: systemctl mask etcd
  38. - name: Reload systemd units
  39. command: systemctl daemon-reload
  40. when: openshift.common.is_containerized | bool and ( install_etcd_result | changed )
  41. - name: Validate permissions on the config dir
  42. file:
  43. path: "{{ etcd_conf_dir }}"
  44. state: directory
  45. owner: "{{ 'etcd' if not openshift.common.is_containerized | bool else omit }}"
  46. group: "{{ 'etcd' if not openshift.common.is_containerized | bool else omit }}"
  47. mode: 0700
  48. - name: Validate permissions on certificate files
  49. file:
  50. path: "{{ item }}"
  51. mode: 0600
  52. owner: "{{ 'etcd' if not openshift.common.is_containerized | bool else omit }}"
  53. group: "{{ 'etcd' if not openshift.common.is_containerized | bool else omit }}"
  54. when: etcd_url_scheme == 'https'
  55. with_items:
  56. - "{{ etcd_ca_file }}"
  57. - "{{ etcd_cert_file }}"
  58. - "{{ etcd_key_file }}"
  59. - name: Validate permissions on peer certificate files
  60. file:
  61. path: "{{ item }}"
  62. mode: 0600
  63. owner: "{{ 'etcd' if not openshift.common.is_containerized | bool else omit }}"
  64. group: "{{ 'etcd' if not openshift.common.is_containerized | bool else omit }}"
  65. when: etcd_peer_url_scheme == 'https'
  66. with_items:
  67. - "{{ etcd_peer_ca_file }}"
  68. - "{{ etcd_peer_cert_file }}"
  69. - "{{ etcd_peer_key_file }}"
  70. - name: Write etcd global config file
  71. template:
  72. src: etcd.conf.j2
  73. dest: /etc/etcd/etcd.conf
  74. backup: true
  75. notify:
  76. - restart etcd
  77. - name: Enable etcd
  78. service:
  79. name: "{{ etcd_service }}"
  80. state: started
  81. enabled: yes
  82. register: start_result
  83. - set_fact:
  84. etcd_service_status_changed: "{{ start_result | changed }}"