Files
kolla-ansible/ansible/roles/prechecks/tasks/host_os_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

36 lines
1.3 KiB
YAML

---
- name: Checking host OS distribution
fail:
msg: >-
Host OS distribution {{ ansible_facts.distribution }} is not supported.
Supported distributions are: {{ host_os_distributions.keys() | join(', ') }}
when: ansible_facts.distribution not in host_os_distributions
- name: Checking host OS release or version
fail:
msg: >-
{{ ansible_facts.distribution }} release {{ ansible_facts.distribution_release }}
version {{ ansible_facts.distribution_version }} is not supported.
Supported releases are:
{{ host_os_distributions[ansible_facts.distribution] | join(', ') }}
when:
- ansible_facts.distribution_release not in host_os_distributions[ansible_facts.distribution]
- ansible_facts.distribution_version not in host_os_distributions[ansible_facts.distribution]
- ansible_facts.distribution_major_version not in host_os_distributions[ansible_facts.distribution]
- name: Checking if CentOS is Stream
become: true
command: grep -q Stream /etc/os-release
register: stream_status
changed_when: false
check_mode: false
when:
- ansible_facts.distribution == 'CentOS'
- name: Fail if not running on CentOS Stream
fail:
msg: CentOS Linux is not supported, you need to run CentOS Stream.
when:
- ansible_facts.distribution == 'CentOS'
- stream_status.rc != 0