Matrix Docker Ansible eploy
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
 
 

70 líneas
3.2 KiB

  1. ---
  2. - name: Ensure systemd is reloaded
  3. ansible.builtin.service:
  4. daemon_reload: true
  5. - name: Ensure Matrix services are stopped
  6. ansible.builtin.service:
  7. name: "{{ item.name }}"
  8. state: stopped
  9. with_items: "{{ matrix_systemd_services_list | sort (attribute='priority,name', reverse=true) }}"
  10. when: not ansible_check_mode
  11. - name: Ensure Matrix services are started
  12. ansible.builtin.service:
  13. name: "{{ item.name }}"
  14. state: started
  15. enabled: "{{ matrix_systemd_services_autostart_enabled }}"
  16. with_items: "{{ matrix_systemd_services_list | sort (attribute='priority,name') }}"
  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. ansible.builtin.wait_for:
  25. timeout: "{{ matrix_common_after_systemd_service_start_wait_for_timeout_seconds }}"
  26. delegate_to: 127.0.0.1
  27. become: false
  28. - when: "ansible_distribution != 'Archlinux'"
  29. block:
  30. - name: Populate service facts
  31. ansible.builtin.service_facts:
  32. - name: Fail if service isn't detected to be running
  33. ansible.builtin.fail:
  34. msg: >-
  35. {{ item }} was not detected to be running.
  36. It's possible that there's a configuration problem or another service on your server interferes with it (uses the same ports, etc.).
  37. Try running `systemctl status {{ item }}` and `journalctl -fu {{ item }}` on the server to investigate.
  38. If you're on a slow or overloaded server, it may be that services take a longer time to start and that this error is a false-positive.
  39. You can consider raising the value of the `matrix_common_after_systemd_service_start_wait_for_timeout_seconds` variable.
  40. See `roles/custom/matrix-common-after/defaults/main.yml` for more details about that.
  41. with_items: "{{ matrix_systemd_services_list | map(attribute='name') }}"
  42. when:
  43. - "item.endswith('.service') and (ansible_facts.services[item] | default(none) is none or ansible_facts.services[item].state != 'running')"
  44. - when: "ansible_distribution == 'Archlinux'"
  45. block:
  46. # Currently there is a bug in ansible that renders is incompatible with systemd.
  47. # service_facts is not collecting the data successfully.
  48. # Therefore iterating here manually
  49. - name: Fetch systemd information
  50. ansible.builtin.systemd:
  51. name: "{{ item.name }}"
  52. register: systemdstatus
  53. with_items: "{{ matrix_systemd_services_list }}"
  54. - name: Fail if service isn't detected to be running
  55. ansible.builtin.fail:
  56. msg: >-
  57. {{ item.item }} was not detected to be running.
  58. It's possible that there's a configuration problem or another service on your server interferes with it (uses the same ports, etc.).
  59. Try running `systemctl status {{ item.item }}` and `journalctl -fu {{ item.item }}` on the server to investigate.
  60. with_items: "{{ systemdstatus.results }}"
  61. when: "item.status['ActiveState'] != 'active'"