From 7ba85710ad8d1f23e28d56cc7a128c5de05224f3 Mon Sep 17 00:00:00 2001 From: Arthur Outhenin-Chalandre Date: Wed, 15 Nov 2023 09:39:09 +0100 Subject: [PATCH] Update to ansible 2.15 (#10481) * ansible: upgrade to version >= 2.15.5 Signed-off-by: Arthur Outhenin-Chalandre * tests: update requirements Signed-off-by: Arthur Outhenin-Chalandre * contrib/openstack: fix wrong gitignore pattern Signed-off-by: Arthur Outhenin-Chalandre * tests: add missing tzdata requirement Signed-off-by: Arthur Outhenin-Chalandre * tests: remove some molecules tests Those doesn't work in Ansible 2.15. Ansible can't load builtin now apparently and these tests are not worth it. Signed-off-by: Arthur Outhenin-Chalandre --------- Signed-off-by: Arthur Outhenin-Chalandre --- contrib/terraform/openstack/.gitignore | 2 +- docs/ansible.md | 2 +- meta/runtime.yml | 2 +- playbooks/ansible_version.yml | 4 +- requirements.txt | 10 ++--- .../molecule/default/tests/test_default.py | 43 ------------------- .../molecule/default/tests/test_default.py | 40 ----------------- tests/requirements.txt | 15 ++++--- 8 files changed, 18 insertions(+), 100 deletions(-) delete mode 100644 roles/adduser/molecule/default/tests/test_default.py delete mode 100644 roles/bastion-ssh-config/molecule/default/tests/test_default.py diff --git a/contrib/terraform/openstack/.gitignore b/contrib/terraform/openstack/.gitignore index 55d775bf0..7e4921aa2 100644 --- a/contrib/terraform/openstack/.gitignore +++ b/contrib/terraform/openstack/.gitignore @@ -1,5 +1,5 @@ .terraform *.tfvars -!sample-inventory\/cluster.tfvars +!sample-inventory/cluster.tfvars *.tfstate *.tfstate.backup diff --git a/docs/ansible.md b/docs/ansible.md index 9a3110b3a..63cc1d768 100644 --- a/docs/ansible.md +++ b/docs/ansible.md @@ -32,7 +32,7 @@ Based on the table below and the available python version for your ansible host | Ansible Version | Python Version | |-----------------|----------------| -| 2.14 | 3.9-3.11 | +| >= 2.15.5 | 3.9-3.11 | ## Inventory diff --git a/meta/runtime.yml b/meta/runtime.yml index be99ccf4b..0b870b698 100644 --- a/meta/runtime.yml +++ b/meta/runtime.yml @@ -1,2 +1,2 @@ --- -requires_ansible: '>=2.14.0' +requires_ansible: '>=2.15.5' diff --git a/playbooks/ansible_version.yml b/playbooks/ansible_version.yml index 840749af5..f6cebdff7 100644 --- a/playbooks/ansible_version.yml +++ b/playbooks/ansible_version.yml @@ -4,8 +4,8 @@ gather_facts: false become: no vars: - minimal_ansible_version: 2.14.0 - maximal_ansible_version: 2.15.0 + minimal_ansible_version: 2.15.5 # 2.15 versions before 2.15.5 are known to be buggy for kubespray + maximal_ansible_version: 2.17.0 ansible_connection: local tags: always tasks: diff --git a/requirements.txt b/requirements.txt index 2420014f8..47a76fcfe 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,9 +1,9 @@ -ansible==7.6.0 -cryptography==41.0.1 +ansible==8.5.0 +cryptography==41.0.4 jinja2==3.1.2 jmespath==1.0.1 MarkupSafe==2.1.3 -netaddr==0.8.0 +netaddr==0.9.0 pbr==5.11.1 -ruamel.yaml==0.17.31 -ruamel.yaml.clib==0.2.7 +ruamel.yaml==0.17.35 +ruamel.yaml.clib==0.2.8 diff --git a/roles/adduser/molecule/default/tests/test_default.py b/roles/adduser/molecule/default/tests/test_default.py deleted file mode 100644 index 7e8649d14..000000000 --- a/roles/adduser/molecule/default/tests/test_default.py +++ /dev/null @@ -1,43 +0,0 @@ -import os -from pathlib import Path - -import testinfra.utils.ansible_runner -import yaml -from ansible.cli.playbook import PlaybookCLI -from ansible.playbook import Playbook - -testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner( - os.environ["MOLECULE_INVENTORY_FILE"] -).get_hosts("all") - - -def read_playbook(playbook): - cli_args = [os.path.realpath(playbook), testinfra_hosts] - cli = PlaybookCLI(cli_args) - cli.parse() - loader, inventory, variable_manager = cli._play_prereqs() - - pb = Playbook.load(cli.args[0], variable_manager, loader) - - for play in pb.get_plays(): - yield variable_manager.get_vars(play) - - -def get_playbook(): - playbooks_path = Path(__file__).parent.parent - with open(os.path.join(playbooks_path, "molecule.yml"), "r") as yamlfile: - data = yaml.load(yamlfile, Loader=yaml.FullLoader) - if "playbooks" in data["provisioner"].keys(): - if "converge" in data["provisioner"]["playbooks"].keys(): - return data["provisioner"]["playbooks"]["converge"] - else: - return os.path.join(playbooks_path, "converge.yml") - - -def test_user(host): - for vars in read_playbook(get_playbook()): - assert host.user(vars["user"]["name"]).exists - if "group" in vars["user"].keys(): - assert host.group(vars["user"]["group"]).exists - else: - assert host.group(vars["user"]["name"]).exists diff --git a/roles/bastion-ssh-config/molecule/default/tests/test_default.py b/roles/bastion-ssh-config/molecule/default/tests/test_default.py deleted file mode 100644 index cce719de1..000000000 --- a/roles/bastion-ssh-config/molecule/default/tests/test_default.py +++ /dev/null @@ -1,40 +0,0 @@ -import os -from pathlib import Path - -import testinfra.utils.ansible_runner -import yaml -from ansible.cli.playbook import PlaybookCLI -from ansible.playbook import Playbook - -testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner( - os.environ["MOLECULE_INVENTORY_FILE"] -).get_hosts("all") - - -def read_playbook(playbook): - cli_args = [os.path.realpath(playbook), testinfra_hosts] - cli = PlaybookCLI(cli_args) - cli.parse() - loader, inventory, variable_manager = cli._play_prereqs() - - pb = Playbook.load(cli.args[0], variable_manager, loader) - - for play in pb.get_plays(): - yield variable_manager.get_vars(play) - - -def get_playbook(): - playbooks_path = Path(__file__).parent.parent - with open(os.path.join(playbooks_path, "molecule.yml"), "r") as yamlfile: - data = yaml.load(yamlfile, Loader=yaml.FullLoader) - if "playbooks" in data["provisioner"].keys(): - if "converge" in data["provisioner"]["playbooks"].keys(): - return data["provisioner"]["playbooks"]["converge"] - else: - return os.path.join(playbooks_path, "converge.yml") - - -def test_ssh_config(host): - for vars in read_playbook(get_playbook()): - assert host.file(vars["ssh_bastion_confing__name"]).exists - assert host.file(vars["ssh_bastion_confing__name"]).is_file diff --git a/tests/requirements.txt b/tests/requirements.txt index 19474ab09..51bc76efb 100644 --- a/tests/requirements.txt +++ b/tests/requirements.txt @@ -1,11 +1,12 @@ -r ../requirements.txt -ansible-lint==6.16.2 -apache-libcloud==3.7.0 -ara[server]==1.6.1 +ansible-lint==6.20.3 +apache-libcloud==3.8.0 +ara[server]==1.7.0 dopy==0.3.7 -molecule==5.0.1 -molecule-plugins[vagrant]==23.4.1 +molecule==6.0.2 +molecule-plugins[vagrant]==23.5.0 python-vagrant==1.0.0 -pytest-testinfra==8.1.0 -tox==4.5.2 +pytest-testinfra==9.0.0 +tox==4.11.3 yamllint==1.32.0 +tzdata==2023.3