Skip to content

Instantly share code, notes, and snippets.

@DevopsVlogger
Last active September 4, 2020 09:26
Show Gist options
  • Save DevopsVlogger/76e8d80b6ff99d02d6b08aeb073625d6 to your computer and use it in GitHub Desktop.
Save DevopsVlogger/76e8d80b6ff99d02d6b08aeb073625d6 to your computer and use it in GitHub Desktop.
- name: Deploy a Web Application
hosts: db_and_webserver1, db_and_webserver2
tasks:
- name: Install dependencies
apt: name={{ item }} state=present
with_items:
- python
- python-setuptools
- python-dev
- build-essential
- python-pip
- python-mysqldb
- libmysqlclient-dev
- default-libmysqlclient-dev
- name: Install MySQL database
apt: name={{ item }} state=present
with_items:
- mysql-server
- mysql-client
- name: Start mysql service
command: service mysql start
- name: Create application database
mysql_db: name=employee_db state=present
- name: create databse user
mysql_user:
name: db_user
password: Passw0rd
priv: '*.*:ALL'
state: present
- name: install python dependencies
pip: name={{ item }} state=present
with_items:
- flask
- flask-mysql
- name: copy source code file app.py
copy: src=app.py dest=/opt/app.py
- name: start webserver
shell: FLASK_APP=/opt/app.py nohup flask run --host=0.0.0.0 &
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment