From b04486df0726e049012deec27be490c79403b8c6 Mon Sep 17 00:00:00 2001
From: Michal Nasiadka <mnasiadka@gmail.com>
Date: Fri, 2 Feb 2024 11:05:23 +0100
Subject: [PATCH] Bump ansible-core versions to 2.15 and 2.16

Change-Id: Iab40eb92c7e4a9092471bef9d4477a4fa34f1c85
---
 ansible/roles/prechecks/vars/main.yml         |  4 ++--
 doc/source/conf.py                            |  9 ++++++++
 doc/source/user/quickstart-development.rst    |  7 ++++---
 doc/source/user/quickstart.rst                |  7 ++++---
 lint-requirements.txt                         |  4 ++--
 .../ansible-core-2-16-257dc4502ede5b88.yaml   |  5 +++++
 tests/run.yml                                 | 20 ------------------
 tools/kolla-ansible                           |  4 ++--
 zuul.d/base.yaml                              | 21 ++++++++++++-------
 9 files changed, 41 insertions(+), 40 deletions(-)
 create mode 100644 releasenotes/notes/ansible-core-2-16-257dc4502ede5b88.yaml

diff --git a/ansible/roles/prechecks/vars/main.yml b/ansible/roles/prechecks/vars/main.yml
index 61ec9f9205..cc1d1145bd 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.14'
-ansible_version_max: '2.15'
+ansible_version_min: '2.15'
+ansible_version_max: '2.16'
 
 # 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/conf.py b/doc/source/conf.py
index 8458c96278..dc5627d89b 100644
--- a/doc/source/conf.py
+++ b/doc/source/conf.py
@@ -130,7 +130,16 @@ else:
     TESTED_RUNTIMES_GOVERNANCE_URL =\
         'https://governance.openstack.org/tc/reference/runtimes/{}.html'.format(KOLLA_OPENSTACK_RELEASE)
 
+ANSIBLE_CORE_VERSION_MIN = '2.15'
+ANSIBLE_CORE_VERSION_MAX = '2.16'
+ANSIBLE_VERSION_MIN = '8'
+ANSIBLE_VERSION_MAX = '9'
+
 GLOBAL_VARIABLE_MAP = {
+    '|ANSIBLE_CORE_VERSION_MIN|': ANSIBLE_CORE_VERSION_MIN,
+    '|ANSIBLE_CORE_VERSION_MAX|': ANSIBLE_CORE_VERSION_MAX,
+    '|ANSIBLE_VERSION_MIN|': ANSIBLE_VERSION_MIN,
+    '|ANSIBLE_VERSION_MAX|': ANSIBLE_VERSION_MAX,
     '|KOLLA_OPENSTACK_RELEASE|': KOLLA_OPENSTACK_RELEASE,
     '|KOLLA_BRANCH_NAME|': KOLLA_BRANCH_NAME,
     '|KOLLA_BRANCH_NAME_DASHED|': KOLLA_BRANCH_NAME.replace('/', '-'),
diff --git a/doc/source/user/quickstart-development.rst b/doc/source/user/quickstart-development.rst
index a9c6a32f71..9bb396b2fa 100644
--- a/doc/source/user/quickstart-development.rst
+++ b/doc/source/user/quickstart-development.rst
@@ -90,12 +90,13 @@ Install dependencies for the virtual environment
       pip install -U pip
 
 #. Install `Ansible <http://www.ansible.com>`__. Kolla Ansible requires at least
-   Ansible ``6`` (or ansible-core ``2.14``) and supports up to ``7`` (or
-   ansible-core ``2.15``).
+   Ansible ``|ANSIBLE_VERSION_MIN|`` (or ansible-core
+   ``|ANSIBLE_CORE_VERSION_MIN|``) and supports up to ``|ANSIBLE_VERSION_MAX|``
+   (or ansible-core ``|ANSIBLE_CORE_VERSION_MAX|``).
 
    .. code-block:: console
 
-      pip install 'ansible-core>=2.14,<2.16'
+      pip install 'ansible-core>=|ANSIBLE_CORE_VERSION_MIN|,<|ANSIBLE_CORE_VERSION_MAX|.99'
 
 Install Kolla-ansible
 ~~~~~~~~~~~~~~~~~~~~~
diff --git a/doc/source/user/quickstart.rst b/doc/source/user/quickstart.rst
index 69dc971089..4fab565494 100644
--- a/doc/source/user/quickstart.rst
+++ b/doc/source/user/quickstart.rst
@@ -90,12 +90,13 @@ Install dependencies for the virtual environment
       pip install -U pip
 
 #. Install `Ansible <http://www.ansible.com>`__. Kolla Ansible requires at least
-   Ansible ``6`` (or ansible-core ``2.14``) and supports up to ``7`` (or
-   ansible-core ``2.15``).
+   Ansible ``|ANSIBLE_VERSION_MIN|`` (or ansible-core
+   ``|ANSIBLE_CORE_VERSION_MIN|``) and supports up to ``|ANSIBLE_VERSION_MAX|``
+   (or ansible-core ``|ANSIBLE_CORE_VERSION_MAX|``).
 
    .. code-block:: console
 
-      pip install 'ansible-core>=2.14,<2.16'
+      pip install 'ansible-core>=|ANSIBLE_CORE_VERSION_MIN|,<|ANSIBLE_CORE_VERSION_MAX|.99'
 
 
 Install Kolla-ansible
diff --git a/lint-requirements.txt b/lint-requirements.txt
index af8d8a49b5..9f9a402593 100644
--- a/lint-requirements.txt
+++ b/lint-requirements.txt
@@ -1,5 +1,5 @@
-ansible>=6,<8 # GPLv3
-ansible-lint>=6.0.0,<7.0.0 # MIT
+ansible>=8,<10 # GPLv3
+ansible-lint>=6.22.0,<7.0.0 # MIT
 bandit>=1.1.0 # Apache-2.0
 bashate>=0.5.1 # Apache-2.0
 doc8>=0.6.0 # Apache-2.0
diff --git a/releasenotes/notes/ansible-core-2-16-257dc4502ede5b88.yaml b/releasenotes/notes/ansible-core-2-16-257dc4502ede5b88.yaml
new file mode 100644
index 0000000000..0305345619
--- /dev/null
+++ b/releasenotes/notes/ansible-core-2-16-257dc4502ede5b88.yaml
@@ -0,0 +1,5 @@
+---
+upgrade:
+  - |
+    Minimum supported Ansible version is now ``8`` (ansible-core 2.15)
+    and maximum supported is ``9`` (ansible-core 2.16).
diff --git a/tests/run.yml b/tests/run.yml
index db49fb9361..9723d2b72b 100644
--- a/tests/run.yml
+++ b/tests/run.yml
@@ -260,13 +260,6 @@
         virtualenv: "{{ kolla_ansible_venv_path }}"
 
     - name: Install kolla-ansible and dependencies
-      vars:
-        ansible_core_version_slurp: "==2.13.*"
-        ansible_core_version_min: "==2.14.*"
-        ansible_core_version_max: "==2.15.*"
-        # Test latest ansible version on Ubuntu, minimum supported on others.
-        ansible_core_version_constraint: >-
-          {{ ansible_core_version_slurp if is_slurp else ansible_core_version_min if is_upgrade or base_distro != 'ubuntu' else ansible_core_version_max }}
       pip:
         extra_args: "-c {{ upper_constraints_file }}"
         name:
@@ -277,13 +270,6 @@
 
     # TODO(mnasiadka): Remove in D
     - name: Install Ansible on SLURP upgrade only
-      vars:
-        ansible_version_slurp: "==6.*"
-        ansible_version_min: "==7.*"
-        ansible_version_max: "==8.*"
-        # Test latest ansible version on Ubuntu, minimum supported on others.
-        ansible_version_constraint: >-
-          {{ ansible_version_slurp if is_slurp else ansible_version_min if is_upgrade or base_distro != 'ubuntu' else ansible_version_max }}
       pip:
         extra_args: "-c {{ upper_constraints_file }}"
         name: "ansible{{ ansible_version_constraint }}"
@@ -693,14 +679,8 @@
 
         - name: Upgrade ansible
           vars:
-            ansible_core_version_min: "==2.14.*"
-            ansible_core_version_max: "==2.15.*"
-            # Test latest ansible version on Ubuntu, minimum supported on others.
             ansible_core_version_constraint: >-
               {{ ansible_core_version_min if is_upgrade or base_distro != 'ubuntu' else ansible_core_version_max }}
-            ansible_version_min: "==7.*"
-            ansible_version_max: "==8.*"
-            # 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 }}
           pip:
diff --git a/tools/kolla-ansible b/tools/kolla-ansible
index 07b43cf6c1..f2daa7f4eb 100755
--- a/tools/kolla-ansible
+++ b/tools/kolla-ansible
@@ -7,8 +7,8 @@ set -o errexit
 # do not use _PYTHON_BIN directly, use $(get_python_bin) instead
 _PYTHON_BIN=""
 
-ANSIBLE_VERSION_MIN=2.14
-ANSIBLE_VERSION_MAX=2.15
+ANSIBLE_VERSION_MIN=2.15
+ANSIBLE_VERSION_MAX=2.16
 
 function get_python_bin {
     if [ -n "$_PYTHON_BIN" ]; then
diff --git a/zuul.d/base.yaml b/zuul.d/base.yaml
index e53752bcff..bc7f9d65eb 100644
--- a/zuul.d/base.yaml
+++ b/zuul.d/base.yaml
@@ -3,16 +3,21 @@
     name: kolla-ansible-variables
     vars:
       address_family: 'ipv4'
-      # Test latest ansible version on Ubuntu, minimum supported on others.
+      # Test latest ansible-core version on Ubuntu, minimum supported on others.
+      # Use SLURP version (two releases back) on SLURP upgrades.
       ansible_core_version_constraint: >-
-        {{ ansible_core_version_min if is_upgrade or base_distro != 'ubuntu' else ansible_core_version_max }}
-      ansible_core_version_max: "==2.15.*"
-      ansible_core_version_min: "==2.14.*"
-      # Test latest ansible version on Ubuntu, minimum supported on others.
+        {{ ansible_core_version_slurp if is_slurp else ansible_core_version_min if is_upgrade or ansible_facts.distribution != "Ubuntu" else ansible_core_version_max }}
+      ansible_core_version_slurp: "==2.14.*"
+      ansible_core_version_max: "==2.16.*"
+      ansible_core_version_min: "==2.15.*"
+      # Test latest ansible-core version on Ubuntu, minimum supported on others.
+      # Use SLURP version (two releases back) on SLURP upgrades.
+      # TODO(mnasiadka): Remove in D.
       ansible_version_constraint: >-
-        {{ ansible_version_min if is_upgrade or base_distro != 'ubuntu' else ansible_version_max }}
-      ansible_version_max: "==8.*"
-      ansible_version_min: "==7.*"
+          {{ ansible_version_slurp if is_slurp else ansible_version_min if is_upgrade or ansible_facts.distribution != "Ubuntu" else ansible_version_max }}
+      ansible_version_slurp: "==7.*"
+      ansible_version_min: "==8.*"
+      ansible_version_max: "==9.*"
       api_interface_name: vxlan0
       api_network_prefix: "192.0.2."
       api_network_prefix_length: "24"