rewritten

This commit is contained in:
2025-11-06 19:49:11 +01:00
parent 0337e23d0c
commit 313064bd99

View File

@@ -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"
- 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`.