main.yml 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. package: 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. when: etcd_is_containerized | bool
  21. - name: Ensure etcd datadir exists when containerized
  22. file:
  23. path: "{{ etcd_data_dir }}"
  24. state: directory
  25. mode: 0700
  26. when: etcd_is_containerized | bool
  27. - name: Disable system etcd when containerized
  28. systemd:
  29. name: etcd
  30. state: stopped
  31. enabled: no
  32. masked: yes
  33. daemon_reload: yes
  34. when: etcd_is_containerized | bool
  35. register: task_result
  36. failed_when: "task_result|failed and 'could not' not in task_result.msg|lower"
  37. - name: Validate permissions on the config dir
  38. file:
  39. path: "{{ etcd_conf_dir }}"
  40. state: directory
  41. owner: "{{ 'etcd' if not etcd_is_containerized | bool else omit }}"
  42. group: "{{ 'etcd' if not etcd_is_containerized | bool else omit }}"
  43. mode: 0700
  44. - name: Write etcd global config file
  45. template:
  46. src: etcd.conf.j2
  47. dest: /etc/etcd/etcd.conf
  48. backup: true
  49. notify:
  50. - restart etcd
  51. - name: Enable etcd
  52. systemd:
  53. name: "{{ etcd_service }}"
  54. state: started
  55. enabled: yes
  56. register: start_result
  57. - include: etcdctl.yml
  58. when: openshift_etcd_etcdctl_profile | default(true) | bool
  59. - name: Set fact etcd_service_status_changed
  60. set_fact:
  61. etcd_service_status_changed: "{{ start_result | changed }}"