Check supported host OS distributions in prechecks

This should help to ensure that users are running tested and supported
host OS distributions.

Change-Id: I6ee76463d284ad4f3646af1c7ec2b7e50e2f3b15
Partially-Implements: blueprint improve-prechecks
This commit is contained in:
Mark Goddard 2019-12-17 15:37:04 +00:00
parent 021de4c0ba
commit d20c65ed48
5 changed files with 45 additions and 0 deletions

View File

@ -0,0 +1,3 @@
---
# Whether to enable checks for host OS distribution and release.
prechecks_enable_host_os_checks: true

View File

@ -0,0 +1,18 @@
---
- name: Checking host OS distribution
fail:
msg: >-
Host OS distribution {{ ansible_distribution }} is not supported.
Supported distributions are: {{ host_os_distributions.keys() | join(', ') }}
when: ansible_distribution not in host_os_distributions
- name: Checking host OS release or version
fail:
msg: >-
{{ ansible_distribution }} release {{ ansible_distribution_release }} is
not supported. Supported releases are:
{{ host_os_distributions[ansible_distribution] | join(', ') }}
when:
- ansible_distribution_release not in host_os_distributions[ansible_distribution]
- ansible_distribution_version not in host_os_distributions[ansible_distribution]
- ansible_distribution_major_version not in host_os_distributions[ansible_distribution]

View File

@ -1,4 +1,7 @@
---
- include_tasks: host_os_checks.yml
when: prechecks_enable_host_os_checks | bool
- include_tasks: port_checks.yml
when:
- inventory_hostname not in groups['deployment']|default([])

View File

@ -3,3 +3,17 @@ docker_version_min: '1.10.0'
docker_py_version_min: '2.0.0'
ansible_version_min: '2.8'
ansible_version_max: '2.9'
# Top level keys should match ansible_distribution.
# These map to lists of supported releases (ansible_distribution_release) or
# versions (ansible_distribution_version or ansible_distribution_major_version)
# for that distribution.
host_os_distributions:
CentOS:
- "8"
Debian:
- "buster"
RHEL:
- "8"
Ubuntu:
- "bionic"

View File

@ -0,0 +1,7 @@
---
features:
- |
Adds a new precheck for supported host OS distributions. Currently
supported distributions are CentOS/RHEL 8, Debian Buster and Ubuntu Bionic.
This check can be disabled by setting ``prechecks_enable_host_os_checks``
to ``false``.