Skip to content

Commit 0d4c8d7

Browse files
committed
ansible - basic playbook
1 parent 9700e8d commit 0d4c8d7

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

ansible/latest_java_testbed.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
- hosts: localhost
3+
become: yes
4+
tasks:
5+
- name: Install Podman if not present
6+
apt:
7+
name: podman
8+
state: present
9+
update_cache: yes
10+
11+
- name: Pull the latest OpenJDK image using Podman
12+
ansible.builtin.command:
13+
cmd: podman pull docker.io/library/openjdk:latest
14+
register: podman_pull_result
15+
16+
- name: Ensure the image is pulled
17+
debug:
18+
msg: "Pulled image: {{ podman_pull_result.stdout }}"
19+
20+
- name: Run Java container with Podman and mount the test-code directory
21+
ansible.builtin.command:
22+
cmd: podman run -d --name java_test_container -v /home/user/test-code:/usr/src/myapp docker.io/library/openjdk:latest sleep infinity
23+
register: podman_run_result
24+
25+
- name: Ensure the container is running
26+
debug:
27+
msg: "Container running: {{ podman_run_result.stdout }}"
28+
29+
- name: Display running Podman containers
30+
ansible.builtin.command:
31+
cmd: podman ps
32+

0 commit comments

Comments
 (0)