Skip to content

Commit f59b361

Browse files
committed
Add an integration test for ansible provisioning
Signed-off-by: Anders F Björklund <[email protected]>
1 parent 45ede80 commit f59b361

File tree

4 files changed

+21
-0
lines changed

4 files changed

+21
-0
lines changed

.github/workflows/test.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,10 @@ jobs:
242242
sudo modprobe kvm
243243
# `sudo usermod -aG kvm $(whoami)` does not take an effect on GHA
244244
sudo chown $(whoami) /dev/kvm
245+
- name: Install ansible-playbook
246+
run: |
247+
sudo apt-get install -y --no-install-recommends ansible
248+
if: matrix.template == '../hack/test-templates/test-misc.yaml'
245249
- name: "Show cache"
246250
run: ./hack/debug-cache.sh
247251
- name: "Test"

hack/ansible-test.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
- hosts: all
2+
tasks:
3+
- name: Create test file
4+
file:
5+
path: /tmp/ansible
6+
state: touch

hack/test-templates.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ declare -A CHECKS=(
3535
["disk"]=""
3636
["user-v2"]=""
3737
["mount-path-with-spaces"]=""
38+
["provision-ansible"]=""
3839
)
3940

4041
case "$NAME" in
@@ -62,6 +63,7 @@ case "$NAME" in
6263
CHECKS["snapshot-online"]="1"
6364
CHECKS["snapshot-offline"]="1"
6465
CHECKS["mount-path-with-spaces"]="1"
66+
CHECKS["provision-ansible"]="1"
6567
;;
6668
"net-user-v2")
6769
CHECKS["port-forwards"]=""
@@ -143,6 +145,11 @@ if [[ -n ${CHECKS["mount-path-with-spaces"]} ]]; then
143145
[ "$(limactl shell "$NAME" cat "/tmp/lima test dir with spaces/test file")" = "test file content" ]
144146
fi
145147

148+
if [[ -n ${CHECKS["provision-ansible"]} ]]; then
149+
INFO 'Testing that /tmp/ansible was created successfully on provision'
150+
limactl shell "$NAME" test -e /tmp/ansible
151+
fi
152+
146153
INFO "Testing proxy settings are imported"
147154
got=$(limactl shell "$NAME" env | grep FTP_PROXY)
148155
# Expected: FTP_PROXY is set in addition to ftp_proxy, localhost is replaced

hack/test-templates/test-misc.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ mounts:
2626
- location: "/tmp/lima"
2727
writable: true
2828

29+
provision:
30+
- mode: ansible
31+
playbook: ./hack/ansible-test.yaml
32+
2933
# in order to use this example, you must first create the disk "data". run:
3034
# $ limactl disk create data --size 10G
3135
additionalDisks:

0 commit comments

Comments
 (0)