From 313064bd99d45dc1a879f071b30eacb3c84af486 Mon Sep 17 00:00:00 2001 From: Rene Mewissen Date: Thu, 6 Nov 2025 19:49:11 +0100 Subject: [PATCH] rewritten --- roles/podman/tasks/main.yml | 46 +++++++++++++------------------------ 1 file changed, 16 insertions(+), 30 deletions(-) diff --git a/roles/podman/tasks/main.yml b/roles/podman/tasks/main.yml index b65c1d3..529d516 100644 --- a/roles/podman/tasks/main.yml +++ b/roles/podman/tasks/main.yml @@ -49,33 +49,19 @@ owner: root group: root -- name: Run Portainer container with Podman - ansible.builtin.command: - cmd: > - podman run -d - --name {{ portainer_name }} - --restart=always - -p {{ portainer_edge_agent_port }}:8000 - -p {{ portainer_web_port }}:9443 - -p {{ portainer_legacy_port }}:9000 - -v /run/podman/podman.sock:/var/run/docker.sock # Map Podman socket to Docker socket path for Portainer compatibility - -v {{ portainer_data_path }}:/data - {{ portainer_image }} - creates: "{{ portainer_data_path }}/portainer.db" # Checks if the Portainer database file exists to ensure idempotency - warn: false # Suppresses the warning that the 'command' module is used for operations that should be idempotent - # Verbesserungsvorschlag: Für eine robustere Container-Verwaltung könnte das Modul - # `community.general.podman_container` verwendet werden, falls die `community.general`-Collection installiert ist. - # Beispiel: - # - name: Run Portainer container with Podman (using podman_container module) - # community.general.podman_container: - # name: "{{ portainer_name }}" - # image: "{{ portainer_image }}" - # state: started - # restart_policy: always - # ports: - # - "{{ portainer_edge_agent_port }}:8000" - # - "{{ portainer_web_port }}:9443" - # - "{{ portainer_legacy_port }}:9000" - # volume: - # - "/run/podman/podman.sock:/var/run/docker.sock" - # - "{{ portainer_data_path }}:/data" \ No newline at end of file +- name: Run Portainer container with Podman (using podman_container module) + community.general.podman_container: + name: "{{ portainer_name }}" + image: "{{ portainer_image }}" + state: started + restart_policy: always + ports: + - "{{ portainer_edge_agent_port }}:8000" + - "{{ portainer_web_port }}:9443" + - "{{ portainer_legacy_port }}:9000" + volume: + # Map Podman socket to Docker socket path for Portainer compatibility + - "/run/podman/podman.sock:/var/run/docker.sock" + - "{{ portainer_data_path }}:/data" + # This module is idempotent by nature and provides better state management. + # Ensure 'community.general' collection is installed with `ansible-galaxy collection install community.general`. \ No newline at end of file