Add portainer compose file
This commit is contained in:
parent
c3959d43c6
commit
d1e5f63efd
3 changed files with 49 additions and 0 deletions
16
ansible/roles/docker/files/portainer/docker-compose.yml
Normal file
16
ansible/roles/docker/files/portainer/docker-compose.yml
Normal 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"
|
|
@ -9,3 +9,6 @@
|
||||||
|
|
||||||
- name: Install watchtower
|
- name: Install watchtower
|
||||||
include: watchtower.yml
|
include: watchtower.yml
|
||||||
|
|
||||||
|
- name: Install portainer
|
||||||
|
include: portainer.yml
|
||||||
|
|
30
ansible/roles/docker/tasks/portainer.yml
Normal file
30
ansible/roles/docker/tasks/portainer.yml
Normal 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
|
Loading…
Reference in a new issue