main.yml 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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-2.* state=present"
  10. - name: Validate permissions on the config dir
  11. file:
  12. path: "{{ etcd_conf_dir }}"
  13. state: directory
  14. owner: etcd
  15. group: etcd
  16. mode: 0700
  17. - name: Validate permissions on certificate files
  18. file:
  19. path: "{{ item }}"
  20. mode: 0600
  21. group: etcd
  22. owner: etcd
  23. when: etcd_url_scheme == 'https'
  24. with_items:
  25. - "{{ etcd_ca_file }}"
  26. - "{{ etcd_cert_file }}"
  27. - "{{ etcd_key_file }}"
  28. - name: Validate permissions on peer certificate files
  29. file:
  30. path: "{{ item }}"
  31. mode: 0600
  32. group: etcd
  33. owner: etcd
  34. when: etcd_peer_url_scheme == 'https'
  35. with_items:
  36. - "{{ etcd_peer_ca_file }}"
  37. - "{{ etcd_peer_cert_file }}"
  38. - "{{ etcd_peer_key_file }}"
  39. - name: Write etcd global config file
  40. template:
  41. src: etcd.conf.j2
  42. dest: /etc/etcd/etcd.conf
  43. backup: true
  44. notify:
  45. - restart etcd
  46. - name: Enable etcd
  47. service:
  48. name: etcd
  49. state: started
  50. enabled: yes
  51. register: start_result
  52. - set_fact:
  53. etcd_service_status_changed = start_result | changed