This repository has been archived by the owner on Aug 31, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
/
docker.yaml
120 lines (108 loc) · 3.67 KB
/
docker.yaml
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
114
115
116
117
118
119
---
- hosts: all
remote_user: root
###gather_facts: no
vars:
# set information about your beaker instance
beaker_server: "localhost"
beaker_user: ""
beaker_pass: ""
# following options it isn't needed change
homedir: "/var/www/greentea"
django_settings: "tttt.settings.production"
elasticsearch: "elasticsearch.docker"
greentea_host: "greentea.docker"
db_host: "postgresql.docker"
db_pass: "default_pass"
db_version: 9.5
environment:
DJANGO_SETTINGS_MODULE: "{{ django_settings }}"
tasks:
- name: "Test Docker service"
command: "service docker status"
- name: "Create storages for docker"
shell: |
mkdir -p {{ homedir }}/{{ item }}
chcon -Rt svirt_sandbox_file_t {{ homedir }}/{{ item }}
with_items:
- static
- storage
- pgsql/data
- elasticsearch/data/
- name: "Update docker images"
command: docker pull {{ item }}
with_items:
- pajinek/greentea
- elasticsearch:2
- postgres:{{ db_version }}
tags:
- install
- update
- name: "List of existed versions of elasticsearch"
shell: docker ps -aq -f "name={{elasticsearch}}" | wc -l
register: eslist
tags:
- install
- update
- debug: var=eslist.stdout_lines
## Elasticseach instance ###
# only one instance of elastic search can be created
- name: "Stop running version of elasticsearch"
shell: |
docker stop "{{elasticsearch}}"
docker rename "{{elasticsearch}}" "{{elasticsearch}}.{{eslist.stdout}}"
when: eslist.stdout|int > 0
tags:
- install
- name: "Create new Elasticsearch in Docker"
shell: |
docker run -d -p 9200:9200 -p 9300:9300 -v "{{ homedir }}/elasticsearch/data/":"/usr/share/elasticsearch/data/:Z" --name "{{elasticsearch}}" -h "{{elasticsearch}}" elasticsearch:2
tags:
- install
- elasticserach
## Postgresql 9.5 ###
- name: "Create Postgresql in Docker"
shell: |
docker start "{{ db_host }}" || true
docker ps | grep "{{ db_host }}" ||
docker run -d --name "{{ db_host }}" -h "{{ db_host }}" -p 5432:5432 \
-e POSTGRES_PASSWORD={{ db_pass }} \
-v /var/lib/postgresql/data:/var/lib/postgresql/data:Z \
postgres:{{ db_version }}
tags:
- install
- update
- name: "List of existed versions of Greentea"
shell: docker ps -aq -f "name={{greentea_host}}" | wc -l
register: gtlist
tags:
- only-greentea
# only one instance of greentea can be created
- name: "Switch to newer image of Greentea"
shell: |
docker stop "{{greentea_host}}" || true
docker rename "{{greentea_host}}" "{{greentea_host}}.{{gtlist.stdout}}" || true
tags:
- install
- only-greentea
when: gtlist.stdout|int > 0
## GreenTea instance ###
- name: "Run Greentea in Docker"
shell: |
chown 1000:1000 -R {{homedir}}
docker run -d --name {{ greentea_host }} -h {{ greentea_host }} \
--link {{ db_host }}:{{ db_host }} -p 80:8000 \
--restart=always \
-e POSTGRES_PASSWORD={{ db_pass }} \
-e POSTGRES_SERVER={{ db_host }} \
-e BEAKER_SERVER={{ beaker_server}} \
-e BEAKER_USER={{ beaker_user}} \
-e BEAKER_PASS={{ beaker_pass}} \
-v {{homedir}}/static:/data/greentea/tttt/static:Z \
-v {{homedir}}/storage:/data/greentea/storage:Z \
pajinek/greentea
tags:
- install
- update
- only-greentea
...