-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy.yml
48 lines (46 loc) · 1.42 KB
/
deploy.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
# Ansible playbook for deploying a Flask app
---
# Install system apt packages
- hosts: webservers
become: yes
become_method: sudo
tasks:
- name: update cache
apt: name=python-software-properties state=present update_cache=yes cache_valid_time=43200
- name: install packages
apt: name={{item}} state=installed
with_items:
- python-pip
- python3
- python3-pip
- python3-dev
- libmysqlclient-dev
- name: dev locale
action: command sudo update-locale LC_ALL=en_US.UTF-8
- name: set default locale
sudo: yes
lineinfile: dest=/etc/default/locale
regexp="LC_ALL"
line="LC_ALL=\"en_US.UTF-8\""
# Install the app, note: don't do these tasks with become sudo
- hosts: webservers
tasks:
- name: clone repo
git:
repo: 'https://github.com/{{ github_user }}/{{ app_name }}.git'
dest: /home/{{ ansible_ssh_user }}/{{ app_name }}
update: yes
- name: Installing python libraries using requirements file
become_method: sudo
shell: pip install -r /home/{{ ansible_ssh_user }}/{{ app_name }}/requirements.txt
# Configure app systemd service and nginx
- hosts: webservers
become: yes
become_method: sudo
tasks:
- name: template systemd service config
template:
src: .service
dest: /etc/systemd/system/{{ app_name }}.service
- name: start systemd app service
systemd: name={{ app_name }}.service state=restarted enabled=yes