forked from rael9/learninglocker-vagrant
-
Notifications
You must be signed in to change notification settings - Fork 0
/
playbook.yml
155 lines (129 loc) · 3.93 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
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
##
# Set up a local Learning Locker instance
#
---
- hosts: default
user: root
vars_files:
- vars.global.yml
- vars.project.yml
- vars.secret.yml
tasks:
##
# Set Hostname
#
- hostname: name={{ server_hostname }}
##
# Message of the day explaining server is under control of Ansible.
#
- name: General | Setting message of the day.
template:
src=templates/motd.j2
dest=/etc/update-motd.d/95-ansible
mode=755
##
# Apt package installation of required software.
#
- name: Packages | Set up required PPAs
apt_repository: repo={{ item }}
with_items: "{{ ppas }}"
- name: Packages | Get mongo keys
apt_key: keyserver=keyserver.ubuntu.com id=7F0CEB10
- name: Packages | Set the mongo repo
apt_repository: repo='deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen'
- name: Packages | Install required packages
apt: pkg={{ item }} state=installed update_cache=yes
with_items: "{{ packages }}"
- name: Packages | Upgrade
apt: upgrade=yes autoremove=yes
##
# Install composer
#
- name: Composer | Download Composer installer
get_url:
url: https://getcomposer.org/installer
dest: /tmp/composer-installer.php
mode: 0755
- name: Composer | Install composer
shell: php5.6 /tmp/composer-installer.php --install-dir=/usr/local/bin --filename=composer creates=/usr/local/bin/composer
##
# Configure Postfix
#
- name: Postfix | Configure postfix server
template:
src=templates/etc-postfix-main-cf.j2
dest=/etc/postfix/main.cf
##
# Add user to mongo
#
- name: Mongo | Create user creation JS
template:
src=templates/home-vagrant-mongo-user-js.j2
dest=/home/vagrant/mongo-user.js
- name: Mongo | Create mongo user
command: /usr/bin/mongo /home/vagrant/mongo-user.js
##
# Restart services
#
- name: Restart nginx
service:
name=nginx
state=started
##
# Fix nodejs alias
#
- name: NodeJS | Fix a nodejs alias issue
file:
src=/usr/bin/nodejs
dest=/usr/bin/node
state=link
##
# Install bower
#
- name: Bower | Install bower
npm:
name=bower
global=yes
##
# Install learninglocker
#
- name: LearningLocker | Set up Github OAuth key
command: composer config -g github-oauth.github.com {{ github_token }}
when: github_token != "false"
- name: LearningLocker | Install Learning Locker
command: composer create-project learninglocker/learninglocker learninglocker "{{ learninglocker_version }}" chdir=/var/www/
- name: LearningLocker | Set the storage to writable
file:
owner=www-data
group=www-data
state=directory
recurse=yes
path=/var/www/learninglocker/app/storage
- name: LearningLocker | Set app configuration
template:
src=templates/var-www-learninglocker-app-config-app-php.j2
dest=/var/www/learninglocker/app/config/app.php
- name: LearningLocker | Set database configuration
template:
src=templates/var-www-learninglocker-app-config-database-php.j2
dest=/var/www/learninglocker/app/config/database.php
- name: LearningLocker | Set mail configuration
template:
src=templates/var-www-learninglocker-app-config-mail-php.j2
dest=/var/www/learninglocker/app/config/mail.php
- name: LearningLocker | migrate
command: php5.6 artisan migrate chdir=/var/www/learninglocker
##
# nginx setup
#
- name: nginx | Configuration file for our site
template:
src=templates/etc-nginx-sites-available-default.j2
dest=/etc/nginx/sites-available/default
notify:
- restart nginx
handlers:
- name: restart nginx
service: >
name=nginx
state=restarted