Fixes #129 (Github Issue).
Unfortunately, we rely on `service_facts`, which is only available
in Ansible >= 2.5.
There's little reason to stick to an old version such as Ansible 2.4:
- some time has passed since we've raised version requirements - it's
time to move into the future (a little bit)
- we've recently (in 82b4640072) improved the way one can run
Ansible in a Docker container
From now on, Ansible >= 2.5 is required.
pull/132/head
| @@ -8,9 +8,9 @@ If your local computer cannot run Ansible, you can also run Ansible on some serv | |||||
| ## Supported Ansible versions | ## 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 | ## 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`. | 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 | ## Upgrading Ansible | ||||
| @@ -3,10 +3,10 @@ | |||||
| - set_fact: | - 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" | 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: | fail: | ||||
| msg: "{{ matrix_ansible_outdated_fail_msg }}" | 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`. | # 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. | # The bug has been fixed in Ansible 2.5.2. | ||||
| @@ -15,4 +15,27 @@ | |||||
| name: "{{ item }}" | name: "{{ item }}" | ||||
| enabled: yes | enabled: yes | ||||
| state: started | state: started | ||||
| with_items: "{{ matrix_systemd_services_list }}" | |||||
| 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'" | |||||