Matrix Docker Ansible eploy
Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 

67 righe
2.4 KiB

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