forked from deraviyam/ansible-webapp
-
Notifications
You must be signed in to change notification settings - Fork 7
/
playbook.yml
49 lines (41 loc) · 1.26 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
- name: Deploy a web application
hosts: db_and_web_server1,db_and_web_server2
tasks:
- name: Install all required dependencies
raw: sudo apt-get install "{{ item }}"
with_items:
- python
- python-setuptools
- python-dev
- build-essential
- python-pip
- name: Install MYSQL database
raw: sudo apt-get install "{{ item }}"
with_items:
- mysql-server
- mysql-client
- name: Start MYSQL Service
service:
name: mysql
state: started
enabled: yes
- name: Create Application database
mysql_db: name=employee_db state=present
- name: Create database User
mysql_user:
name: db_user
password: Passw0rd
priv: '*.*:ALL'
state: present
host: '%'
- name: Install Python Flask Dependency
pip:
name: "{{ item }}"
state: present
with_items:
- flask
- flask-mysql
- name: Copy Source code
copy: src=/opt/app.py dest=/opt/app.py
- name: Start web server
shell: FLASK_APP=app.py nohup flask run --host=0.0.0.0 &