init
This commit is contained in:
17
molecule/default/converge.yml
Normal file
17
molecule/default/converge.yml
Normal file
@@ -0,0 +1,17 @@
|
||||
---
|
||||
- name: Converge - apply podman role
|
||||
hosts: all
|
||||
become: true
|
||||
vars:
|
||||
podman_install_from_repo: true
|
||||
podman_packages:
|
||||
- podman
|
||||
podman_configure_registries: true
|
||||
podman_configure_storage: true
|
||||
podman_configure_policy: true
|
||||
podman_enable_socket: false
|
||||
podman_enable_api_service: false
|
||||
podman_policy_default_type: "insecureAcceptAnything"
|
||||
podman_policy_trusted_registries: []
|
||||
roles:
|
||||
- name: podman
|
||||
30
molecule/default/molecule.yml
Normal file
30
molecule/default/molecule.yml
Normal file
@@ -0,0 +1,30 @@
|
||||
---
|
||||
dependency:
|
||||
name: galaxy
|
||||
driver:
|
||||
name: podman
|
||||
platform_defaults: &platform_defaults
|
||||
tmpfs:
|
||||
- /tmp
|
||||
- /run/lock
|
||||
volumes:
|
||||
- /sys/fs/cgroup:/sys/fs/cgroup:ro
|
||||
command: /lib/systemd/systemd
|
||||
platforms:
|
||||
- name: debian-bullseye
|
||||
image: docker.io/jrei/systemd-debian:12
|
||||
<<: *platform_defaults
|
||||
- name: debian-bullseye
|
||||
image: docker.io/jrei/systemd-debian:13
|
||||
<<: *platform_defaults
|
||||
|
||||
provisioner:
|
||||
name: ansible
|
||||
lint:
|
||||
name: ansible-lint
|
||||
verifier:
|
||||
name: ansible
|
||||
lint: |
|
||||
set -e
|
||||
ansible-lint .
|
||||
yamllint .
|
||||
28
molecule/default/prepare.yml
Normal file
28
molecule/default/prepare.yml
Normal file
@@ -0,0 +1,28 @@
|
||||
---
|
||||
- name: Prepare instance for podman role testing
|
||||
hosts: all
|
||||
become: true
|
||||
tasks:
|
||||
- name: Ensure apt cache is up-to-date
|
||||
ansible.builtin.apt:
|
||||
update_cache: yes
|
||||
cache_valid_time: 3600
|
||||
|
||||
- name: Install prerequisites used by the role/tests
|
||||
ansible.builtin.apt:
|
||||
name:
|
||||
- apt-transport-https
|
||||
- ca-certificates
|
||||
- gnupg
|
||||
- lsb-release
|
||||
- curl
|
||||
state: present
|
||||
update_cache: false
|
||||
|
||||
- name: Install python3-venv and python3-pip for testinfra
|
||||
ansible.builtin.apt:
|
||||
name:
|
||||
- python3-pip
|
||||
- python3-venv
|
||||
state: present
|
||||
update_cache: false
|
||||
3
molecule/default/requirements.yml
Normal file
3
molecule/default/requirements.yml
Normal file
@@ -0,0 +1,3 @@
|
||||
---
|
||||
collections:
|
||||
- name: containers.podman
|
||||
BIN
molecule/default/tests/__pycache__/test_default.cpython-313.pyc
Normal file
BIN
molecule/default/tests/__pycache__/test_default.cpython-313.pyc
Normal file
Binary file not shown.
34
molecule/default/tests/test_default.py
Normal file
34
molecule/default/tests/test_default.py
Normal file
@@ -0,0 +1,34 @@
|
||||
import os
|
||||
import testinfra.utils.ansible_runner
|
||||
|
||||
# Get hosts from Testinfra inventory created by Molecule
|
||||
testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
|
||||
os.environ.get('MOLECULE_INVENTORY_FILE')
|
||||
).get_hosts('all')
|
||||
|
||||
|
||||
def test_podman_package_installed(host):
|
||||
pkg = host.package("podman")
|
||||
assert pkg.is_installed, "podman package should be installed"
|
||||
|
||||
|
||||
def test_podman_binary_executes(host):
|
||||
cmd = host.run("podman --version")
|
||||
assert cmd.rc == 0, f"podman not runnable: {cmd.stderr or cmd.stdout}"
|
||||
|
||||
|
||||
def test_containers_conf_exists(host):
|
||||
f = host.file("/etc/containers/registries.conf")
|
||||
assert f.exists, "/etc/containers/registries.conf should exist"
|
||||
|
||||
|
||||
def test_policy_json_exists(host):
|
||||
f = host.file("/etc/containers/policy.json")
|
||||
assert f.exists, "/etc/containers/policy.json should exist"
|
||||
|
||||
|
||||
def test_podman_config_file_valid_json(host):
|
||||
f = host.file("/etc/containers/policy.json")
|
||||
assert f.exists and f.size > 0
|
||||
cmd = host.run("python3 -c 'import json,sys;json.load(open(\"/etc/containers/policy.json\"))'")
|
||||
assert cmd.rc == 0, "policy.json should be valid JSON"
|
||||
Reference in New Issue
Block a user