main.yml 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. ---
  2. - name: Set hostname and ip facts
  3. set_fact:
  4. # Store etcd_hostname and etcd_ip such that they will be available
  5. # in hostvars. Defaults for these variables are set in etcd_common.
  6. etcd_hostname: "{{ etcd_hostname }}"
  7. etcd_ip: "{{ etcd_ip }}"
  8. - name: Install etcd
  9. action: "{{ ansible_pkg_mgr }} name=etcd state=present"
  10. when: not etcd_is_containerized | bool
  11. - name: Pull etcd container
  12. command: docker pull {{ openshift.etcd.etcd_image }}
  13. register: pull_result
  14. changed_when: "'Downloaded newer image' in pull_result.stdout"
  15. when: etcd_is_containerized | bool
  16. - name: Install etcd container service file
  17. template:
  18. dest: "/etc/systemd/system/etcd_container.service"
  19. src: etcd.docker.service
  20. register: install_etcd_result
  21. when: etcd_is_containerized | bool
  22. - name: Ensure etcd datadir exists
  23. when: etcd_is_containerized | bool
  24. file:
  25. path: "{{ etcd_data_dir }}"
  26. state: directory
  27. mode: 0700
  28. - name: Check for etcd service presence
  29. command: systemctl show etcd.service
  30. register: etcd_show
  31. changed_when: false
  32. failed_when: false
  33. - name: Disable system etcd when containerized
  34. when: etcd_is_containerized | bool and etcd_show.rc == 0 and 'LoadState=not-found' not in etcd_show.stdout
  35. service:
  36. name: etcd
  37. state: stopped
  38. enabled: no
  39. - name: Mask system etcd when containerized
  40. when: etcd_is_containerized | bool and etcd_show.rc == 0 and 'LoadState=not-found' not in etcd_show.stdout
  41. command: systemctl mask etcd
  42. - name: Reload systemd units
  43. command: systemctl daemon-reload
  44. when: etcd_is_containerized | bool and ( install_etcd_result | changed )
  45. - name: Validate permissions on the config dir
  46. file:
  47. path: "{{ etcd_conf_dir }}"
  48. state: directory
  49. owner: "{{ 'etcd' if not etcd_is_containerized | bool else omit }}"
  50. group: "{{ 'etcd' if not etcd_is_containerized | bool else omit }}"
  51. mode: 0700
  52. - name: Write etcd global config file
  53. template:
  54. src: etcd.conf.j2
  55. dest: /etc/etcd/etcd.conf
  56. backup: true
  57. notify:
  58. - restart etcd
  59. - name: Enable etcd
  60. service:
  61. name: "{{ etcd_service }}"
  62. state: started
  63. enabled: yes
  64. register: start_result
  65. - set_fact:
  66. etcd_service_status_changed: "{{ start_result | changed }}"