forked from jtreminio/docker-bootstrap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
playbook.yml
79 lines (66 loc) · 2.09 KB
/
playbook.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
---
- hosts: all
vars_files:
- defaults/main.yml
- vars.yml
tasks:
- name: Check if Docker installed
stat:
path: /usr/bin/docker
register: docker
- block:
- name: Add docker repo requirements
package:
name: "{{ item }}"
state: present
with_items:
- apt-transport-https
- ca-certificates
- curl
- software-properties-common
- name: Install Docker
script: files/get-docker.sh
when: docker.stat.exists != true
- name: Install Docker Compose
get_url:
url: https://github.com/docker/compose/releases/download/1.24.0/docker-compose-Linux-x86_64
dest: /usr/local/bin/docker-compose
mode: "+x"
- block:
- name: Configure firewall
ufw:
rule: allow
port: "{{ item }}"
with_items: "{{ ufw_allow_ports }}"
- name: Enable firewall
ufw:
state: enabled
when: add_firewall_rules
- name: Copy docker-compose
copy:
src: files/docker-compose.yml
dest: /opt/
- name: Ensure Let's Encrypt datafile exists
file:
path: /root/acme.json
owner: root
group: root
mode: 0600
state: touch
changed_when: false
# - name: Install Traefik, Watchtower and Portainer
- name: Install Traefik and Watchtower
command: docker-compose up -d
args:
chdir: /opt/
environment:
COMPOSE_PROJECT_NAME: traefik
LE_EMAIL: "{{ lookup('env', 'LE_EMAIL') }}"
PORTAINER_ADMIN_PASS: "{{ lookup('env', 'PORTAINER_ADMIN_PASS') }}"
# HOST_DNS: "{{ lookup('env', 'HOST_DNS') }}"
# TRAEFIK_ADMIN_PASS: "{{ lookup('env', 'TRAEFIK_ADMIN_PASS') }}"
# TRAEFIK_DASHBOARD_PATH: "{{ lookup('env', 'TRAEFIK_DASHBOARD_PATH') }}"
# PORTAINER_ADMIN_PASS: "{{ lookup('env', 'PORTAINER_ADMIN_PASS') }}"
# PORTAINER_DASHBOARD_PATH: "{{ lookup('env', 'PORTAINER_DASHBOARD_PATH') }}"
register: dc_changed
changed_when: "'up-to-date' not in dc_changed.stderr"