Add portainer compose file

This commit is contained in:
Jake Howard 2020-01-28 22:02:02 +00:00
parent c3959d43c6
commit d1e5f63efd
Signed by: jake
GPG key ID: 57AFB45680EDD477
3 changed files with 49 additions and 0 deletions

View file

@ -0,0 +1,16 @@
version: '3'
services:
portainer:
image: portainer/portainer
container_name: portainer
restart: unless-stopped
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- ./data:/data
labels:
- "traefik.enable=true"
- "traefik.http.routers.portainer.rule=Host(`portainer.jakehoward.tech`)"
- "traefik.http.routers.portainer.tls=true"
- "traefik.http.routers.portainer.tls.certresolver=le"
- "traefik.http.routers.portainer.middlewares=internal-only@file"

View file

@ -9,3 +9,6 @@
- name: Install watchtower
include: watchtower.yml
- name: Install portainer
include: portainer.yml

View file

@ -0,0 +1,30 @@
- name: Create portainer directory
file:
path: '/opt/portainer'
state: directory
owner: "{{ docker_user.name }}"
mode: "{{ docker_compose_directory_mask }}"
become: true
become_user: root
- name: Install portainer config
template:
src: files/portainer/docker-compose.yml
dest: "/opt/portainer/docker-compose.yml"
mode: "{{ docker_compose_file_mask }}"
owner: "{{ docker_user.name }}"
register: compose_file
become: true
become_user: root
- name: Cycle portainer container
docker_compose:
project_src: /opt/portainer
pull: true
remove_orphans: true
remove_volumes: true
state: "{{ item }}"
when: compose_file.changed
loop:
- absent
- present