-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathplaybook.yml
113 lines (95 loc) · 2.58 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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
---
- name: run the playbook tasks for Vagrant provisioning
hosts: all
connection: local
tasks:
- name: apt upgrade (this may take a while)
apt:
upgrade: safe
become: true
- name: ensure prerequisite packages are installed (this may take a while)
apt:
name:
- curl
- docker.io
- python-pip
become: true
- name: python prerequisite modules
pip:
name: "{{ modules }}"
become: yes
vars:
modules:
- docker
- name: Check if docker-compose is already installed
stat:
path: /usr/bin/docker-compose
register: stat_docker_compose
- name: install docker-compose
shell: 'curl -L https://github.com/docker/compose/releases/download/1.14.0/docker-compose-`uname -s`-`uname -m` > /usr/bin/docker-compose'
become: yes
when: stat_docker_compose.stat.exists == False
- name: set permissions for docker-compose
file:
path: /usr/bin/docker-compose
mode: "+x"
become: yes
- name: Check if docker daemon.json configuration file exists
stat:
path: /etc/docker/daemon.json
register: daemon_json
- name: Turn off docker so we can update DNS if needed
service:
name: docker
state: stopped
become: yes
when: daemon_json.stat.exists == False
- name: Update docker DNS configuration
copy:
dest: /etc/docker/daemon.json
content: |
{
"dns": ["8.8.8.8", "8.8.4.4"]
}
become: yes
when: daemon_json.stat.exists == False
- name: Make sure docker service is running
service:
name: docker
state: started
enabled: yes
become: yes
- name: Create Samurai Dojo target service descriptor
copy:
dest: /etc/systemd/system/wtf-dojo.service
content: |
[Unit]
Description=dojo-basic and dojo-scavenger target service
After=docker.service
Requires=docker.service
[Service]
Type=simple
WorkingDirectory=/vagrant
ExecStart=/usr/bin/docker-compose up
[Install]
WantedBy=multi-user.target
mode: 0744
become: yes
- name: Start Samurai-Dojo targets
service:
name: wtf-dojo.service
state: started
enabled: yes
become: yes
- name: Wait for dojo-basic to be available
wait_for:
port: 30080
sleep: 10
delay: 1
timeout: 120
- name: Reset dojo-basic DB
uri:
url: http://localhost:30080/reset-db.php
- name: Output location of hosts for dev.
debug:
msg: "Basic: http://localhost:30080 Scavenger: http://localhost:31080"