Closed SvenVD closed 1 week ago
@SvenVD can you please paste a task you run? And would be great to see a log with running -vvvv
If I'm right and you set explicitly env: {}
in task, then it explains this behavior. But I don't understand why to set env: {}
and what is the reasoning behind this.
The task is
- name: podman_rootless | Configure and download {{ podman_rootless_container_image }} container to run under user {{ podman_rootless_user }}
containers.podman.podman_container:
name: "{{ podman_rootless_hostname }}"
image: "{{ podman_rootless_container_image }}"
#We will start it with the generated systemd file
state: present
ipc: "private"
#We do not need to force recreating all the time
#recreate: yes
ports: "{{ podman_rootless_ports }}"
hostname: "{{ podman_rootless_hostname }}"
env: "{{ podman_rootless_env }}"
volume: "{{ podman_rootless_volume }}"
userns: "{{ podman_rootless_userns }}"
#https://docs.podman.io/en/latest/markdown/podman-generate-systemd.1.html
generate_systemd:
path: /home/{{ podman_rootless_user }}/.config/systemd/user
restart_policy: on-failure
time: 120
names: true
become_user: "{{ podman_rootless_user }}"
register: podman_rootless_configure_and_download_result
and it and other tasks in the role gets called by
- name: app_containerx | manage container
include_role:
name: podman
tasks_from: rootless_container
vars:
podman_rootless_user: "user"
... and so on
podman_rootless_env is optional in the latter and not passed in this example, but in defaults/main.yml we set it to podman_rootless_env: {} if it is not overwritten by the include_role vars.
In these cases it's better to use env: "{{ podman_rootless_env | default(omit, true) }}"
And this setting will be omitted when you pass empty value - []
, ''
, {}
Every run a change is detected and the rootless container is restarted
A variant of https://github.com/containers/ansible-podman-collections/issues/686