mirror of
https://github.com/containers/ansible-podman-collections.git
synced 2026-02-04 07:11:49 +00:00
Add inventory plugins for buildah and podman (#963)
Add inventory plugins for buildah and podman, unit tests and functional CI tests. --------- Signed-off-by: Sagi Shnaidman <sshnaidm@redhat.com>
This commit is contained in:
parent
fb76891c50
commit
6ee2f3891b
57 changed files with 3856 additions and 8899 deletions
41
playbooks/examples/build_ai_env_with_ansible.yml
Normal file
41
playbooks/examples/build_ai_env_with_ansible.yml
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
---
|
||||
- name: Build a consistent AI dev environment image using Ansible and Buildah connection
|
||||
hosts: localhost
|
||||
gather_facts: false
|
||||
vars:
|
||||
base_image: "python:3.11-slim"
|
||||
image_name: "ai-dev-env:latest"
|
||||
workdir: "/workspace"
|
||||
tasks:
|
||||
- name: Start Buildah working container
|
||||
command: buildah from {{ base_image }}
|
||||
register: from_out
|
||||
|
||||
- set_fact:
|
||||
container_id: "{{ from_out.stdout | trim }}"
|
||||
|
||||
- name: Configure working directory
|
||||
command: buildah config --workingdir {{ workdir }} {{ container_id }}
|
||||
|
||||
- name: Add working container as dynamic host (Buildah connection)
|
||||
add_host:
|
||||
name: "buildcntr_{{ container_id }}"
|
||||
ansible_connection: containers.podman.buildah
|
||||
ansible_host: "{{ container_id }}"
|
||||
ansible_buildah_working_directory: "{{ workdir }}"
|
||||
|
||||
- name: Provision AI environment inside container using role
|
||||
import_role:
|
||||
name: ai-dev-env
|
||||
delegate_to: "buildcntr_{{ container_id }}"
|
||||
|
||||
- name: Set container metadata
|
||||
shell: |
|
||||
buildah config --env "JUPYTER_TOKEN=ansible" {{ container_id }}
|
||||
buildah config --port 8888 {{ container_id }}
|
||||
buildah config --cmd "jupyter lab --ip=0.0.0.0 --no-browser" {{ container_id }}
|
||||
|
||||
- name: Commit image
|
||||
command: buildah commit {{ container_id }} {{ image_name }}
|
||||
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue