mirror of
https://github.com/kubernetes-sigs/kubespray.git
synced 2025-12-14 05:45:06 +03:00
Adds support for Ansible collections (#9582)
This commit is contained in:
@@ -12,3 +12,4 @@ stdout_callback = skippy
|
||||
library = ./library:../library
|
||||
callbacks_enabled = profile_tasks
|
||||
jinja2_extensions = jinja2.ext.do
|
||||
roles_path = ../roles
|
||||
|
||||
9
tests/files/vagrant_ubuntu20-flannel-collection.rb
Normal file
9
tests/files/vagrant_ubuntu20-flannel-collection.rb
Normal file
@@ -0,0 +1,9 @@
|
||||
$os = "ubuntu2004"
|
||||
|
||||
# For CI we are not worries about data persistence across reboot
|
||||
$libvirt_volume_cache = "unsafe"
|
||||
|
||||
# Checking for box update can trigger API rate limiting
|
||||
# https://www.vagrantup.com/docs/vagrant-cloud/request-limits.html
|
||||
$box_check_update = false
|
||||
$vm_cpus = 2
|
||||
3
tests/files/vagrant_ubuntu20-flannel-collection.yml
Normal file
3
tests/files/vagrant_ubuntu20-flannel-collection.yml
Normal file
@@ -0,0 +1,3 @@
|
||||
---
|
||||
# Kubespray settings
|
||||
kube_network_plugin: flannel
|
||||
18
tests/scripts/check_galaxy_version.sh
Executable file
18
tests/scripts/check_galaxy_version.sh
Executable file
@@ -0,0 +1,18 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
version_from_galaxy=$(grep "^version:" galaxy.yml | awk '{print $2}')
|
||||
version_from_docs=$(grep -P "^\s+version:\sv\d+\.\d+\.\d+" docs/ansible_collection.md | awk '{print $2}')
|
||||
|
||||
if [[ $KUBESPRAY_VERSION != "v${version_from_galaxy}" ]]
|
||||
then
|
||||
echo "Please update galaxy.yml version to match the KUBESPRAY_VERSION. Be sure to remove the \"v\" to adhere"
|
||||
echo "to semenatic versioning"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ $KUBESPRAY_VERSION != "${version_from_docs}" ]]
|
||||
then
|
||||
echo "Please update the documentation for Ansible collections under docs/ansible_collection.md to reflect the KUBESPRAY_VERSION"
|
||||
exit 1
|
||||
fi
|
||||
@@ -78,6 +78,39 @@ if [ "${RECOVER_CONTROL_PLANE_TEST}" != "false" ]; then
|
||||
ansible-playbook ${ANSIBLE_LOG_LEVEL} -e @${CI_TEST_SETTING} -e @${CI_TEST_REGISTRY_MIRROR} -e @${CI_TEST_VARS} -e local_release_dir=${PWD}/downloads -e etcd_retries=10 --limit etcd,kube_control_plane:!fake_hosts recover-control-plane.yml
|
||||
fi
|
||||
|
||||
# Test collection build and install by installing our collection, emptying our repository, adding
|
||||
# cluster.yml, reset.yml, and remote-node.yml files that simply point to our collection's playbooks, and then
|
||||
# running the same tests as before
|
||||
if [[ "${CI_JOB_NAME}" =~ "collection" ]]; then
|
||||
# Build and install collection
|
||||
ansible-galaxy collection build
|
||||
ansible-galaxy collection install kubernetes_sigs-kubespray-$(grep "^version:" galaxy.yml | awk '{print $2}').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 -maxdepth 1 ! -name tests -exec rm -rfv {} \;
|
||||
|
||||
# Write cluster.yml
|
||||
cat > cluster.yml <<EOF
|
||||
- name: Install Kubernetes
|
||||
ansible.builtin.import_playbook: kubernetes_sigs.kubespray.cluster
|
||||
EOF
|
||||
|
||||
# Write reset.yml
|
||||
cat > reset.yml <<EOF
|
||||
- name: Remove Kubernetes
|
||||
ansible.builtin.import_playbook: kubernetes_sigs.kubespray.reset
|
||||
EOF
|
||||
|
||||
# Write remove-node.yml
|
||||
cat > remove-node.yml <<EOF
|
||||
- name: Remove node from Kubernetes
|
||||
ansible.builtin.import_playbook: kubernetes_sigs.kubespray.remote-node
|
||||
EOF
|
||||
|
||||
fi
|
||||
|
||||
# Tests Cases
|
||||
## Test Master API
|
||||
ansible-playbook --limit "all:!fake_hosts" -e @${CI_TEST_VARS} ${CI_TEST_ADDITIONAL_VARS} tests/testcases/010_check-apiserver.yml $ANSIBLE_LOG_LEVEL
|
||||
|
||||
Reference in New Issue
Block a user