Skip to content

Commit 100be8b

Browse files
committed
Add example of ansible provisioning with playbook
Currently the playbook is relative to the current workdir, it should probably be relative to the lima.yaml instead. Signed-off-by: Anders F Björklund <anders.f.bjorklund@gmail.com>
1 parent 16fd466 commit 100be8b

File tree

6 files changed

+54
-0
lines changed

6 files changed

+54
-0
lines changed

examples/README.md

+3
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ Distro:
2929
- [`experimental/gentoo`](./experimental/gentoo.yaml): [experimental] Gentoo
3030
- [`experimental/opensuse-tumbleweed`](./experimental/opensuse-tumbleweed.yaml): [experimental] openSUSE Tumbleweed
3131

32+
Provisioning:
33+
- [`ansible`](./ansible.yaml): Ansible, using [playbook.yaml](./ansible/playbook.yaml)
34+
3235
Container engines:
3336
- [`apptainer`](./apptainer.yaml): Apptainer
3437
- [`apptainer-rootful`](./apptainer-rootful.yaml): Apptainer (rootful)

examples/ansible.yaml

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# This template requires Lima v0.7.0 or later.
2+
images:
3+
# Try to use release-yyyyMMdd image if available. Note that release-yyyyMMdd will be removed after several months.
4+
- location: "https://cloud-images.ubuntu.com/releases/24.04/release-20240821/ubuntu-24.04-server-cloudimg-amd64.img"
5+
arch: "x86_64"
6+
digest: "sha256:0e25ca6ee9f08ec5d4f9910054b66ae7163c6152e81a3e67689d89bd6e4dfa69"
7+
- location: "https://cloud-images.ubuntu.com/releases/24.04/release-20240821/ubuntu-24.04-server-cloudimg-arm64.img"
8+
arch: "aarch64"
9+
digest: "sha256:5ecac6447be66a164626744a87a27fd4e6c6606dc683e0a233870af63df4276a"
10+
# Fallback to the latest release image.
11+
# Hint: run `limactl prune` to invalidate the cache
12+
- location: "https://cloud-images.ubuntu.com/releases/24.04/release/ubuntu-24.04-server-cloudimg-amd64.img"
13+
arch: "x86_64"
14+
- location: "https://cloud-images.ubuntu.com/releases/24.04/release/ubuntu-24.04-server-cloudimg-arm64.img"
15+
arch: "aarch64"
16+
17+
mounts:
18+
- location: "~"
19+
- location: "/tmp/lima"
20+
writable: true
21+
22+
provision:
23+
- mode: ansible
24+
playbook: ./templates/ansible/playbook.yaml

examples/ansible/README.md

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Ansible
2+
3+
Playbook example from:
4+
5+
<https://docs.ansible.com/ansible/latest/getting_started/get_started_playbook.html>
6+
7+
Template example from:
8+
9+
<https://docs.ansible.com/ansible/latest/playbook_guide/playbooks_templating.html>

examples/ansible/playbook.yaml

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
- name: My first play
2+
hosts: all
3+
tasks:
4+
- name: Ping my hosts
5+
ansible.builtin.ping:
6+
7+
- name: Print message
8+
ansible.builtin.debug:
9+
msg: Hello world

examples/ansible/tasks/main.yaml

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
- name: Write hostname
3+
hosts: all
4+
tasks:
5+
- name: write hostname using jinja2
6+
ansible.builtin.template:
7+
src: templates/test.j2
8+
dest: /tmp/hostname

examples/ansible/templates/test.j2

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
My name is {{ ansible_facts['hostname'] }}

0 commit comments

Comments
 (0)