mirror of
https://github.com/kubernetes-sigs/kubespray.git
synced 2026-02-24 14:36:04 -03:30
project: upgrade test dependencies and drop ansible-core 2.11 (#10034)
Molecule 5.0 require ansible-core 2.12.10. So this commit we update ansible-core from 2.12.5 to 2.12.10. We also drop supporting two ansible-core version. Also we now use the "oldest" still supported ansible-core version as both 2.11 is EOL and not supported by molecule. tests/molecule: remove linting in molecule to support molecule 5 tests/molecule: remove role name check for molecule 5 support Kubespray doesn't use ansible galaxy style naming so we have to disable that check. contrib/inventory_builder: fix tox.ini for tox4 tests/molecule: fix get_playbook in testinfra tests tests: upgrade most tests requirements Exclude ansible-lint for now, I will do that in a separate PR. tests/molecule: force kvm driver option If we don't do this it fallbacks to qemu emulated on our CI for some reasons. Signed-off-by: Arthur Outhenin-Chalandre <arthur.outhenin-chalandre@proton.ch>
This commit is contained in:
committed by
GitHub
parent
b7fa2d7b87
commit
edc73bc3c8
@@ -1,9 +1,7 @@
|
||||
---
|
||||
role_name_check: 1
|
||||
dependency:
|
||||
name: galaxy
|
||||
lint: |
|
||||
set -e
|
||||
yamllint -c ../../.yamllint .
|
||||
driver:
|
||||
name: vagrant
|
||||
provider:
|
||||
@@ -13,15 +11,13 @@ platforms:
|
||||
box: generic/ubuntu2004
|
||||
cpus: 1
|
||||
memory: 512
|
||||
provider_options:
|
||||
driver: kvm
|
||||
provisioner:
|
||||
name: ansible
|
||||
config_options:
|
||||
defaults:
|
||||
callbacks_enabled: profile_tasks
|
||||
timeout: 120
|
||||
lint:
|
||||
name: ansible-lint
|
||||
verifier:
|
||||
name: testinfra
|
||||
lint:
|
||||
name: flake8
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
import os
|
||||
import yaml
|
||||
import glob
|
||||
from pathlib import Path
|
||||
|
||||
import testinfra.utils.ansible_runner
|
||||
from ansible.playbook import Playbook
|
||||
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')
|
||||
os.environ["MOLECULE_INVENTORY_FILE"]
|
||||
).get_hosts("all")
|
||||
|
||||
|
||||
def read_playbook(playbook):
|
||||
cli_args = [os.path.realpath(playbook), testinfra_hosts]
|
||||
@@ -19,19 +22,22 @@ def read_playbook(playbook):
|
||||
for play in pb.get_plays():
|
||||
yield variable_manager.get_vars(play)
|
||||
|
||||
|
||||
def get_playbook():
|
||||
with open(os.path.realpath(' '.join(map(str,glob.glob('molecule.*')))), 'r') as yamlfile:
|
||||
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']
|
||||
if "playbooks" in data["provisioner"].keys():
|
||||
if "converge" in data["provisioner"]["playbooks"].keys():
|
||||
return data["provisioner"]["playbooks"]["converge"]
|
||||
else:
|
||||
return ' '.join(map(str,glob.glob('converge.*')))
|
||||
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
|
||||
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
|
||||
assert host.group(vars["user"]["name"]).exists
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
---
|
||||
role_name_check: 1
|
||||
dependency:
|
||||
name: galaxy
|
||||
lint: |
|
||||
set -e
|
||||
yamllint -c ../../.yamllint .
|
||||
driver:
|
||||
name: vagrant
|
||||
provider:
|
||||
@@ -13,14 +11,14 @@ platforms:
|
||||
box: generic/ubuntu2004
|
||||
cpus: 1
|
||||
memory: 512
|
||||
provider_options:
|
||||
driver: kvm
|
||||
provisioner:
|
||||
name: ansible
|
||||
config_options:
|
||||
defaults:
|
||||
callbacks_enabled: profile_tasks
|
||||
timeout: 120
|
||||
lint:
|
||||
name: ansible-lint
|
||||
inventory:
|
||||
hosts:
|
||||
all:
|
||||
@@ -31,5 +29,3 @@ provisioner:
|
||||
bastion-01:
|
||||
verifier:
|
||||
name: testinfra
|
||||
lint:
|
||||
name: flake8
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
import os
|
||||
import yaml
|
||||
import glob
|
||||
from pathlib import Path
|
||||
|
||||
import testinfra.utils.ansible_runner
|
||||
from ansible.playbook import Playbook
|
||||
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')
|
||||
os.environ["MOLECULE_INVENTORY_FILE"]
|
||||
).get_hosts("all")
|
||||
|
||||
|
||||
def read_playbook(playbook):
|
||||
cli_args = [os.path.realpath(playbook), testinfra_hosts]
|
||||
@@ -19,16 +22,19 @@ def read_playbook(playbook):
|
||||
for play in pb.get_plays():
|
||||
yield variable_manager.get_vars(play)
|
||||
|
||||
|
||||
def get_playbook():
|
||||
with open(os.path.realpath(' '.join(map(str,glob.glob('molecule.*')))), 'r') as yamlfile:
|
||||
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']
|
||||
if "playbooks" in data["provisioner"].keys():
|
||||
if "converge" in data["provisioner"]["playbooks"].keys():
|
||||
return data["provisioner"]["playbooks"]["converge"]
|
||||
else:
|
||||
return ' '.join(map(str,glob.glob('converge.*')))
|
||||
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
|
||||
assert host.file(vars["ssh_bastion_confing__name"]).exists
|
||||
assert host.file(vars["ssh_bastion_confing__name"]).is_file
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
---
|
||||
role_name_check: 1
|
||||
dependency:
|
||||
name: galaxy
|
||||
lint: |
|
||||
set -e
|
||||
yamllint -c ../../.yamllint .
|
||||
driver:
|
||||
name: vagrant
|
||||
provider:
|
||||
@@ -13,30 +11,38 @@ platforms:
|
||||
box: generic/ubuntu2004
|
||||
cpus: 1
|
||||
memory: 512
|
||||
provider_options:
|
||||
driver: kvm
|
||||
- name: ubuntu22
|
||||
box: generic/ubuntu2204
|
||||
cpus: 1
|
||||
memory: 1024
|
||||
provider_options:
|
||||
driver: kvm
|
||||
- name: centos7
|
||||
box: centos/7
|
||||
cpus: 1
|
||||
memory: 512
|
||||
provider_options:
|
||||
driver: kvm
|
||||
- name: almalinux8
|
||||
box: almalinux/8
|
||||
cpus: 1
|
||||
memory: 512
|
||||
provider_options:
|
||||
driver: kvm
|
||||
- name: debian10
|
||||
box: generic/debian10
|
||||
cpus: 1
|
||||
memory: 512
|
||||
provider_options:
|
||||
driver: kvm
|
||||
provisioner:
|
||||
name: ansible
|
||||
config_options:
|
||||
defaults:
|
||||
callbacks_enabled: profile_tasks
|
||||
timeout: 120
|
||||
lint:
|
||||
name: ansible-lint
|
||||
inventory:
|
||||
group_vars:
|
||||
all:
|
||||
@@ -45,5 +51,3 @@ provisioner:
|
||||
comment: My test comment
|
||||
verifier:
|
||||
name: testinfra
|
||||
lint:
|
||||
name: flake8
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
---
|
||||
role_name_check: 1
|
||||
driver:
|
||||
name: vagrant
|
||||
provider:
|
||||
name: libvirt
|
||||
lint: |
|
||||
set -e
|
||||
yamllint -c ../../../.yamllint .
|
||||
platforms:
|
||||
- name: ubuntu20
|
||||
box: generic/ubuntu2004
|
||||
@@ -15,6 +13,8 @@ platforms:
|
||||
- kube_control_plane
|
||||
- kube_node
|
||||
- k8s_cluster
|
||||
provider_options:
|
||||
driver: kvm
|
||||
- name: debian11
|
||||
box: generic/debian11
|
||||
cpus: 1
|
||||
@@ -23,6 +23,8 @@ platforms:
|
||||
- kube_control_plane
|
||||
- kube_node
|
||||
- k8s_cluster
|
||||
provider_options:
|
||||
driver: kvm
|
||||
- name: almalinux8
|
||||
box: almalinux/8
|
||||
cpus: 1
|
||||
@@ -31,6 +33,8 @@ platforms:
|
||||
- kube_control_plane
|
||||
- kube_node
|
||||
- k8s_cluster
|
||||
provider_options:
|
||||
driver: kvm
|
||||
provisioner:
|
||||
name: ansible
|
||||
env:
|
||||
@@ -39,11 +43,5 @@ provisioner:
|
||||
defaults:
|
||||
callbacks_enabled: profile_tasks
|
||||
timeout: 120
|
||||
lint:
|
||||
name: ansible-lint
|
||||
options:
|
||||
c: ../../../.ansible-lint
|
||||
verifier:
|
||||
name: testinfra
|
||||
lint:
|
||||
name: flake8
|
||||
|
||||
@@ -1,13 +1,9 @@
|
||||
---
|
||||
role_name_check: 1
|
||||
driver:
|
||||
name: vagrant
|
||||
provider:
|
||||
name: libvirt
|
||||
options:
|
||||
driver: kvm
|
||||
lint: |
|
||||
set -e
|
||||
yamllint -c ../../../.yamllint .
|
||||
platforms:
|
||||
- name: almalinux8
|
||||
box: almalinux/8
|
||||
@@ -16,6 +12,8 @@ platforms:
|
||||
nested: true
|
||||
groups:
|
||||
- kube_control_plane
|
||||
provider_options:
|
||||
driver: kvm
|
||||
- name: ubuntu20
|
||||
box: generic/ubuntu2004
|
||||
cpus: 1
|
||||
@@ -23,6 +21,8 @@ platforms:
|
||||
nested: true
|
||||
groups:
|
||||
- kube_control_plane
|
||||
provider_options:
|
||||
driver: kvm
|
||||
provisioner:
|
||||
name: ansible
|
||||
env:
|
||||
@@ -31,15 +31,9 @@ provisioner:
|
||||
defaults:
|
||||
callbacks_enabled: profile_tasks
|
||||
timeout: 120
|
||||
lint:
|
||||
name: ansible-lint
|
||||
options:
|
||||
c: ../../../.ansible-lint
|
||||
inventory:
|
||||
group_vars:
|
||||
all:
|
||||
become: true
|
||||
verifier:
|
||||
name: testinfra
|
||||
lint:
|
||||
name: flake8
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
---
|
||||
role_name_check: 1
|
||||
driver:
|
||||
name: vagrant
|
||||
provider:
|
||||
name: libvirt
|
||||
lint: |
|
||||
set -e
|
||||
yamllint -c ../../../.yamllint .
|
||||
platforms:
|
||||
- name: ubuntu20
|
||||
box: generic/ubuntu2004
|
||||
@@ -15,6 +13,8 @@ platforms:
|
||||
- kube_control_plane
|
||||
- kube_node
|
||||
- k8s_cluster
|
||||
provider_options:
|
||||
driver: kvm
|
||||
- name: almalinux8
|
||||
box: almalinux/8
|
||||
cpus: 2
|
||||
@@ -23,6 +23,8 @@ platforms:
|
||||
- kube_control_plane
|
||||
- kube_node
|
||||
- k8s_cluster
|
||||
provider_options:
|
||||
driver: kvm
|
||||
- name: fedora
|
||||
box: fedora/36-cloud-base
|
||||
cpus: 2
|
||||
@@ -31,6 +33,8 @@ platforms:
|
||||
- kube_control_plane
|
||||
- kube_node
|
||||
- k8s_cluster
|
||||
provider_options:
|
||||
driver: kvm
|
||||
- name: debian10
|
||||
box: generic/debian10
|
||||
cpus: 2
|
||||
@@ -39,6 +43,8 @@ platforms:
|
||||
- kube_control_plane
|
||||
- kube_node
|
||||
- k8s_cluster
|
||||
provider_options:
|
||||
driver: kvm
|
||||
provisioner:
|
||||
name: ansible
|
||||
env:
|
||||
@@ -47,11 +53,5 @@ provisioner:
|
||||
defaults:
|
||||
callbacks_enabled: profile_tasks
|
||||
timeout: 120
|
||||
lint:
|
||||
name: ansible-lint
|
||||
options:
|
||||
c: ../../../.ansible-lint
|
||||
verifier:
|
||||
name: testinfra
|
||||
lint:
|
||||
name: flake8
|
||||
|
||||
@@ -1,13 +1,9 @@
|
||||
---
|
||||
role_name_check: 1
|
||||
driver:
|
||||
name: vagrant
|
||||
provider:
|
||||
name: libvirt
|
||||
options:
|
||||
driver: kvm
|
||||
lint: |
|
||||
set -e
|
||||
yamllint -c ../../../.yamllint .
|
||||
platforms:
|
||||
- name: ubuntu20
|
||||
box: generic/ubuntu2004
|
||||
@@ -16,6 +12,8 @@ platforms:
|
||||
nested: true
|
||||
groups:
|
||||
- kube_control_plane
|
||||
provider_options:
|
||||
driver: kvm
|
||||
- name: almalinux8
|
||||
box: almalinux/8
|
||||
cpus: 1
|
||||
@@ -23,6 +21,8 @@ platforms:
|
||||
nested: true
|
||||
groups:
|
||||
- kube_control_plane
|
||||
provider_options:
|
||||
driver: kvm
|
||||
provisioner:
|
||||
name: ansible
|
||||
env:
|
||||
@@ -31,15 +31,9 @@ provisioner:
|
||||
defaults:
|
||||
callbacks_enabled: profile_tasks
|
||||
timeout: 120
|
||||
lint:
|
||||
name: ansible-lint
|
||||
options:
|
||||
c: ../../../.ansible-lint
|
||||
inventory:
|
||||
group_vars:
|
||||
all:
|
||||
become: true
|
||||
verifier:
|
||||
name: testinfra
|
||||
lint:
|
||||
name: flake8
|
||||
|
||||
@@ -1,13 +1,9 @@
|
||||
---
|
||||
role_name_check: 1
|
||||
driver:
|
||||
name: vagrant
|
||||
provider:
|
||||
name: libvirt
|
||||
options:
|
||||
driver: kvm
|
||||
lint: |
|
||||
set -e
|
||||
yamllint -c ../../../.yamllint .
|
||||
platforms:
|
||||
- name: ubuntu20
|
||||
box: generic/ubuntu2004
|
||||
@@ -16,6 +12,8 @@ platforms:
|
||||
nested: true
|
||||
groups:
|
||||
- kube_control_plane
|
||||
provider_options:
|
||||
driver: kvm
|
||||
- name: ubuntu22
|
||||
box: generic/ubuntu2204
|
||||
cpus: 1
|
||||
@@ -23,6 +21,8 @@ platforms:
|
||||
nested: true
|
||||
groups:
|
||||
- kube_control_plane
|
||||
provider_options:
|
||||
driver: kvm
|
||||
provisioner:
|
||||
name: ansible
|
||||
env:
|
||||
@@ -31,15 +31,9 @@ provisioner:
|
||||
defaults:
|
||||
callbacks_enabled: profile_tasks
|
||||
timeout: 120
|
||||
lint:
|
||||
name: ansible-lint
|
||||
options:
|
||||
c: ../../../.ansible-lint
|
||||
inventory:
|
||||
group_vars:
|
||||
all:
|
||||
become: true
|
||||
verifier:
|
||||
name: testinfra
|
||||
lint:
|
||||
name: flake8
|
||||
|
||||
@@ -1,13 +1,9 @@
|
||||
---
|
||||
role_name_check: 1
|
||||
driver:
|
||||
name: vagrant
|
||||
provider:
|
||||
name: libvirt
|
||||
options:
|
||||
driver: kvm
|
||||
lint: |
|
||||
set -e
|
||||
yamllint -c ../../../.yamllint .
|
||||
platforms:
|
||||
- name: ubuntu20
|
||||
box: generic/ubuntu2004
|
||||
@@ -16,6 +12,8 @@ platforms:
|
||||
nested: true
|
||||
groups:
|
||||
- kube_control_plane
|
||||
provider_options:
|
||||
driver: kvm
|
||||
- name: almalinux8
|
||||
box: almalinux/8
|
||||
cpus: 1
|
||||
@@ -23,6 +21,8 @@ platforms:
|
||||
nested: true
|
||||
groups:
|
||||
- kube_control_plane
|
||||
provider_options:
|
||||
driver: kvm
|
||||
provisioner:
|
||||
name: ansible
|
||||
env:
|
||||
@@ -31,15 +31,9 @@ provisioner:
|
||||
defaults:
|
||||
callbacks_enabled: profile_tasks
|
||||
timeout: 120
|
||||
lint:
|
||||
name: ansible-lint
|
||||
options:
|
||||
c: ../../../.ansible-lint
|
||||
inventory:
|
||||
group_vars:
|
||||
all:
|
||||
become: true
|
||||
verifier:
|
||||
name: testinfra
|
||||
lint:
|
||||
name: flake8
|
||||
|
||||
Reference in New Issue
Block a user