-
Notifications
You must be signed in to change notification settings - Fork 14
/
deploy.yml
52 lines (38 loc) · 1.22 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
49
50
51
52
---
- name: Prepare deployment
hosts: database-servers
user: root
vars:
db_dir: /tmp/db
tasks:
- name: Create a temporary directory for database migrations
file: dest={{ db_dir }} state=directory
- name: Create the database
mysql_db: name=ws state=present
register: db_create
- name: Copy initial schema
copy: src=app/db/initial.sql dest={{ db_dir }}/
when: db_create|changed
- name: Initialize database
mysql_db: name=ws state=import target={{ db_dir }}/initial.sql
when: db_create|changed
- name: Create a ws user
mysql_user: name=ws host={{ hostvars[item]["ansible_ssh_host"] }} password=""
priv=ws.*:SELECT state=present
with_items:
- '{{ groups["web-servers"] }}'
- name: Upload database migrations
copy: src=app/db/migrations.sql dest={{ db_dir }}/
- name: Run database migrations
mysql_db: name=ws state=import target={{ db_dir }}/migrations.sql
- name: Deploy the demo application
hosts: web-servers
user: root
vars_files:
- config.yml
tasks:
- name: Copy all php scripts to the web server
template: src={{ item }}
dest={{ webapp_dir }}/
owner=apache group=apache
with_fileglob: app/web/*