From 7372911a1994db8d3138b8de61af63040cb6176d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rados=C5=82aw=20Piliszek?= <radoslaw.piliszek@gmail.com>
Date: Wed, 24 Nov 2021 15:47:27 +0000
Subject: [PATCH] Add Ansible 5 aka core 2.12 support

Also bumps the minimum to 4.

Change-Id: Ia373f9cc3bb69eba0288bbb3e497e8cadb7cc4d3
---
 ansible/roles/prechecks/vars/main.yml              | 4 ++--
 doc/source/user/quickstart.rst                     | 8 ++++----
 doc/source/user/virtual-environments.rst           | 2 +-
 releasenotes/notes/ansible-5-56bc1764e733d5af.yaml | 5 +++++
 test-requirements.txt                              | 2 +-
 tests/run.yml                                      | 4 ++--
 tools/kolla-ansible                                | 4 ++--
 7 files changed, 17 insertions(+), 12 deletions(-)
 create mode 100644 releasenotes/notes/ansible-5-56bc1764e733d5af.yaml

diff --git a/ansible/roles/prechecks/vars/main.yml b/ansible/roles/prechecks/vars/main.yml
index ea32bd2910..2a131f3fc2 100644
--- a/ansible/roles/prechecks/vars/main.yml
+++ b/ansible/roles/prechecks/vars/main.yml
@@ -1,8 +1,8 @@
 ---
 docker_version_min: '18.09'
 docker_py_version_min: '3.4.1'
-ansible_version_min: '2.10'
-ansible_version_max: '2.11'
+ansible_version_min: '2.11'
+ansible_version_max: '2.12'
 
 # Top level keys should match ansible_facts.distribution.
 # These map to lists of supported releases (ansible_facts.distribution_release) or
diff --git a/doc/source/user/quickstart.rst b/doc/source/user/quickstart.rst
index 111822e3fc..9b125041b4 100644
--- a/doc/source/user/quickstart.rst
+++ b/doc/source/user/quickstart.rst
@@ -89,11 +89,11 @@ If not installing Kolla Ansible in a virtual environment, skip this section.
       pip install -U pip
 
 #. Install `Ansible <http://www.ansible.com>`__. Kolla Ansible requires at least
-   Ansible ``2.10`` and supports up to ``4``.
+   Ansible ``4`` and supports up to ``5``.
 
    .. code-block:: console
 
-      pip install 'ansible<5.0'
+      pip install 'ansible==5.*'
 
 Install dependencies not using a virtual environment
 ----------------------------------------------------
@@ -121,7 +121,7 @@ If installing Kolla Ansible in a virtual environment, skip this section.
       sudo pip3 install -U pip
 
 #. Install `Ansible <http://www.ansible.com>`__. Kolla Ansible requires at least
-   Ansible ``2.10`` and supports up to ``4``.
+   Ansible ``4`` and supports up to ``5``.
 
    For CentOS or RHEL, run:
 
@@ -138,7 +138,7 @@ If installing Kolla Ansible in a virtual environment, skip this section.
    .. note::
 
       If the installed Ansible version does not meet the requirements, one can
-      use pip: ``sudo pip install -U 'ansible<3.0'``.
+      use pip: ``sudo pip install -U 'ansible==5.*'``.
       Beware system package upgrades might interfere with that so it
       is recommended to uninstall the system package first. One might be better
       off with the virtual environment method to avoid this pitfall.
diff --git a/doc/source/user/virtual-environments.rst b/doc/source/user/virtual-environments.rst
index 1cea330831..fee1644684 100644
--- a/doc/source/user/virtual-environments.rst
+++ b/doc/source/user/virtual-environments.rst
@@ -22,7 +22,7 @@ python virtual environment on the Ansible control host. For example:
    source /path/to/venv/bin/activate
    pip install -U pip
    pip install kolla-ansible
-   pip install 'ansible<2.10'
+   pip install 'ansible==5.*'
    deactivate
 
 To use the virtual environment, it should first be activated:
diff --git a/releasenotes/notes/ansible-5-56bc1764e733d5af.yaml b/releasenotes/notes/ansible-5-56bc1764e733d5af.yaml
new file mode 100644
index 0000000000..d2ed3120bc
--- /dev/null
+++ b/releasenotes/notes/ansible-5-56bc1764e733d5af.yaml
@@ -0,0 +1,5 @@
+---
+upgrade:
+  - |
+    Minimum supported Ansible version is now ``4`` (ansible-core 2.11)
+    and maximum supported is ``5`` (ansible-core 2.12).
diff --git a/test-requirements.txt b/test-requirements.txt
index ef84c6b8a8..305532bcb3 100644
--- a/test-requirements.txt
+++ b/test-requirements.txt
@@ -13,4 +13,4 @@ coverage!=4.4,>=4.0 # Apache-2.0
 docker>=2.4.2 # Apache-2.0
 oslotest>=3.2.0 # Apache-2.0
 stestr>=2.0.0 # Apache-2.0
-ansible>=2.10.0,<5.0 # GPLv3
+ansible>=4,<6 # GPLv3
diff --git a/tests/run.yml b/tests/run.yml
index 0435059e66..d372d7e597 100644
--- a/tests/run.yml
+++ b/tests/run.yml
@@ -202,8 +202,8 @@
 
     - name: install kolla-ansible and dependencies
       vars:
-        ansible_version_min: "==2.10.*"
-        ansible_version_max: "==4.*"
+        ansible_version_min: "==4.*"
+        ansible_version_max: "==5.*"
         # Test latest ansible version on Ubuntu, minimum supported on others.
         ansible_version_constraint: >-
           {{ ansible_version_min if is_upgrade or base_distro != 'ubuntu' else ansible_version_max }}
diff --git a/tools/kolla-ansible b/tools/kolla-ansible
index fb885e334b..3b40f28c01 100755
--- a/tools/kolla-ansible
+++ b/tools/kolla-ansible
@@ -68,8 +68,8 @@ function check_environment_coherence {
         exit 1
     fi
 
-    local ANSIBLE_VERSION_MIN=2.10
-    local ANSIBLE_VERSION_MAX=2.11
+    local ANSIBLE_VERSION_MIN=2.11
+    local ANSIBLE_VERSION_MAX=2.12
 
     if [[ $(printf "%s\n" "$ANSIBLE_VERSION_MIN" "$ANSIBLE_VERSION_MAX" "$ansible_version" | sort -V | head -n1) != "$ANSIBLE_VERSION_MIN" ]] ||
        [[ $(printf "%s\n" "$ANSIBLE_VERSION_MIN" "$ANSIBLE_VERSION_MAX" "$ansible_version" | sort -V | tail -n1) != "$ANSIBLE_VERSION_MAX" ]]; then
-- 
GitLab