-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsite.yml
81 lines (71 loc) · 1.65 KB
/
site.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
75
76
77
78
79
80
81
# This is a "play"
- hosts: all
sudo: yes
tasks:
# This is a "task". "template" is a "module"
- name: Roll out the welcome mat
template: >
src=templates/motd
dest=/etc/motd
- hosts: web
sudo: yes
tasks:
- name: Install packages
apt: >
name={{ item }}
state=installed
with_items:
- apache2=2.2.22-1ubuntu1.6
- libapache2-mod-php5=5.3.10-1ubuntu3.11
- php5-mysql
notify:
- restart apache
- name: Deploy the application
copy: >
src=app/hello.php
dest=/var/www
handlers:
- name: restart apache
service: name=apache2 state=restarted
- hosts: database
sudo: yes
tasks:
- name: Install mysql
apt: >
name={{ item }}
state=installed
with_items:
- mysql-server=5.5.37-0ubuntu0.12.04.1
- mysql-client=5.5.37-0ubuntu0.12.04.1
- python-mysqldb
- name: Apply mysql configuration
copy: >
src=files/my.cnf
dest=/etc/mysql
notify:
- restart mysql
- name: Copy schema to be restored
copy: >
src=files/schema.sql
dest=/tmp
- name: Create database
mysql_db: >
name=hello
state=present
register: create_database
- name: Import schema
mysql_db: >
name=hello
state=import
target=/tmp/schema.sql
when: create_database.changed
- name: Create application user
mysql_user: >
name=app
host=%
password=secret
priv=*.*:ALL
state=present
handlers:
- name: restart mysql
service: name=mysql state=restarted