1
0
Fork 0
mirror of https://github.com/containers/ansible-podman-collections.git synced 2026-03-22 02:29:08 +00:00

Rewrite podman and buildah connections (#962)

* Rewrite podman and buildah connections

---------

Signed-off-by: Sagi Shnaidman <sshnaidm@redhat.com>
This commit is contained in:
Sergey 2025-09-11 20:35:09 +03:00 committed by GitHub
parent 237bc385b9
commit 991e461ea5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
38 changed files with 2966 additions and 344 deletions

View file

@ -0,0 +1,104 @@
#!/usr/bin/env bash
set -o pipefail
set -eux
# Enhanced Buildah Connection Plugin Tests
# Tests for new features and configuration options
# New requirement from ansible-core 2.14
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
export LANGUAGE=en_US.UTF-8
# Buildah storage configuration for compatibility
export STORAGE_OPTS="overlay.mount_program=/usr/bin/fuse-overlayfs"
function run_ansible {
${SUDO:-} ${ANSIBLECMD:-ansible-playbook} test_buildah_features.yml -i "test_connection.inventory" \
-e target_hosts="buildah_advanced" \
"$@"
}
function run_configuration_test {
local config_name="$1"
local extra_vars="$2"
echo "Testing configuration: $config_name"
${SUDO:-} ${ANSIBLECMD:-ansible-playbook} test_buildah_features.yml -i "test_connection.inventory" \
-e target_hosts="buildah_advanced" \
-e "$extra_vars" \
"$@"
}
echo "=== Running Enhanced Buildah Connection Tests ==="
# Create a container
${SUDO:-} buildah from --name=buildah-container python:3.10-alpine
# Test 1: Basic functionality with new features
echo "Test 1: Basic advanced features"
run_ansible "$@"
# Test 2: Mount detection disabled
echo "Test 2: Mount detection disabled"
run_configuration_test "mount_disabled" "ansible_buildah_mount_detection=false" "$@"
# Test 3: Different timeout settings
echo "Test 3: Short timeout"
run_configuration_test "short_timeout" "ansible_buildah_timeout=5" "$@"
# Test 4: Different retry settings
echo "Test 4: More retries"
run_configuration_test "more_retries" "ansible_buildah_retries=5" "$@"
# Test 5: Custom working directory
echo "Test 5: Custom working directory"
run_configuration_test "custom_workdir" "ansible_buildah_working_directory=/home" "$@"
# Test 6: Auto-commit enabled
echo "Test 6: Auto-commit enabled"
run_configuration_test "auto_commit" "ansible_buildah_auto_commit=true" "$@"
# Test 7: Custom environment variables
echo "Test 7: Custom environment variables"
run_configuration_test "custom_env" "ansible_buildah_extra_env={'CUSTOM_BUILD': 'value', 'DEBUG': 'true'}" "$@"
# Test 8: Verify plugin identification
echo "Test 8: Plugin identification verification"
ANSIBLE_VERBOSITY=4 run_ansible "$@" | tee check_log
${SUDO:-} grep -q "Using buildah connection from collection" check_log
${SUDO:-} rm -f check_log
# Test 9: Error handling with invalid executable
echo "Test 9: Error handling test"
set +o pipefail
ANSIBLE_BUILDAH_EXECUTABLE=fakebuildah run_ansible "$@" 2>&1 | grep "Could not find fakebuildah in PATH"
test_result=$?
set -o pipefail
if [ $test_result -eq 0 ]; then
echo "Error handling test passed"
else
echo "Error handling test failed - error message not found"
exit 1
fi
# Test 10: Performance test with multiple operations
echo "Test 10: Performance test"
time run_ansible "$@" > /tmp/buildah_performance_test.log 2>&1
echo "Performance test completed - check /tmp/buildah_performance_test.log for timing"
echo "Test 11: Missing buildah container exec"
${SUDO:-} ${ANSIBLECMD:-ansible-playbook} test_missing_container_exec.yml -i "test_connection.inventory"
echo "Test 12: Buildah removed between exec"
${SUDO:-} ${ANSIBLECMD:-ansible-playbook} test_removed_between_exec.yml -i "test_connection.inventory"
echo "Test 13: Buildah put/fetch on missing container"
${SUDO:-} ${ANSIBLECMD:-ansible-playbook} test_missing_container_put_fetch.yml -i "test_connection.inventory"
echo "Test 14: Buildah stdin on missing container"
${SUDO:-} ${ANSIBLECMD:-ansible-playbook} test_missing_container_stdin.yml -i "test_connection.inventory"
echo "=== All Enhanced Buildah Connection Tests Completed Successfully ==="

View file

@ -0,0 +1,209 @@
---
# Advanced Buildah Connection Plugin Tests
# Tests new features and configuration options in the rewritten plugin
- hosts: "{{ target_hosts }}"
gather_facts: false
serial: 1
tasks:
### Test basic buildah functionality
- name: Test basic command execution
raw: echo "Testing enhanced buildah connection"
register: basic_test
- name: Verify basic command output
assert:
that:
- "'Testing enhanced buildah connection' in basic_test.stdout"
### Test environment variables injection
- name: Test environment variable injection
raw: printenv BUILD_VAR
register: env_test
vars:
ansible_buildah_extra_env:
BUILD_VAR: "build_value"
CONTAINER_TYPE: "buildah"
- name: Verify environment variables were set
assert:
that:
- "'build_value' in env_test.stdout"
### Test timeout configuration
- name: Test command timeout with quick command
raw: sh -c 'sleep 0.1 && echo "Quick buildah command completed"'
register: quick_command
vars:
ansible_buildah_timeout: 10
- name: Verify quick command succeeded
assert:
that:
- "'Quick buildah command completed' in quick_command.stdout"
### Test working directory functionality
- name: Test working directory setting
raw: pwd
register: workdir_test
vars:
ansible_buildah_working_directory: "/tmp"
- name: Create test file in working directory
raw: sh -c 'echo "buildah test content" > test_buildah_file.txt'
vars:
ansible_buildah_working_directory: "/tmp"
- name: Verify file was created in working directory
raw: cat /tmp/test_buildah_file.txt
register: file_content
- name: Verify file content
assert:
that:
- "'buildah test content' in file_content.stdout"
### Test file operations with mount detection
- name: Create test file locally
copy:
content: "Buildah test file content with mount detection"
dest: /tmp/buildah_test_file
delegate_to: localhost
- name: Copy file with mount detection enabled
copy:
src: /tmp/buildah_test_file
dest: /tmp/remote_buildah_test
vars:
ansible_buildah_mount_detection: true
- name: Verify file was copied
raw: cat /tmp/remote_buildah_test
register: mount_test
- name: Verify file content
assert:
that:
- "'Buildah test file content with mount detection' in mount_test.stdout"
### Test different user contexts
- name: Test command execution with root user
raw: whoami
register: user_test
vars:
ansible_user: root
- name: Verify user context (may be root or container default)
debug:
msg: "Current user: {{ user_test.stdout.strip() }}"
### Test retry mechanism
- name: Test retry mechanism with valid command
raw: echo "Buildah retry test successful"
register: retry_test
vars:
ansible_buildah_retries: 2
- name: Verify retry test succeeded
assert:
that:
- "'Buildah retry test successful' in retry_test.stdout"
### Test container building scenarios
- name: Install package in container (basic build operation)
raw: sh -c 'which apk >/dev/null && apk add --no-cache curl || true'
register: package_install
ignore_errors: true
- name: Test that package installation succeeded
debug:
msg: "Package installation completed: {{ package_install.rc }}"
when: package_install is defined
### Test Unicode and special characters
- name: Test unicode command output
raw: echo "Buildah测试中文字符"
register: unicode_test
- name: Verify unicode output
assert:
that:
- "'Buildah测试中文字符' in unicode_test.stdout"
### Test connection robustness with multiple commands
- name: Test connection robustness with multiple commands
raw: echo "Buildah command {{ item }}"
register: multiple_commands
loop: [1, 2, 3, 4, 5]
- name: Verify all commands executed successfully
assert:
that:
- multiple_commands.results | length == 5
- "'Buildah command 1' in multiple_commands.results[0].stdout"
- "'Buildah command 5' in multiple_commands.results[4].stdout"
### Test complex shell operations
- name: Test complex shell command with pipes
raw: sh -c 'echo "buildah test data" | wc -w'
register: complex_shell
- name: Verify complex shell operation
assert:
that:
- complex_shell.stdout.strip() | int == 3
### Test container inspection capabilities
- name: Test container info retrieval
raw: echo $HOSTNAME
register: hostname_test
- name: Verify hostname is set
assert:
that:
- hostname_test.stdout.strip() | length > 0
### Test file system operations
- name: Create directory structure
raw: mkdir -p /tmp/buildah_test/dir1 /tmp/buildah_test/dir2
- name: Create files in directory structure
raw: sh -c 'echo "{{ item }}" > /tmp/buildah_test/dir{{ item }}/file{{ item }}.txt'
loop: [1, 2]
- name: List created files
raw: sh -c 'find /tmp/buildah_test -name "*.txt" | sort'
register: file_list
- name: Verify file structure
assert:
that:
- "'file1.txt' in file_list.stdout"
- "'file2.txt' in file_list.stdout"
### Cleanup
- name: Clean up test files in container
raw: rm -rf /tmp/buildah_test /tmp/remote_buildah_test /tmp/test_buildah_file.txt
ignore_errors: true
- name: Clean up local test files
file:
path: /tmp/buildah_test_file
state: absent
delegate_to: localhost
ignore_errors: true

View file

@ -0,0 +1,22 @@
[buildah_advanced]
buildah-container
[buildah_advanced:vars]
ansible_host=buildah-container
ansible_connection=containers.podman.buildah
ansible_ssh_pipelining=true
# Test different configurations
# Basic configuration with timeout
ansible_buildah_timeout=30
ansible_buildah_retries=3
# Mount detection enabled by default
ansible_buildah_mount_detection=true
ansible_buildah_ignore_mount_errors=true
# Additional environment variables
ansible_buildah_extra_env={"BUILDAH_TESTING": "true", "BUILD_MODE": "test"}
# Auto-commit disabled for testing
ansible_buildah_auto_commit=false

View file

@ -0,0 +1,25 @@
---
- name: Define a missing Buildah host dynamically
hosts: localhost
gather_facts: false
tasks:
- name: Add a missing buildah container host
add_host:
name: missing_buildah_host
ansible_connection: containers.podman.buildah
ansible_host: ci-missing-buildah
- name: Exec on non-existent buildah container should raise ContainerNotFoundError
hosts: missing_buildah_host
gather_facts: false
tasks:
- name: Try exec on missing container
raw: echo hi
register: r
ignore_errors: true
- name: Assert ContainerNotFoundError surfaced
assert:
that:
- r is failed
- r.msg is search("Container .* not found")

View file

@ -0,0 +1,29 @@
---
- name: Buildah put/fetch on missing container
hosts: localhost
gather_facts: false
vars:
ansible_connection: containers.podman.buildah
ansible_host: ci-missing-buildah
tasks:
- name: Put should fail
copy:
content: abc
dest: /root/a.txt
register: r_put
ignore_errors: true
- name: Fetch should fail
fetch:
src: /etc/os-release
dest: /tmp/osr
flat: true
register: r_fetch
ignore_errors: true
- assert:
that:
- r_put is failed
- r_put.msg is search("Container .* not found")
- r_fetch is failed
- r_fetch.msg is search("Container .* not found")

View file

@ -0,0 +1,17 @@
---
- name: Buildah stdin path on missing container
hosts: localhost
gather_facts: false
vars:
ansible_connection: containers.podman.buildah
ansible_host: ci-missing-buildah
tasks:
- name: Cat with stdin should raise ContainerNotFoundError
raw: cat -n
register: r
ignore_errors: true
- assert:
that:
- r is failed
- r.msg is search("Container .* not found")

View file

@ -0,0 +1,32 @@
---
- name: Buildah container removed between tasks
hosts: localhost
gather_facts: false
vars:
wk: ci-bu-wk
tasks:
- name: Create working container
shell: buildah from --name {{ wk }} alpine:latest
- name: First exec via buildah connection
vars:
ansible_connection: containers.podman.buildah
ansible_host: "{{ wk }}"
raw: uname -a
- name: Remove working container
shell: buildah rm -f {{ wk }}
changed_when: true
- name: Second exec should raise ContainerNotFoundError
vars:
ansible_connection: containers.podman.buildah
ansible_host: "{{ wk }}"
raw: echo later
register: r
ignore_errors: true
- assert:
that:
- r is failed
- r.msg is search("Container .* not found")

View file

@ -19,7 +19,7 @@ ANSIBLE_VERBOSITY=4 ANSIBLE_REMOTE_TMP="/tmp" ANSIBLE_REMOTE_USER="1000" run_ans
${SUDO:-} grep -q "Using podman connection from collection" check_log
${SUDO:-} rm -f check_log
set +o pipefail
ANSIBLE_PODMAN_EXECUTABLE=fakepodman run_ansible "$@" 2>&1 | grep "fakepodman command not found in PATH"
ANSIBLE_PODMAN_EXECUTABLE=fakepodman run_ansible "$@" 2>&1 | grep "Could not find fakepodman in PATH"
set -o pipefail
ANSIBLE_PODMAN_EXECUTABLE=fakepodman run_ansible "$@" && {
echo "Playbook with fakepodman should fail!"

View file

@ -0,0 +1,92 @@
#!/usr/bin/env bash
set -o pipefail
set -eux
# Enhanced Podman Connection Plugin Tests
# Tests for new features and configuration options
function run_ansible {
${SUDO:-} ${ANSIBLECMD:-ansible-playbook} test_advanced_features.yml -i "test_connection.inventory" \
-e target_hosts="podman_advanced" \
"$@"
}
function run_configuration_test {
local config_name="$1"
local extra_vars="$2"
echo "Testing configuration: $config_name"
${SUDO:-} ${ANSIBLECMD:-ansible-playbook} test_advanced_features.yml -i "test_connection.inventory" \
-e target_hosts="podman_advanced" \
-e "$extra_vars" \
"$@"
}
echo "=== Running Enhanced Podman Connection Tests ==="
# Create a container
${SUDO} podman run -d --name "podman-container" python:3.10-alpine sleep 1d
# Test 1: Basic functionality with new features
echo "Test 1: Basic advanced features"
run_ansible "$@"
# Test 2: Mount detection disabled
echo "Test 2: Mount detection disabled"
run_configuration_test "mount_disabled" "ansible_podman_mount_detection=false" "$@"
# Test 3: Different timeout settings
echo "Test 3: Short timeout"
run_configuration_test "short_timeout" "ansible_podman_timeout=5" "$@"
# Test 4: Different retry settings
echo "Test 4: More retries"
run_configuration_test "more_retries" "ansible_podman_retries=5" "$@"
# Test 5: Different user context
echo "Test 5: Root user context"
run_configuration_test "root_user" "ansible_user=root" "$@"
# Test 6: Custom environment variables
echo "Test 6: Custom environment variables"
run_configuration_test "custom_env" "ansible_podman_extra_env={'CUSTOM_TEST': 'value', 'DEBUG': 'true'}" "$@"
# Test 7: Verify plugin identification
echo "Test 7: Plugin identification verification"
ANSIBLE_VERBOSITY=4 run_ansible "$@" | tee check_log
${SUDO:-} grep -q "Using podman connection from collection" check_log
${SUDO:-} rm -f check_log
# Test 8: Error handling with invalid executable
echo "Test 8: Error handling test"
set +o pipefail
ANSIBLE_PODMAN_EXECUTABLE=fakepodman run_ansible "$@" 2>&1 | grep "Could not find fakepodman in PATH"
test_result=$?
set -o pipefail
if [ $test_result -eq 0 ]; then
echo "Error handling test passed"
else
echo "Error handling test failed - error message not found"
exit 1
fi
# Test 9: Performance test with multiple operations
echo "Test 9: Performance test"
time run_ansible "$@" > /tmp/performance_test.log 2>&1
echo "Performance test completed - check /tmp/performance_test.log for timing"
echo "Test 10: Missing container exec"
${SUDO:-} ${ANSIBLECMD:-ansible-playbook} test_missing_container_exec.yml -i "test_connection.inventory"
echo "Test 11: Removed between exec"
${SUDO:-} ${ANSIBLECMD:-ansible-playbook} test_removed_between_exec.yml -i "test_connection.inventory"
echo "Test 12: Missing container put"
${SUDO:-} ${ANSIBLECMD:-ansible-playbook} test_missing_container_put.yml -i "test_connection.inventory"
echo "Test 13: Missing container fetch"
${SUDO:-} ${ANSIBLECMD:-ansible-playbook} test_missing_container_fetch.yml -i "test_connection.inventory"
echo "=== All Enhanced Podman Connection Tests Completed Successfully ==="

View file

@ -0,0 +1,248 @@
---
# Advanced Podman Connection Plugin Tests
# Tests new features and configuration options in the rewritten plugin
- hosts: "{{ target_hosts }}"
gather_facts: false
serial: 1
tasks:
### Test new configuration options
- name: Test basic command execution
raw: echo "Testing enhanced podman connection"
register: basic_test
- name: Verify basic command output
assert:
that:
- "'Testing enhanced podman connection' in basic_test.stdout"
### Test environment variables injection
- name: Test environment variable injection
raw: printenv TEST_VAR
register: env_test
vars:
ansible_podman_extra_env:
TEST_VAR: "custom_value"
ANOTHER_VAR: "another_value"
- name: Verify environment variables were set
assert:
that:
- "'custom_value' in env_test.stdout"
### Test timeout configuration
- name: Test command timeout with quick command
raw: sh -c 'sleep 0.1 && echo "Quick command completed"'
register: quick_command
vars:
ansible_podman_timeout: 5
- name: Verify quick command succeeded
assert:
that:
- "'Quick command completed' in quick_command.stdout"
### Test retry mechanism with valid command
- name: Test retry mechanism with initially failing but eventually succeeding command
raw: echo "Retry test successful"
register: retry_test
vars:
ansible_podman_retries: 2
- name: Verify retry test succeeded
assert:
that:
- "'Retry test successful' in retry_test.stdout"
### Test file operations with mount detection
- name: Create test file locally
copy:
content: "Test file content with mount detection enabled"
dest: /tmp/test_mount_file
delegate_to: localhost
- name: Copy file with mount detection enabled
copy:
src: /tmp/test_mount_file
dest: /tmp/remote_mount_test
vars:
ansible_podman_mount_detection: true
- name: Verify file was copied
raw: cat /tmp/remote_mount_test
register: mount_test
- name: Verify file content
assert:
that:
- "'Test file content with mount detection enabled' in mount_test.stdout"
- name: Fetch file with mount detection
fetch:
src: /tmp/remote_mount_test
dest: /tmp/fetched_mount_test
flat: true
vars:
ansible_podman_mount_detection: true
- name: Verify fetched file content
command:
cmd: cat /tmp/fetched_mount_test
register: fetched_content
delegate_to: localhost
- name: Verify fetched file content is correct
assert:
that:
- "'Test file content with mount detection enabled' in fetched_content.stdout"
### Test file operations with mount detection disabled
- name: Copy file with mount detection disabled
copy:
src: /tmp/test_mount_file
dest: /tmp/remote_no_mount_test
vars:
ansible_podman_mount_detection: false
- name: Verify file was copied without mount
raw: cat /tmp/remote_no_mount_test
register: no_mount_test
- name: Verify file content without mount
assert:
that:
- "'Test file content with mount detection enabled' in no_mount_test.stdout"
### Test user specification
- name: Test command execution with specific user
raw: whoami
register: user_test
vars:
ansible_user: root
- name: Verify user context
assert:
that:
- "'root' in user_test.stdout"
### Test large file transfer
- name: Create large test file locally
command:
cmd: head -c 1M /dev/zero
register: large_file_content
delegate_to: localhost
- name: Write large file locally
copy:
content: "{{ large_file_content.stdout }}"
dest: /tmp/large_test_file
delegate_to: localhost
- name: Copy large file to container
copy:
src: /tmp/large_test_file
dest: /tmp/remote_large_file
- name: Verify large file size
raw: wc -c /tmp/remote_large_file | cut -d' ' -f1
register: large_file_size
- name: Verify large file was copied correctly
assert:
that:
- large_file_size.stdout | int >= 1000000
### Test Unicode and special characters
- name: Test unicode command output
raw: echo "测试中文字符"
register: unicode_test
- name: Verify unicode output
assert:
that:
- "'测试中文字符' in unicode_test.stdout"
- name: Create unicode filename test
copy:
content: "Unicode filename test content"
dest: "/tmp/测试文件.txt"
- name: Verify unicode file was created
raw: cat "/tmp/测试文件.txt"
register: unicode_file_test
- name: Verify unicode file content
assert:
that:
- "'Unicode filename test content' in unicode_file_test.stdout"
### Test connection recovery and error handling
- name: Test connection robustness with multiple commands
raw: echo "Command {{ item }}"
register: multiple_commands
loop: [1, 2, 3, 4, 5]
- name: Verify all commands executed successfully
assert:
that:
- multiple_commands.results | length == 5
- "'Command 1' in multiple_commands.results[0].stdout"
- "'Command 5' in multiple_commands.results[4].stdout"
### Test complex shell operations
- name: Test complex shell command with pipes and redirects
raw: sh -c 'echo "test data" | wc -c | tr -d "\n"'
register: complex_shell
- name: Verify complex shell operation
assert:
that:
- complex_shell.stdout | int == 10
### Test working directory
- name: Test working directory commands
raw: pwd
register: pwd_test
- name: Create directory and test relative path
raw: sh -c 'mkdir -p /tmp/test_workdir && cd /tmp/test_workdir && pwd'
register: workdir_test
- name: Verify working directory operations
assert:
that:
- "'/tmp/test_workdir' in workdir_test.stdout"
### Cleanup
- name: Clean up test files
raw: rm -f /tmp/remote_mount_test /tmp/remote_no_mount_test /tmp/remote_large_file /tmp/测试文件.txt
ignore_errors: true
- name: Clean up test directory
raw: rm -rf /tmp/test_workdir
ignore_errors: true
- name: Clean up local test files
file:
path: "{{ item }}"
state: absent
loop:
- /tmp/test_mount_file
- /tmp/fetched_mount_test
- /tmp/large_test_file
delegate_to: localhost
ignore_errors: true

View file

@ -0,0 +1,22 @@
[podman_advanced]
podman-container
[podman_advanced:vars]
ansible_host=podman-container
ansible_connection=containers.podman.podman
ansible_python_interpreter=/usr/local/bin/python
# Test different configurations
# Basic configuration with timeout
ansible_podman_timeout=30
ansible_podman_retries=3
# Mount detection enabled by default
ansible_podman_mount_detection=true
ansible_podman_ignore_mount_errors=true
# Additional environment variables
ansible_podman_extra_env={"TESTING": "true", "PLUGIN_VERSION": "2.0"}
# Connection caching and performance
ansible_podman_timeout=15

View file

@ -0,0 +1,25 @@
---
- name: Define a missing Podman host dynamically
hosts: localhost
gather_facts: false
tasks:
- name: Add a missing container host
add_host:
name: missing_podman_host
ansible_connection: containers.podman.podman
ansible_host: ci-missing-podman
- name: Exec on non-existent container should raise ContainerNotFoundError
hosts: missing_podman_host
gather_facts: false
tasks:
- name: Try exec on missing container
raw: id -u
register: r
ignore_errors: true
- name: Assert ContainerNotFoundError surfaced
assert:
that:
- r is failed
- r.msg is search("Container .* not found")

View file

@ -0,0 +1,21 @@
---
- name: Fetch from missing Podman container
hosts: localhost
gather_facts: false
vars:
ansible_connection: containers.podman.podman
ansible_host: ci-missing-podman
tasks:
- name: Fetch should raise ContainerNotFoundError
fetch:
src: /etc/os-release
dest: /tmp/os-release
flat: true
register: r
ignore_errors: true
- name: Assert ContainerNotFoundError surfaced
assert:
that:
- r is failed
- r.msg is search("Container .* not found")

View file

@ -0,0 +1,26 @@
---
- name: Put file to missing Podman container
hosts: localhost
gather_facts: false
vars:
ansible_connection: containers.podman.podman
ansible_host: ci-missing-podman
tasks:
- name: Create temp file on controller
copy:
content: podman-put-test
dest: /tmp/podman-put-test.txt
delegate_to: localhost
- name: Put file should raise ContainerNotFoundError
copy:
src: /tmp/podman-put-test.txt
dest: /root/put-here.txt
register: r
ignore_errors: true
- name: Assert ContainerNotFoundError surfaced
assert:
that:
- r is failed
- r.msg is search("Container .* not found")

View file

@ -0,0 +1,26 @@
---
- name: Removed between exec for Podman
hosts: podman_advanced
gather_facts: false
vars:
ansible_connection: containers.podman.podman
tasks:
- name: First exec works
raw: uname -s
- name: Remove this container from host
delegate_to: localhost
become: false
shell: podman rm -f {{ inventory_hostname }}
changed_when: true
- name: Second exec should fail with ContainerNotFoundError
raw: echo hello
register: r
ignore_errors: true
- name: Assert ContainerNotFoundError surfaced
assert:
that:
- r is failed
- r.msg is search("Container .* not found")