Matrix Docker Ansible eploy
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

71 строка
2.7 KiB

  1. ---
  2. - name: Determine whether we should make services autostart
  3. set_fact:
  4. matrix_services_autostart_enabled_bool: "{{ true if matrix_services_autostart_enabled|default('') == '' else matrix_services_autostart_enabled|bool }}"
  5. - name: Ensure systemd is reloaded
  6. service:
  7. daemon_reload: yes
  8. - name: Ensure Matrix services are stopped
  9. service:
  10. name: "{{ item }}"
  11. state: stopped
  12. with_items: "{{ matrix_systemd_services_list }}"
  13. when: not ansible_check_mode
  14. - name: Ensure Matrix services are started
  15. service:
  16. name: "{{ item }}"
  17. enabled: "{{ matrix_services_autostart_enabled_bool }}"
  18. state: started
  19. with_items: "{{ matrix_systemd_services_list }}"
  20. when: not ansible_check_mode
  21. # If we check service state immediately, we may succeed,
  22. # because it takes some time for the service to attempt to start and actually fail.
  23. #
  24. # Waiting too long (30s) may not work for a similar reason,
  25. # as we may run into systemd's automatic restart logic retrying the service.
  26. - name: Wait a bit, so that services can start (or fail)
  27. wait_for:
  28. timeout: 5
  29. delegate_to: 127.0.0.1
  30. become: false
  31. - block:
  32. - name: Populate service facts
  33. service_facts:
  34. - name: Fail if service isn't detected to be running
  35. fail:
  36. msg: >-
  37. {{ item }} was not detected to be running.
  38. It's possible that there's a configuration problem or another service on your server interferes with it (uses the same ports, etc.).
  39. Try running `systemctl status {{ item }}` and `journalctl -fu {{ item }}` on the server to investigate.
  40. with_items: "{{ matrix_systemd_services_list }}"
  41. when:
  42. - "item.endswith('.service') and (ansible_facts.services[item]|default(none) is none or ansible_facts.services[item].state != 'running')"
  43. when: " ansible_distribution != 'Archlinux'"
  44. - block:
  45. # Currently there is a bug in ansible that renders is incompatible with systemd.
  46. # service_facts is not collecting the data successfully.
  47. # Therefore iterating here manually
  48. - name: Fetch systemd information
  49. systemd:
  50. name: "{{ item }}"
  51. register: systemdstatus
  52. with_items: "{{ matrix_systemd_services_list }}"
  53. - name: Fail if service isn't detected to be running
  54. fail:
  55. msg: >-
  56. {{ item.item }} was not detected to be running.
  57. It's possible that there's a configuration problem or another service on your server interferes with it (uses the same ports, etc.).
  58. Try running `systemctl status {{ item.item }}` and `journalctl -fu {{ item.item }}` on the server to investigate.
  59. with_items: "{{ systemdstatus.results }}"
  60. when: "item.status['ActiveState'] != 'active'"
  61. when: "ansible_distribution == 'Archlinux'"