Browse Source

Update to ansible 2.15 (#10481)

* ansible: upgrade to version >= 2.15.5

Signed-off-by: Arthur Outhenin-Chalandre <arthur@cri.epita.fr>

* tests: update requirements

Signed-off-by: Arthur Outhenin-Chalandre <arthur@cri.epita.fr>

* contrib/openstack: fix wrong gitignore pattern

Signed-off-by: Arthur Outhenin-Chalandre <arthur@cri.epita.fr>

* tests: add missing tzdata requirement

Signed-off-by: Arthur Outhenin-Chalandre <arthur@cri.epita.fr>

* 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 <arthur@cri.epita.fr>

---------

Signed-off-by: Arthur Outhenin-Chalandre <arthur@cri.epita.fr>
pull/10625/head
Arthur Outhenin-Chalandre 1 year ago
committed by GitHub
parent
commit
7ba85710ad
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 18 additions and 100 deletions
  1. 2
      contrib/terraform/openstack/.gitignore
  2. 2
      docs/ansible.md
  3. 2
      meta/runtime.yml
  4. 4
      playbooks/ansible_version.yml
  5. 10
      requirements.txt
  6. 43
      roles/adduser/molecule/default/tests/test_default.py
  7. 40
      roles/bastion-ssh-config/molecule/default/tests/test_default.py
  8. 15
      tests/requirements.txt

2
contrib/terraform/openstack/.gitignore

@ -1,5 +1,5 @@
.terraform
*.tfvars
!sample-inventory\/cluster.tfvars
!sample-inventory/cluster.tfvars
*.tfstate
*.tfstate.backup

2
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

2
meta/runtime.yml

@ -1,2 +1,2 @@
---
requires_ansible: '>=2.14.0'
requires_ansible: '>=2.15.5'

4
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:

10
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

43
roles/adduser/molecule/default/tests/test_default.py

@ -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

40
roles/bastion-ssh-config/molecule/default/tests/test_default.py

@ -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

15
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
Loading…
Cancel
Save