diff --git a/examples/README.md b/examples/README.md index aa1b5ecb12e2..81e37c591a11 100644 --- a/examples/README.md +++ b/examples/README.md @@ -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) diff --git a/examples/ansible.yaml b/examples/ansible.yaml new file mode 100644 index 000000000000..b0aca136dab1 --- /dev/null +++ b/examples/ansible.yaml @@ -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 diff --git a/examples/ansible/README.md b/examples/ansible/README.md new file mode 100644 index 000000000000..32aa6e261efa --- /dev/null +++ b/examples/ansible/README.md @@ -0,0 +1,9 @@ +# Ansible + +Playbook example from: + + + +Template example from: + + diff --git a/examples/ansible/playbook.yaml b/examples/ansible/playbook.yaml new file mode 100644 index 000000000000..ca42abb8001c --- /dev/null +++ b/examples/ansible/playbook.yaml @@ -0,0 +1,11 @@ +- name: My first play + hosts: all + tasks: + - name: Ping my hosts + ansible.builtin.ping: + + - name: Print message + ansible.builtin.debug: + msg: Hello world + roles: + - hostname diff --git a/examples/ansible/roles/hostname/tasks/main.yaml b/examples/ansible/roles/hostname/tasks/main.yaml new file mode 100644 index 000000000000..93319a802f9f --- /dev/null +++ b/examples/ansible/roles/hostname/tasks/main.yaml @@ -0,0 +1,5 @@ +--- +- name: write hostname using jinja2 + ansible.builtin.template: + src: templates/test.j2 + dest: /tmp/hostname diff --git a/examples/ansible/roles/hostname/templates/test.j2 b/examples/ansible/roles/hostname/templates/test.j2 new file mode 100644 index 000000000000..f7ac13743c76 --- /dev/null +++ b/examples/ansible/roles/hostname/templates/test.j2 @@ -0,0 +1 @@ +My name is {{ ansible_facts['hostname'] }}