-
Notifications
You must be signed in to change notification settings - Fork 651
Add example of ansible provisioning with playbook #2676
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
minimumLimaVersion: "1.0.0" | ||
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/noble/release-20250313/ubuntu-24.04-server-cloudimg-amd64.img" | ||
arch: "x86_64" | ||
digest: "sha256:eacac65efe9e9bae0cbcb3f9d5c2b5e8c5313fa78a3bc401c3fb28b2d48cefc0" | ||
- location: "https://cloud-images.ubuntu.com/releases/noble/release-20250313/ubuntu-24.04-server-cloudimg-arm64.img" | ||
arch: "aarch64" | ||
digest: "sha256:103f31c5a5b7f031a60ce3555c8fbd56317fd8ffbaaa7e17002879e6157d546d" | ||
# Fallback to the latest release image. | ||
# Hint: run `limactl prune` to invalidate the cache | ||
- location: "https://cloud-images.ubuntu.com/releases/noble/release/ubuntu-24.04-server-cloudimg-amd64.img" | ||
arch: "x86_64" | ||
- location: "https://cloud-images.ubuntu.com/releases/noble/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 | ||
message: | | ||
To run `ansible` on the host (assumes ansible is installed), run the following commands: | ||
------ | ||
export ANSIBLE_INVENTORY="{{.Dir}}/ansible-inventory.yaml" | ||
# To see the inventory: `ansible-inventory --list --yaml` | ||
|
||
ansible all -m ping | ||
------ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
- name: write hostname using jinja2 | ||
ansible.builtin.template: | ||
src: templates/test.j2 | ||
dest: /tmp/hostname |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
My name is {{ ansible_facts['hostname'] }} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if we want to put non-lima yamls to the template store.
Maybe we should have a
examples/
directory?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't because they would be included in
limactl create --list-templates
, which would be confusing.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It needs to be next to the template, so that it can be referenced.
It could probably use the new feature for scripts:
base
setting #3072