main.yml 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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:
  16. - etcd_is_containerized | bool
  17. - not openshift.common.is_etcd_system_container | bool
  18. - name: Install etcd container service file
  19. template:
  20. dest: "/etc/systemd/system/etcd_container.service"
  21. src: etcd.docker.service
  22. when:
  23. - etcd_is_containerized | bool
  24. - not openshift.common.is_etcd_system_container | bool
  25. # Start secondary etcd instance for third party integrations
  26. # TODO: Determine an alternative to using thirdparty variable
  27. - name: Create configuration directory
  28. file:
  29. path: "{{ etcd_conf_dir }}"
  30. state: directory
  31. mode: 0700
  32. when: etcd_is_thirdparty | bool
  33. # TODO: retest with symlink to confirm it does or does not function
  34. - name: Copy service file for etcd instance
  35. copy:
  36. src: /usr/lib/systemd/system/etcd.service
  37. dest: "/etc/systemd/system/{{ etcd_service }}.service"
  38. remote_src: True
  39. when: etcd_is_thirdparty | bool
  40. - name: Create third party etcd service.d directory exists
  41. file:
  42. path: "{{ etcd_systemd_dir }}"
  43. state: directory
  44. when: etcd_is_thirdparty | bool
  45. - name: Configure third part etcd service unit file
  46. template:
  47. dest: "{{ etcd_systemd_dir }}/custom.conf"
  48. src: custom.conf.j2
  49. when: etcd_is_thirdparty
  50. # TODO: this task may not be needed with Validate permissions
  51. - name: Ensure etcd datadir exists
  52. file:
  53. path: "{{ etcd_data_dir }}"
  54. state: directory
  55. mode: 0700
  56. when: etcd_is_containerized | bool
  57. - name: Ensure etcd datadir ownership for thirdparty datadir
  58. file:
  59. path: "{{ etcd_data_dir }}"
  60. state: directory
  61. mode: 0700
  62. owner: etcd
  63. group: etcd
  64. recurse: True
  65. when: etcd_is_thirdparty | bool
  66. # TODO: Determine if the below reload would work here, for now just reload
  67. - name:
  68. command: systemctl daemon-reload
  69. when: etcd_is_thirdparty | bool
  70. - name: Disable system etcd when containerized
  71. systemd:
  72. name: etcd
  73. state: stopped
  74. enabled: no
  75. masked: yes
  76. daemon_reload: yes
  77. when:
  78. - etcd_is_containerized | bool
  79. - not openshift.common.is_etcd_system_container | bool
  80. register: task_result
  81. failed_when: "task_result|failed and 'could not' not in task_result.msg|lower"
  82. - name: Install etcd container service file
  83. template:
  84. dest: "/etc/systemd/system/etcd_container.service"
  85. src: etcd.docker.service
  86. when: etcd_is_containerized | bool and not openshift.common.is_etcd_system_container | bool
  87. - name: Install Etcd system container
  88. include: system_container.yml
  89. when: etcd_is_containerized | bool and openshift.common.is_etcd_system_container | bool
  90. - name: Validate permissions on the config dir
  91. file:
  92. path: "{{ etcd_conf_dir }}"
  93. state: directory
  94. owner: "{{ 'etcd' if not etcd_is_containerized | bool else omit }}"
  95. group: "{{ 'etcd' if not etcd_is_containerized | bool else omit }}"
  96. mode: 0700
  97. - name: Write etcd global config file
  98. template:
  99. src: etcd.conf.j2
  100. dest: "{{ etcd_conf_file }}"
  101. backup: true
  102. notify:
  103. - restart etcd
  104. - name: Enable etcd
  105. systemd:
  106. name: "{{ etcd_service }}"
  107. state: started
  108. enabled: yes
  109. register: start_result
  110. - include: etcdctl.yml
  111. when: openshift_etcd_etcdctl_profile | default(true) | bool
  112. - name: Set fact etcd_service_status_changed
  113. set_fact:
  114. etcd_service_status_changed: "{{ start_result | changed }}"