The module containers.podman.podman_container creates a change and therefore is not idempotent when creating a pod, attaching a container to it and creating a systemd service for that pod.
Steps to reproduce the issue:
Create a pod using containers.podman.podman_pod
Create and attach a container to the pod usin containers.podman.podman_container
Create and start a systemd service from the pod using containers.podman.podman_generate_systemd
Rerun steps 1-3
Describe the results you received:
Step 2 reports a change and tries to recreate the container. Because the pod_id_file is missing for the container.
Describe the results you expected:
No change and idempotency.
Additional information you deem important (e.g. issue happens only occasionally):
/
Version of the containers.podman collection:Either git commit if installed from git: git show --summaryOr version from ansible-galaxy if installed from galaxy: ansible-galaxy collection list | grep containers.podman
$ ansible-galaxy collection list | grep containers.podman
containers.podman 1.15.4
Package info (e.g. output of rpm -q podman or apt list podman):
$ apt list podman
Listing... Done
podman/stable,now 4.3.1+ds1-8+deb12u1 armhf [installed]
Playbok you run with ansible (e.g. content of playbook.yaml):
---
- hosts: all
tasks:
- name: Create Podman pod
containers.podman.podman_pod:
name: test
debug: true
# State options
state: created
recreate: false
# Infra container
infra_name: "test_infra"
- name: Create container
containers.podman.podman_container:
name: test_test
image: fedora
command: sleep infinity
pod: test
state: created
rm: true
ipc: shareable
log_driver: journald
log_level: info
log_opt:
tag: test_test
- name: Setup Systemd service for Podman pod test
containers.podman.podman_generate_systemd:
name: test
# Systemd options
dest: /etc/systemd/system
restart_policy: on-failure
restart_sec: 10
wants: []
after: []
# Nameing
pod_prefix: "pod"
container_prefix: "container"
separator: "_"
use_names: true # Use container name as Systemd service name
# Additional options for Podman
new: true # Create containers with Systemd unit file
no_header: true # Do not add header to Systemd unit file (no reload of Systemd daemon required)
- name: Set enable and mask Systemd service for Podman pod test
ansible.builtin.systemd:
name: "pod_test.service"
enabled: true
state: started
masked: false
daemon_reload: true
Command line and output of ansible run with high verbosity
Please NOTE: if you submit a bug about idempotency, run the playbook with --diff option, like:
/kind bug
Description
The module
containers.podman.podman_container
creates a change and therefore is not idempotent when creating a pod, attaching a container to it and creating a systemd service for that pod.Steps to reproduce the issue:
Create a pod using
containers.podman.podman_pod
Create and attach a container to the pod usin
containers.podman.podman_container
Create and start a systemd service from the pod using
containers.podman.podman_generate_systemd
Rerun steps 1-3
Describe the results you received: Step 2 reports a change and tries to recreate the container. Because the
pod_id_file
is missing for the container.Describe the results you expected: No change and idempotency.
Additional information you deem important (e.g. issue happens only occasionally): /
Version of the
containers.podman
collection: Either git commit if installed from git:git show --summary
Or version fromansible-galaxy
if installed from galaxy:ansible-galaxy collection list | grep containers.podman
Output of
ansible --version
:Output of
podman version
:Output of
podman info --debug
:Package info (e.g. output of
rpm -q podman
orapt list podman
):Playbok you run with ansible (e.g. content of
playbook.yaml
):Command line and output of ansible run with high verbosity
Please NOTE: if you submit a bug about idempotency, run the playbook with
--diff
option, like:ansible-playbook -i inventory --diff -vv playbook.yml --check
Additional environment details (AWS, VirtualBox, physical, etc.): /