diff --git a/ansible/roles/prechecks/tasks/package_checks.yml b/ansible/roles/prechecks/tasks/package_checks.yml index 7919b540e6..f8f65136ee 100644 --- a/ansible/roles/prechecks/tasks/package_checks.yml +++ b/ansible/roles/prechecks/tasks/package_checks.yml @@ -6,8 +6,13 @@ when: inventory_hostname in groups['baremetal'] 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: "Current Ansible version {{ ansible_version.full }} is less than {{ ansible_version_min }}" + 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.full is version(ansible_version_min, '<') + when: ansible_version_host is version(ansible_version_min, '<') or ansible_version_host is version(ansible_version_max, '>') diff --git a/ansible/roles/prechecks/vars/main.yml b/ansible/roles/prechecks/vars/main.yml index 8d673d5361..4f1616589e 100644 --- a/ansible/roles/prechecks/vars/main.yml +++ b/ansible/roles/prechecks/vars/main.yml @@ -1,4 +1,5 @@ --- docker_version_min: '1.10.0' docker_py_version_min: '2.0.0' -ansible_version_min: '2.6.0' +ansible_version_min: '2.8' +ansible_version_max: '2.9' diff --git a/doc/source/user/quickstart.rst b/doc/source/user/quickstart.rst index 051e6d1e88..d4bd1cd9a9 100644 --- a/doc/source/user/quickstart.rst +++ b/doc/source/user/quickstart.rst @@ -89,8 +89,8 @@ If not installing Kolla Ansible in a virtual environment, skip this section. pip install -U pip -#. Install `Ansible `__. Currently, Kolla Ansible - requires Ansible 2.6+. +#. Install `Ansible `__. Kolla Ansible requires at least + Ansible ``2.8`` and supports up to ``2.9``. .. code-block:: console @@ -121,8 +121,8 @@ If installing Kolla Ansible in a virtual environment, skip this section. sudo pip install -U pip -#. Install `Ansible `__. Currently, Kolla Ansible - requires Ansible 2.6+. +#. Install `Ansible `__. Kolla Ansible requires at least + Ansible ``2.8`` and supports up to ``2.9``. For CentOS or RHEL, run: diff --git a/releasenotes/notes/ansible-max-version-support-d74258eec27d3549.yaml b/releasenotes/notes/ansible-max-version-support-d74258eec27d3549.yaml new file mode 100644 index 0000000000..152f483f5a --- /dev/null +++ b/releasenotes/notes/ansible-max-version-support-d74258eec27d3549.yaml @@ -0,0 +1,8 @@ +--- +upgrade: + - | + Adds maximum supported version check for Ansible. Kolla Ansible now + requires at least Ansible ``2.8`` and supports up to ``2.9``. See + `blueprint + `__ + for details. diff --git a/tests/run.yml b/tests/run.yml index c1f5a13e6d..5a8322264e 100644 --- a/tests/run.yml +++ b/tests/run.yml @@ -148,7 +148,7 @@ - name: install kolla-ansible and dependencies vars: # Test latest ansible version on Ubuntu, minimum supported on others. - ansible_version_constraint: "{{ '>=2.6' if base_distro == 'ubuntu' else '<2.7' }}" + ansible_version_constraint: "{{ '==2.9.*' if base_distro == 'ubuntu' else '==2.8.*' }}" pip: name: - "{{ kolla_ansible_src_dir }}" @@ -373,7 +373,7 @@ - name: install ansible and ARA for python 3 vars: # Test latest ansible version on Ubuntu, minimum supported on others. - ansible_version_constraint: "{{ '>=2.6' if base_distro == 'ubuntu' else '<2.7' }}" + ansible_version_constraint: "{{ '==2.9.*' if base_distro == 'ubuntu' else '==2.8.*' }}" pip: name: - "ansible{{ ansible_version_constraint }}" diff --git a/tools/kolla-ansible b/tools/kolla-ansible index 2bc0ada170..733c69c89e 100755 --- a/tools/kolla-ansible +++ b/tools/kolla-ansible @@ -2,6 +2,18 @@ # # This script can be used to interact with kolla via ansible. +function check_ansible_compatibility { + ANSIBLE_VERSION_MIN=2.8 + ANSIBLE_VERSION_MAX=2.9 + ANSIBLE_VERSION_HOST=$(ansible --version | head -n1 | egrep -o '[0-9]\.[0-9]+') + + if [[ $(printf "%s\n" "$ANSIBLE_VERSION_MIN" "$ANSIBLE_VERSION_MAX" "$ANSIBLE_VERSION_HOST" | sort -V | head -n1) != "$ANSIBLE_VERSION_MIN" ]] || + [[ $(printf "%s\n" "$ANSIBLE_VERSION_MIN" "$ANSIBLE_VERSION_MAX" "$ANSIBLE_VERSION_HOST" | sort -V | tail -1) != "$ANSIBLE_VERSION_MAX" ]]; then + echo "ERROR: Ansible version should be between $ANSIBLE_VERSION_MIN and $ANSIBLE_VERSION_MAX. Current version is $ANSIBLE_VERSION_HOST which is not supported." + exit 1 + fi +} + function find_base_dir { # $1: Python interpreter local python @@ -117,6 +129,8 @@ genconfig EOF } +check_ansible_compatibility + SHORT_OPTS="hi:p:t:k:e:v" LONG_OPTS="help,inventory:,playbook:,skip-tags:,tags:,key:,extra:,verbose,configdir:,passwords:,limit:,forks:,vault-id:,ask-vault-pass,vault-password-file:,yes-i-really-really-mean-it,include-images,include-dev:,full,incremental"