main.yml 1.5 KB

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