infra-v1/applications/roles/base/tasks/containers.yml

35 lines
1015 B
YAML

---
# Installs Portainer or portainer agent for Docker management
- name: Deploy Portainer
community.docker.docker_container:
name: portainer
image: portainer/portainer-ce
restart_policy: always
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- portainer_data:/data
ports:
- 9000:9000
- 8000:8000
when: "'docker-main' in group_names"
- name: Deploy Portainer Agent
community.docker.docker_container:
name: portainer-agent
image: portainer/agent
restart_policy: always
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- /var/lib/docker/volumes:/var/lib/docker/volumes
when: "'docker-main' not in group_names"
# Install Watchtower to auto update containers. Checks every 4 hours
- name: Deploy Watchtower
community.docker.docker_container:
name: watchtower
image: containrrr/watchtower
restart_policy: always
command: --schedule "0 0 4 * * *"
volumes:
- /var/run/docker.sock:/var/run/docker.sock