rewritten
This commit is contained in:
@@ -49,33 +49,19 @@
|
|||||||
owner: root
|
owner: root
|
||||||
group: root
|
group: root
|
||||||
|
|
||||||
- name: Run Portainer container with Podman
|
- name: Run Portainer container with Podman (using podman_container module)
|
||||||
ansible.builtin.command:
|
community.general.podman_container:
|
||||||
cmd: >
|
name: "{{ portainer_name }}"
|
||||||
podman run -d
|
image: "{{ portainer_image }}"
|
||||||
--name {{ portainer_name }}
|
state: started
|
||||||
--restart=always
|
restart_policy: always
|
||||||
-p {{ portainer_edge_agent_port }}:8000
|
ports:
|
||||||
-p {{ portainer_web_port }}:9443
|
- "{{ portainer_edge_agent_port }}:8000"
|
||||||
-p {{ portainer_legacy_port }}:9000
|
- "{{ portainer_web_port }}:9443"
|
||||||
-v /run/podman/podman.sock:/var/run/docker.sock # Map Podman socket to Docker socket path for Portainer compatibility
|
- "{{ portainer_legacy_port }}:9000"
|
||||||
-v {{ portainer_data_path }}:/data
|
volume:
|
||||||
{{ portainer_image }}
|
# Map Podman socket to Docker socket path for Portainer compatibility
|
||||||
creates: "{{ portainer_data_path }}/portainer.db" # Checks if the Portainer database file exists to ensure idempotency
|
- "/run/podman/podman.sock:/var/run/docker.sock"
|
||||||
warn: false # Suppresses the warning that the 'command' module is used for operations that should be idempotent
|
- "{{ portainer_data_path }}:/data"
|
||||||
# Verbesserungsvorschlag: Für eine robustere Container-Verwaltung könnte das Modul
|
# This module is idempotent by nature and provides better state management.
|
||||||
# `community.general.podman_container` verwendet werden, falls die `community.general`-Collection installiert ist.
|
# Ensure 'community.general' collection is installed with `ansible-galaxy collection install community.general`.
|
||||||
# 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"
|
|
||||||
Reference in New Issue
Block a user