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

65 строки
2.3 KiB

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