From f59b361dec1cd699b88de90083eb8c80b57f4321 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anders=20F=20Bj=C3=B6rklund?= Date: Wed, 8 May 2024 19:40:11 +0200 Subject: [PATCH] Add an integration test for ansible provisioning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Anders F Björklund --- .github/workflows/test.yml | 4 ++++ hack/ansible-test.yaml | 6 ++++++ hack/test-templates.sh | 7 +++++++ hack/test-templates/test-misc.yaml | 4 ++++ 4 files changed, 21 insertions(+) create mode 100644 hack/ansible-test.yaml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 96f2c4f5d2e..240f6af07ae 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -242,6 +242,10 @@ jobs: sudo modprobe kvm # `sudo usermod -aG kvm $(whoami)` does not take an effect on GHA sudo chown $(whoami) /dev/kvm + - name: Install ansible-playbook + run: | + sudo apt-get install -y --no-install-recommends ansible + if: matrix.template == '../hack/test-templates/test-misc.yaml' - name: "Show cache" run: ./hack/debug-cache.sh - name: "Test" diff --git a/hack/ansible-test.yaml b/hack/ansible-test.yaml new file mode 100644 index 00000000000..255c7eca551 --- /dev/null +++ b/hack/ansible-test.yaml @@ -0,0 +1,6 @@ +- hosts: all + tasks: + - name: Create test file + file: + path: /tmp/ansible + state: touch diff --git a/hack/test-templates.sh b/hack/test-templates.sh index b1eadfc4349..5f6732d1fea 100755 --- a/hack/test-templates.sh +++ b/hack/test-templates.sh @@ -35,6 +35,7 @@ declare -A CHECKS=( ["disk"]="" ["user-v2"]="" ["mount-path-with-spaces"]="" + ["provision-ansible"]="" ) case "$NAME" in @@ -62,6 +63,7 @@ case "$NAME" in CHECKS["snapshot-online"]="1" CHECKS["snapshot-offline"]="1" CHECKS["mount-path-with-spaces"]="1" + CHECKS["provision-ansible"]="1" ;; "net-user-v2") CHECKS["port-forwards"]="" @@ -143,6 +145,11 @@ if [[ -n ${CHECKS["mount-path-with-spaces"]} ]]; then [ "$(limactl shell "$NAME" cat "/tmp/lima test dir with spaces/test file")" = "test file content" ] fi +if [[ -n ${CHECKS["provision-ansible"]} ]]; then + INFO 'Testing that /tmp/ansible was created successfully on provision' + limactl shell "$NAME" test -e /tmp/ansible +fi + INFO "Testing proxy settings are imported" got=$(limactl shell "$NAME" env | grep FTP_PROXY) # Expected: FTP_PROXY is set in addition to ftp_proxy, localhost is replaced diff --git a/hack/test-templates/test-misc.yaml b/hack/test-templates/test-misc.yaml index 35f74c8e7ec..2bf6cc8bd1a 100644 --- a/hack/test-templates/test-misc.yaml +++ b/hack/test-templates/test-misc.yaml @@ -26,6 +26,10 @@ mounts: - location: "/tmp/lima" writable: true +provision: +- mode: ansible + playbook: ./hack/ansible-test.yaml + # in order to use this example, you must first create the disk "data". run: # $ limactl disk create data --size 10G additionalDisks: