ansible-role-docker-swarm/templates/portainer-agent-stack.yml.j2

89 lines
2.1 KiB
Django/Jinja

version: '3.8'
volumes:
portainer_server_data:
{% if docker_swarm_portainer_nfs_volume %}
driver: local
driver_opts:
type: {{ docker_swarm_portainer_nfs_type }}
# o: "nfsvers=4,addr=146.48.123.250,rw,nolock,soft"
o: "{{ docker_swarm_portainer_nfs_o }}"
device: "{{ docker_swarm_portainer_nfs_device }}"
{% endif %}
networks:
{% if docker_swarm_cluster_haproxy_install %}
{{ haproxy_docker_overlay_network }}:
external: true
{% endif %}
{{ docker_swarm_portainer_network }}:
services:
agent:
image: portainer/agent
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- /var/lib/docker/volumes:/var/lib/docker/volumes
deploy:
mode: global
placement:
constraints: [node.platform.os == linux]
networks:
- {{ docker_swarm_portainer_network }}
{% if docker_log_to_journal %}
logging:
driver: 'journald'
{% endif %}
portainer:
image: portainer/portainer-ce
command: -H tcp://tasks.agent:9001 --tlsskipverify
{% if not docker_swarm_cluster_haproxy_install %}
ports:
- target: 9443
published: 9443
protocol: tcp
mode: 'ingress'
- target: 9000
published: 9000
protocol: tcp
mode: 'ingress'
- target: 8000
published: 8000
protocol: tcp
mode: 'ingress'
{% endif %}
volumes:
- portainer_server_data:/data
networks:
- {{ docker_swarm_portainer_network }}
{% if docker_swarm_cluster_haproxy_install %}
- {{ haproxy_docker_overlay_network }}
{% endif %}
deploy:
mode: replicated
replicas: 1
{% if docker_swarm_cluster_haproxy_install %}
endpoint_mode: dnsrr
{% endif %}
restart_policy:
condition: on-failure
delay: 5s
max_attempts: 3
window: 120s
placement:
constraints:
- 'node.role == manager'
{% for constraint in docker_swarm_portainer_additional_constraints %}
- '{{ constraint }}'
{% endfor %}
{% if docker_log_to_journal %}
logging:
driver: 'journald'
{% endif %}