mirror of
https://github.com/kubernetes-sigs/kubespray.git
synced 2026-02-15 10:10:03 -03:30
CI: Simplify running playbooks as collection
This commit is contained in:
@@ -30,38 +30,16 @@ export ANSIBLE_BECOME_USER=root
|
|||||||
if [[ "${TESTCASE}" =~ "collection" ]]; then
|
if [[ "${TESTCASE}" =~ "collection" ]]; then
|
||||||
# Build and install collection
|
# Build and install collection
|
||||||
ansible-galaxy collection build
|
ansible-galaxy collection build
|
||||||
ansible-galaxy collection install kubernetes_sigs-kubespray-$(grep "^version:" galaxy.yml | awk '{print $2}').tar.gz
|
ansible-galaxy collection install kubernetes_sigs-kubespray-*.tar.gz
|
||||||
|
|
||||||
# Simply remove all of our files and directories except for our tests directory
|
|
||||||
# to be absolutely certain that none of our playbooks or roles
|
|
||||||
# are interfering with our collection
|
|
||||||
find -mindepth 1 -maxdepth 1 ! -regex './\(tests\|inventory\)' -exec rm -rfv {} +
|
|
||||||
|
|
||||||
cat > cluster.yml <<EOF
|
|
||||||
- name: Install Kubernetes
|
|
||||||
ansible.builtin.import_playbook: kubernetes_sigs.kubespray.cluster
|
|
||||||
EOF
|
|
||||||
|
|
||||||
cat > upgrade-cluster.yml <<EOF
|
|
||||||
- name: Install Kubernetes
|
|
||||||
ansible.builtin.import_playbook: kubernetes_sigs.kubespray.upgrade-cluster
|
|
||||||
EOF
|
|
||||||
|
|
||||||
cat > reset.yml <<EOF
|
|
||||||
- name: Remove Kubernetes
|
|
||||||
ansible.builtin.import_playbook: kubernetes_sigs.kubespray.reset
|
|
||||||
EOF
|
|
||||||
|
|
||||||
cat > remove-node.yml <<EOF
|
|
||||||
- name: Remove node from Kubernetes
|
|
||||||
ansible.builtin.import_playbook: kubernetes_sigs.kubespray.remove_node
|
|
||||||
EOF
|
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
run_playbook () {
|
run_playbook () {
|
||||||
playbook=$1
|
if [[ "${TESTCASE}" =~ "collection" ]]; then
|
||||||
|
playbook=kubernetes_sigs.kubespray.$1
|
||||||
|
else
|
||||||
|
playbook=$1.yml
|
||||||
|
fi
|
||||||
shift
|
shift
|
||||||
|
|
||||||
ansible-playbook \
|
ansible-playbook \
|
||||||
-e @tests/common_vars.yml \
|
-e @tests/common_vars.yml \
|
||||||
-e @tests/${TESTCASE_FILE} \
|
-e @tests/${TESTCASE_FILE} \
|
||||||
@@ -71,11 +49,10 @@ ansible-playbook \
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## START KUBESPRAY
|
## START KUBESPRAY
|
||||||
|
|
||||||
# Create cluster
|
# Create cluster
|
||||||
run_playbook cluster.yml
|
run_playbook cluster
|
||||||
|
|
||||||
# Repeat deployment if testing upgrade
|
# Repeat deployment if testing upgrade
|
||||||
if [ "${UPGRADE_TEST}" != "false" ]; then
|
if [ "${UPGRADE_TEST}" != "false" ]; then
|
||||||
@@ -85,10 +62,10 @@ if [ "${UPGRADE_TEST}" != "false" ]; then
|
|||||||
|
|
||||||
case "${UPGRADE_TEST}" in
|
case "${UPGRADE_TEST}" in
|
||||||
"basic")
|
"basic")
|
||||||
run_playbook cluster.yml
|
run_playbook cluster
|
||||||
;;
|
;;
|
||||||
"graceful")
|
"graceful")
|
||||||
run_playbook upgrade-cluster.yml
|
run_playbook upgrade-cluster
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
;;
|
;;
|
||||||
@@ -97,8 +74,8 @@ fi
|
|||||||
|
|
||||||
# Test control plane recovery
|
# Test control plane recovery
|
||||||
if [ "${RECOVER_CONTROL_PLANE_TEST}" != "false" ]; then
|
if [ "${RECOVER_CONTROL_PLANE_TEST}" != "false" ]; then
|
||||||
run_playbook reset.yml --limit "${RECOVER_CONTROL_PLANE_TEST_GROUPS}" -e reset_confirmation=yes
|
run_playbook reset --limit "${RECOVER_CONTROL_PLANE_TEST_GROUPS}" -e reset_confirmation=yes
|
||||||
run_playbook recover-control-plane.yml -e etcd_retries=10 --limit "etcd:kube_control_plane"
|
run_playbook recover-control-plane -e etcd_retries=10 --limit "etcd:kube_control_plane"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Tests Cases
|
# Tests Cases
|
||||||
@@ -123,10 +100,10 @@ run_playbook tests/testcases/100_check-k8s-conformance.yml
|
|||||||
|
|
||||||
# Test node removal procedure
|
# Test node removal procedure
|
||||||
if [ "${REMOVE_NODE_CHECK}" = "true" ]; then
|
if [ "${REMOVE_NODE_CHECK}" = "true" ]; then
|
||||||
run_playbook remove-node.yml -e skip_confirmation=yes -e node=${REMOVE_NODE_NAME}
|
run_playbook remove-node -e skip_confirmation=yes -e node=${REMOVE_NODE_NAME}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Clean up at the end, this is to allow stage1 tests to include cleanup test
|
# Clean up at the end, this is to allow stage1 tests to include cleanup test
|
||||||
if [ "${RESET_CHECK}" = "true" ]; then
|
if [ "${RESET_CHECK}" = "true" ]; then
|
||||||
run_playbook reset.yml -e reset_confirmation=yes
|
run_playbook reset -e reset_confirmation=yes
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user