mirror of
https://github.com/kubernetes-sigs/kubespray.git
synced 2026-10-29 22:03:22 -02:30
CI/molecule: use common vars as well and simplify run (#13520)
The molecule_run.sh isn't really needed since the switch to gitlab-ci matrix runs. Also use the inventory variables pattern for kata-containers.
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
---
|
---
|
||||||
.molecule:
|
molecule:
|
||||||
tags: [ffci]
|
tags: [ffci]
|
||||||
rules: # run on ci-short as well
|
rules: # run on ci-short as well
|
||||||
- if: $CI_COMMIT_BRANCH =~ /^pr-.*$/
|
- if: $CI_COMMIT_BRANCH =~ /^pr-.*$/
|
||||||
@@ -13,7 +13,8 @@
|
|||||||
needs:
|
needs:
|
||||||
- pipeline-image
|
- pipeline-image
|
||||||
script:
|
script:
|
||||||
- ./tests/scripts/molecule_run.sh
|
- cd roles/$ROLE
|
||||||
|
- molecule test --all -- --extra-vars @${CI_PROJECT_DIR}/tests/common_vars.yml
|
||||||
after_script:
|
after_script:
|
||||||
- rm -fr molecule_logs
|
- rm -fr molecule_logs
|
||||||
- mkdir -p molecule_logs
|
- mkdir -p molecule_logs
|
||||||
@@ -23,11 +24,6 @@
|
|||||||
when: always
|
when: always
|
||||||
paths:
|
paths:
|
||||||
- molecule_logs/
|
- molecule_logs/
|
||||||
|
|
||||||
molecule:
|
|
||||||
extends: .molecule
|
|
||||||
script:
|
|
||||||
- ./tests/scripts/molecule_run.sh -i $ROLE
|
|
||||||
parallel:
|
parallel:
|
||||||
matrix:
|
matrix:
|
||||||
- ROLE:
|
- ROLE:
|
||||||
|
|||||||
+1
-1
@@ -25,7 +25,7 @@ pre-commit run -a # To run pre-commit hook on all files in the repository, even
|
|||||||
|
|
||||||
#### Molecule
|
#### Molecule
|
||||||
|
|
||||||
[molecule](https://github.com/ansible-community/molecule) is designed to help the development and testing of Ansible roles. In Kubespray you can run it all for all roles with `./tests/scripts/molecule_run.sh` or for a specific role (that you are working with) with `molecule test` from the role directory (`cd roles/my-role`).
|
[molecule](https://github.com/ansible-community/molecule) is designed to help the development and testing of Ansible roles. In Kubespray you can run it all for all roles with `find roles -name molecule -type d -execdir molecule test --all -- -e @$PWD/tests/common_vars.yml \;` or for a specific role (that you are working with) with `molecule test` from the role directory (`cd roles/my-role`).
|
||||||
|
|
||||||
When developing or debugging a role it can be useful to run `molecule create` and `molecule converge` separately. Then you can use `molecule login` to SSH into the test environment.
|
When developing or debugging a role it can be useful to run `molecule create` and `molecule converge` separately. Then you can use `molecule login` to SSH into the test environment.
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,12 @@
|
|||||||
- name: Get kubespray defaults
|
- name: Get kubespray defaults
|
||||||
import_role:
|
import_role:
|
||||||
name: ../../../../../kubespray_defaults
|
name: ../../../../../kubespray_defaults
|
||||||
|
- name: Get OS facts (needed for bin_dir resolution)
|
||||||
|
setup:
|
||||||
|
gather_subset:
|
||||||
|
- '!all'
|
||||||
|
- '!min'
|
||||||
|
- 'distribution'
|
||||||
- name: Test version
|
- name: Test version
|
||||||
command: "{{ bin_dir }}/runsc --version"
|
command: "{{ bin_dir }}/runsc --version"
|
||||||
register: runsc_version
|
register: runsc_version
|
||||||
|
|||||||
@@ -2,9 +2,6 @@
|
|||||||
- name: Converge
|
- name: Converge
|
||||||
hosts: all
|
hosts: all
|
||||||
become: true
|
become: true
|
||||||
vars:
|
|
||||||
kata_containers_enabled: true
|
|
||||||
container_manager: containerd
|
|
||||||
roles:
|
roles:
|
||||||
- role: kubespray_defaults
|
- role: kubespray_defaults
|
||||||
- role: container-engine/containerd
|
- role: container-engine/containerd
|
||||||
|
|||||||
@@ -7,12 +7,16 @@ platforms:
|
|||||||
vm_memory: 1024
|
vm_memory: 1024
|
||||||
node_groups:
|
node_groups:
|
||||||
- kube_control_plane
|
- kube_control_plane
|
||||||
|
- kube_node
|
||||||
|
- k8s_cluster
|
||||||
- name: ubuntu24
|
- name: ubuntu24
|
||||||
cloud_image: ubuntu-2404
|
cloud_image: ubuntu-2404
|
||||||
vm_cpu_cores: 1
|
vm_cpu_cores: 1
|
||||||
vm_memory: 1024
|
vm_memory: 1024
|
||||||
node_groups:
|
node_groups:
|
||||||
- kube_control_plane
|
- kube_control_plane
|
||||||
|
- kube_node
|
||||||
|
- k8s_cluster
|
||||||
provisioner:
|
provisioner:
|
||||||
name: ansible
|
name: ansible
|
||||||
env:
|
env:
|
||||||
@@ -21,6 +25,11 @@ provisioner:
|
|||||||
defaults:
|
defaults:
|
||||||
callbacks_enabled: profile_tasks
|
callbacks_enabled: profile_tasks
|
||||||
timeout: 120
|
timeout: 120
|
||||||
|
inventory:
|
||||||
|
group_vars:
|
||||||
|
k8s_cluster:
|
||||||
|
kata_containers_enabled: true
|
||||||
|
container_manager: containerd
|
||||||
playbooks:
|
playbooks:
|
||||||
create: ../../../../../tests/cloud_playbooks/create-kubevirt.yml
|
create: ../../../../../tests/cloud_playbooks/create-kubevirt.yml
|
||||||
prepare: ../../../molecule/prepare.yml
|
prepare: ../../../molecule/prepare.yml
|
||||||
|
|||||||
@@ -3,6 +3,15 @@
|
|||||||
hosts: all
|
hosts: all
|
||||||
gather_facts: false
|
gather_facts: false
|
||||||
tasks:
|
tasks:
|
||||||
|
- name: Get kubespray defaults
|
||||||
|
import_role:
|
||||||
|
name: ../../../../../kubespray_defaults
|
||||||
|
- name: Get OS facts (needed for bin_dir resolution)
|
||||||
|
setup:
|
||||||
|
gather_subset:
|
||||||
|
- '!all'
|
||||||
|
- '!min'
|
||||||
|
- 'distribution'
|
||||||
- name: Test version
|
- name: Test version
|
||||||
command: "/opt/kata/bin/kata-runtime version"
|
command: "/opt/kata/bin/kata-runtime version"
|
||||||
register: version
|
register: version
|
||||||
|
|||||||
@@ -7,6 +7,12 @@
|
|||||||
- name: Get kubespray defaults
|
- name: Get kubespray defaults
|
||||||
import_role:
|
import_role:
|
||||||
name: ../../kubespray_defaults
|
name: ../../kubespray_defaults
|
||||||
|
- name: Get OS facts (needed for bin_dir resolution)
|
||||||
|
setup:
|
||||||
|
gather_subset:
|
||||||
|
- '!all'
|
||||||
|
- '!min'
|
||||||
|
- 'distribution'
|
||||||
- name: Collect services facts
|
- name: Collect services facts
|
||||||
ansible.builtin.service_facts:
|
ansible.builtin.service_facts:
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,12 @@
|
|||||||
- name: Get kubespray defaults
|
- name: Get kubespray defaults
|
||||||
import_role:
|
import_role:
|
||||||
name: ../../../../../kubespray_defaults
|
name: ../../../../../kubespray_defaults
|
||||||
|
- name: Get OS facts (needed for bin_dir resolution)
|
||||||
|
setup:
|
||||||
|
gather_subset:
|
||||||
|
- '!all'
|
||||||
|
- '!min'
|
||||||
|
- 'distribution'
|
||||||
- name: Test version
|
- name: Test version
|
||||||
command: "{{ bin_dir }}/youki --version"
|
command: "{{ bin_dir }}/youki --version"
|
||||||
register: youki_version
|
register: youki_version
|
||||||
|
|||||||
@@ -1,34 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
set -euxo pipefail -o noglob
|
|
||||||
|
|
||||||
export LC_ALL=C.UTF-8
|
|
||||||
export LANG=C.UTF-8
|
|
||||||
|
|
||||||
_PATH='roles'
|
|
||||||
_EXCLUDE=""
|
|
||||||
|
|
||||||
while [[ $# -gt 0 ]] ; do
|
|
||||||
case $1 in
|
|
||||||
-e|--exclude)
|
|
||||||
_EXCLUDE="${_EXCLUDE} -not -path ${_PATH}/$2/*"
|
|
||||||
shift
|
|
||||||
shift
|
|
||||||
;;
|
|
||||||
-i|--include)
|
|
||||||
_PATH="${_PATH}/$2"
|
|
||||||
shift
|
|
||||||
shift
|
|
||||||
;;
|
|
||||||
-h|--help)
|
|
||||||
echo "Usage: molecule_run.sh [-h|--help] [-e|--exclude] [-i|--include]"
|
|
||||||
exit 0
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
for d in $(find ${_PATH} ${_EXCLUDE} -name molecule -type d)
|
|
||||||
do
|
|
||||||
pushd $(dirname $d)
|
|
||||||
molecule test --all
|
|
||||||
popd
|
|
||||||
done
|
|
||||||
Reference in New Issue
Block a user