Closed maciej-markowski closed 1 year ago
@CyberFox001 would like to look into?
@sshnaidm I can take look, but this week I'm very busy. I will try to find time.
Do we really want to make the Ansible module podman_generate_systemd
idempotent as its name is an imperative action ?
This Ansible module was made to reflect the podman command podman generate systemd
. Which is an imperative command. But maybe we need a podman_to_systemd_unit
Ansible module who is made from the Ansible user point of view, more than from the podman commands point of view.
Since podman 4.4.0 we have the introduction of Quadlet, a new systemd-generator that easily writes and maintains systemd services using Podman. Maybe it's time to make a new Ansible module that use Quadlet with podman >= 4.4.0 and podman generate systemd
command with podman <= 4.4.0.
It's just a thought, but I think we need to make a choice about it.
Quadlet seems like a good option for future. Probably this time it's fine to set no-header as a default? I don't see much sense to have it. Either way we can implement comparison without taking header into account: https://github.com/containers/ansible-podman-collections/blob/7c06ddec3b51bab66d6733ce6d78a29681246a02/plugins/modules/podman_generate_systemd.py#L453-L461
@maciej-markowski please test if #558 helps.
@sshnaidm tested. Works fine, thanks!
Is this a BUG REPORT or FEATURE REQUEST? (leave only one on its own line)
/kind bug
Description
containers.podman.podman_generate_systemd
by default includes the header with date into systemd service file. If the task is run again, service file gets recreated, despite no config changes - only thing that changed is that current date is not the same as written in config file. It is an idempotency issue, as this task usually comes with follow up tasks / handlers that stops the container and run it as systemd service, while configuration was not changed and container is already running as systemd service. Steps to reproduce the issue:Run the task that creates service file
Run the same task again.
Describe the results you received:
changed
result with every run.Describe the results you expected:
changed
result after first run,OK
result with every next run without config changes.Additional information you deem important (e.g. issue happens only occasionally):
workaround: set
no_header: true
. Solution: multiple. Get rid of the header as default, remove date from the header, compare only actual content of service file ignoring the header...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
Additional environment details (AWS, VirtualBox, physical, etc.):