Skip to content

Commit

Permalink
Add example of ansible provisioning with playbook
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
afbjorklund committed Oct 3, 2024
1 parent 16fd466 commit 100be8b
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 0 deletions.
3 changes: 3 additions & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ Distro:
- [`experimental/gentoo`](./experimental/gentoo.yaml): [experimental] Gentoo
- [`experimental/opensuse-tumbleweed`](./experimental/opensuse-tumbleweed.yaml): [experimental] openSUSE Tumbleweed

Provisioning:
- [`ansible`](./ansible.yaml): Ansible, using [playbook.yaml](./ansible/playbook.yaml)

Container engines:
- [`apptainer`](./apptainer.yaml): Apptainer
- [`apptainer-rootful`](./apptainer-rootful.yaml): Apptainer (rootful)
Expand Down
24 changes: 24 additions & 0 deletions examples/ansible.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# This template requires Lima v0.7.0 or later.
images:
# Try to use release-yyyyMMdd image if available. Note that release-yyyyMMdd will be removed after several months.
- location: "https://cloud-images.ubuntu.com/releases/24.04/release-20240821/ubuntu-24.04-server-cloudimg-amd64.img"
arch: "x86_64"
digest: "sha256:0e25ca6ee9f08ec5d4f9910054b66ae7163c6152e81a3e67689d89bd6e4dfa69"
- location: "https://cloud-images.ubuntu.com/releases/24.04/release-20240821/ubuntu-24.04-server-cloudimg-arm64.img"
arch: "aarch64"
digest: "sha256:5ecac6447be66a164626744a87a27fd4e6c6606dc683e0a233870af63df4276a"
# Fallback to the latest release image.
# Hint: run `limactl prune` to invalidate the cache
- location: "https://cloud-images.ubuntu.com/releases/24.04/release/ubuntu-24.04-server-cloudimg-amd64.img"
arch: "x86_64"
- location: "https://cloud-images.ubuntu.com/releases/24.04/release/ubuntu-24.04-server-cloudimg-arm64.img"
arch: "aarch64"

mounts:
- location: "~"
- location: "/tmp/lima"
writable: true

provision:
- mode: ansible
playbook: ./templates/ansible/playbook.yaml
9 changes: 9 additions & 0 deletions examples/ansible/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Ansible

Playbook example from:

<https://docs.ansible.com/ansible/latest/getting_started/get_started_playbook.html>

Template example from:

<https://docs.ansible.com/ansible/latest/playbook_guide/playbooks_templating.html>
9 changes: 9 additions & 0 deletions examples/ansible/playbook.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
- name: My first play
hosts: all
tasks:
- name: Ping my hosts
ansible.builtin.ping:

- name: Print message
ansible.builtin.debug:
msg: Hello world
8 changes: 8 additions & 0 deletions examples/ansible/tasks/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
- name: Write hostname
hosts: all
tasks:
- name: write hostname using jinja2
ansible.builtin.template:
src: templates/test.j2
dest: /tmp/hostname
1 change: 1 addition & 0 deletions examples/ansible/templates/test.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
My name is {{ ansible_facts['hostname'] }}

0 comments on commit 100be8b

Please sign in to comment.