diff --git a/docs/ansible.md b/docs/ansible.md index 13d297de..0987ca7f 100644 --- a/docs/ansible.md +++ b/docs/ansible.md @@ -8,9 +8,9 @@ If your local computer cannot run Ansible, you can also run Ansible on some serv ## Supported Ansible versions -Generally, Ansible 2.4 or later is required. +Ansible 2.5 or newer is required. -If you're on Ansible 2.5.x, then at least Ansible 2.5.2 is required. +If you're on Ansible 2.5.x, due to bugs in Ansible 2.5.0 and 2.5.1, at least Ansible 2.5.2 is required. ## Checking your Ansible version @@ -20,7 +20,7 @@ The playbook will try to detect it and tell you if you're on an unsupported vers To manually check which verison of Ansible you're on, run: `ansible --version`. -If you're on an old version of Ansible, you should upgrade to a newer version. +If you're on an old version of Ansible, you should [upgrade Ansible to a newer version](#upgrading-ansible) or [use Ansible via Docker](#using-ansible-via-docker). ## Upgrading Ansible diff --git a/roles/matrix-base/tasks/sanity_check.yml b/roles/matrix-base/tasks/sanity_check.yml index 0bff6a6b..b2d8c249 100644 --- a/roles/matrix-base/tasks/sanity_check.yml +++ b/roles/matrix-base/tasks/sanity_check.yml @@ -3,10 +3,10 @@ - set_fact: matrix_ansible_outdated_fail_msg: "You are running on Ansible {{ ansible_version.string }}, which is not supported. See our guide about Ansible: https://github.com/spantaleev/matrix-docker-ansible-deploy/blob/master/docs/ansible.md" -- name: Fail if running on Ansible < 2.4 +- name: Fail if running on Ansible < 2.5 fail: msg: "{{ matrix_ansible_outdated_fail_msg }}" - when: "ansible_version.major <= 2 and ansible_version.minor < 4" + when: "ansible_version.major <= 2 and ansible_version.minor < 5" # Ansible 2.5.0 and 2.5.1 are known to have a bug with `include_tasks` + `with_items`. # The bug has been fixed in Ansible 2.5.2. diff --git a/roles/matrix-common-after/tasks/start.yml b/roles/matrix-common-after/tasks/start.yml index 688b9244..f0015428 100644 --- a/roles/matrix-common-after/tasks/start.yml +++ b/roles/matrix-common-after/tasks/start.yml @@ -15,4 +15,27 @@ name: "{{ item }}" enabled: yes state: started - with_items: "{{ matrix_systemd_services_list }}" \ No newline at end of file + with_items: "{{ matrix_systemd_services_list }}" + +# If we check service state immediately, we may succeed, +# because it takes some time for the service to attempt to start and actually fail. +# +# Waiting too long (30s) may not work for a similar reason, +# as we may run into systemd's automatic restart logic retrying the service. +- name: Wait a bit, so that services can start (or fail) + wait_for: + timeout: 5 + delegate_to: 127.0.0.1 + become: false + +- name: Populate service facts + service_facts: + +- name: Fail if service isn't detected to be running + fail: + msg: >- + {{ item }} was not detected to be running. + It's possible that there's a configuration problem or another service on your server interferes with it (uses the same ports, etc.). + Try running `systemctl status {{ item }}` and `systemctl -fu {{ item }}` on the server to investigate. + with_items: "{{ matrix_systemd_services_list }}" + when: "ansible_facts.services[item + '.service']|default(none) is none or ansible_facts.services[item + '.service'].state != 'running'"