Convert CRI-O molecule to ansible verifier

This commit is contained in:
Max Gautier
2025-06-13 16:18:58 +02:00
parent 3f26203ed0
commit 68c4ee23cb
7 changed files with 57 additions and 39 deletions

View File

@@ -0,0 +1,17 @@
{
"cniVersion": "0.2.0",
"name": "mynet",
"type": "bridge",
"bridge": "cni0",
"isGateway": true,
"ipMasq": true,
"ipam": {
"type": "host-local",
"subnet": "172.19.0.0/24",
"routes": [
{
"dst": "0.0.0.0/0"
}
]
}
}

View File

@@ -0,0 +1,10 @@
{
"metadata": {
"name": "{{ container_runtime }}1"
},
"image": {
"image": "quay.io/kubespray/hello-world:latest"
},
"log_path": "{{ container_runtime }}1.0.log",
"linux": {}
}

View File

@@ -0,0 +1,10 @@
{
"metadata": {
"name": "{{ container_runtime }}1",
"namespace": "default",
"attempt": 1,
"uid": "hdishd83djaidwnduwk28bcsb"
},
"linux": {},
"log_directory": "/tmp"
}

View File

@@ -0,0 +1,42 @@
---
- name: Test container runtime
hosts: all
gather_facts: false
become: true
roles:
- role: ../../kubespray_defaults
tasks:
- name: Copy test container files
template:
src: "{{ item }}.j2"
dest: "/tmp/{{ item }}"
owner: root
mode: "0644"
loop:
- container.json
- sandbox.json
- name: Check running a container with runtime {{ container_runtime }}
block:
- name: Run container
command:
argv:
- "{{ bin_dir }}/crictl"
- run
- --with-pull
- --runtime
- "{{ container_runtime }}"
- /tmp/container.json
- /tmp/sandbox.json
- name: Check log file
slurp:
src: "/tmp/{{ container_runtime }}1.0.log"
register: log_file
failed_when: >
log_file is failed or
'Hello from Docker' not in (log_file.content | b64decode)
rescue:
- name: Display container manager config on error
command: "{{ bin_dir }}/crictl info"
- name: Check container manager logs
command: journalctl -u {{ container_manager }}
failed_when: true