Files
kolla-ansible/ansible/roles/prechecks/tasks/package_checks.yml
Mark Goddard 46aeb9843f Fix prechecks in check mode
When running in check mode, some prechecks previously failed because
they use the command module which is silently not run in check mode.
Other prechecks were not running correctly in check mode due to e.g.
looking for a string in empty command output or not querying which
containers are running.

This change fixes these issues.

Closes-Bug: #2002657
Change-Id: I5219cb42c48d5444943a2d48106dc338aa08fa7c
2023-01-12 14:27:36 +00:00

24 lines
1.0 KiB
YAML

---
- name: Checking docker SDK version
command: "{{ ansible_facts.python.executable }} -c \"import docker; print(docker.__version__)\""
register: result
changed_when: false
check_mode: false
when:
- inventory_hostname in groups['baremetal']
- kolla_container_engine == 'docker'
failed_when: result is failed or result.stdout is version(docker_py_version_min, '<')
# NOTE(osmanlicilegi): ansible_version.full includes patch number that's useless
# to check. as ansible_version does not provide major.minor in dict, we need to
# set it as variable.
- name: Checking Ansible version
vars:
ansible_version_host: "{{ ansible_version.major }}.{{ ansible_version.minor }}"
fail:
msg: >-
Ansible version should be between {{ ansible_version_min }} and {{ ansible_version_max }}.
Current version is {{ ansible_version.full }} which is not supported.
run_once: true
when: ansible_version_host is version(ansible_version_min, '<') or ansible_version_host is version(ansible_version_max, '>')