-
Notifications
You must be signed in to change notification settings - Fork 0
/
create_app.yml
76 lines (56 loc) · 1.78 KB
/
create_app.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
---
- hosts: ansible-server
become: true
tasks:
- name: active release
include_vars: '{{ item }}'
with_items:
- active_release.yml
- name: load vars of release
include_vars: '{{ item }}'
with_items:
- releases/{{ release }}/all.yml
- name: copy Dockerfile
copy:
src: Dockerfile
dest: /root/Dockerfile
- name: create app dir
file:
path: /root/app
state: directory
- name: generate jinja2 app/app.py
template:
src: releases/{{ release }}/app.py.j2
dest: /root/app/app.py
- name: copy requirements.txt
copy:
src: releases/{{ release }}/requirements.txt
dest: /root/requirements.txt
- name: stop flaskapp containers
shell: docker stop $(docker ps --all|grep flaskapp | cut -d ' ' -f1)
ignore_errors: yes
- name: remove flaskapp containers
shell: docker rm $(docker ps --all|grep flaskapp | cut -d ' ' -f1)
ignore_errors: yes
# - name: remove a container
# docker_container:
# name: flaskapp-{{ version }}
# state: absent
- name: create docker image
shell: docker build -t docker-flask:latest .
- name: docker image prune
shell: docker image prune -f
- name: docker image list
shell: docker image list
register: docker_image_list_output
- name: docker image list
debug:
msg: '{{ docker_image_list_output.stdout_lines }}'
- name: run docker with the app
shell: docker run --name flaskapp-{{ version }} -d -v $PWD/app:/app -p 5000:5000 docker-flask:latest
- name: docker list
shell: docker ps --all
register: docker_list_output
- name: docker list
debug:
msg: '{{ docker_list_output.stdout_lines }}'