1
0
Fork 0
mirror of https://github.com/containers/ansible-podman-collections.git synced 2026-02-04 07:11:49 +00:00

Add test for kube_play with image build

Signed-off-by: nishipy <goodisonev4@gmail.com>
This commit is contained in:
nishipy 2023-09-28 11:08:01 +09:00
parent 2a8aaf4522
commit c38d91f1a0
4 changed files with 81 additions and 0 deletions

View file

@ -0,0 +1,3 @@
FROM ubi8-init
RUN dnf -y install httpd; dnf -y clean all
RUN systemctl enable httpd.service

View file

@ -0,0 +1,22 @@
# Save the output of this file and use kubectl create -f to import
# it into Kubernetes.
#
# Created with podman-4.4.1
apiVersion: v1
kind: Pod
metadata:
annotations:
org.opencontainers.image.base.digest/buil-test: sha256:e08f47885d5794a7d8b6404e9db9b0c0a9fc6c633da3c3af0c355299
org.opencontainers.image.base.name/buil-test: registry.redhat.io/ubi8-init:latest
creationTimestamp: "2023-09-28T01:12:34Z"
labels:
app: buil-test-pod
name: buil-test-pod
spec:
containers:
- image: localhost/build-test:latest
name: buil-test
ports:
- containerPort: 80
hostPort: 8080

View file

@ -128,3 +128,9 @@
args:
apply:
become: true
- name: Test play kube with on-demand image build
include_tasks: play-with-build.yml
vars:
ansible_python_interpreter: "/usr/bin/python"

View file

@ -0,0 +1,50 @@
- name: Test play kube with on-demand image build
vars:
image_name: build-test
build_context_dir: /tmp/contextdir
kube_dir: /tmp
success_msg: "Successfully tagged localhost/{{ image_name }}:latest"
block:
- name: Make sure that "{{ image_name }}" image is absent
containers.podman.podman_image:
name: "{{ image_name }}"
state: absent
- name: Copy files to known place
copy:
src: kube-buil-test.yaml
dest: "{{ kube_dir }}/kube-buil-test.yaml"
remote_src: false
- name: Create context dir for build
file:
path: "{{ build_context_dir }}/{{ image_name }}"
state: directory
- name: Copy Containerfile for build
copy:
src: Containerfile
dest: "{{ build_context_dir }}/{{ image_name }}/Containerfile"
remote_src: false
- name: Play kube file with image build
containers.podman.podman_play:
kube_file: "{{ kube_dir }}/kube-buil-test.yaml"
build: true
context_dir: "{{ build_context_dir }}"
state: started
register: play_with_build
- name: Check if the result is changed
assert:
that:
- play_with_build is changed
- success_msg in play_with_build.stdout
always:
- name: Cleanup pods
containers.podman.podman_play:
kube_file: "{{ kube_dir }}/kube-buil-test.yaml"
state: absent