forked from jonpugh/vansible
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplaybook.yml
187 lines (151 loc) · 4.73 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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
##
# Attempt at a common set of core tags for php web development.
#
---
- hosts: default
user: root
vars_files:
- vars.global.yml
- vars.project.yml
tasks:
##
# Apt package installation of required software.
#
- name: Packages | Install required packages.
apt: pkg={{ item }} state=installed update_cache=yes
with_items: packages
##
# 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
##
# PHP Setup.
#
- name: PHP | Configuration file, php.ini
template:
src=templates/etc-php5-apache2-php-ini.j2
dest=/etc/php5/apache2/php.ini
- name: APC | Cache configuration file, apc.ini
template:
src=templates/etc-php5-conf-d-apc-ini.j2
dest=/etc/php5/apache2/conf.d/apc.ini
- name: PHP | Enable required modules
command: php5enmod mcrypt
##
# MySQL database setup.
#
- name: MySQL | Configuration file, my.cnf
template:
src=templates/etc-mysql-my-cnf.j2
dest=/etc/mysql/my.cnf
- name: MySQL | Check if MySQL was secured.
stat: path=/var/mysql-secured
register: mysqlsecured
- name: Install MySQL Securely
include: ./tasks/mysql-secure.yml
when: not mysqlsecured.stat.exists
- name: Setup | Install Composer
shell: curl -sS https://getcomposer.org/installer | php; mv composer.phar /usr/local/bin/composer
args:
creates: /usr/local/bin/composer
- name: Setup | Prepare composer directory
file:
path=/usr/share/composer
state=directory
- name: Setup | Install Drush
shell: composer global require drush/drush:6.* -d /usr/share/composer; /usr/share/composer/vendor/bin/drush
args:
creates: /usr/share/composer/vendor/bin/drush
- name: Setup | Add composer bin to path
command: sed -i '1i export PATH="/usr/share/composer/vendor/bin:$PATH"' /etc/bash.bashrc
##
# Apache2 setup.
#
- name: Apache | Enable some required modules
command: a2enmod rewrite vhost_alias ssl
- name: Apache | Configuration file for our site
template:
src=templates/etc-apache2-sites-available-devserver.j2
dest=/etc/apache2/sites-available/devserver.conf
notify:
- restart apache
- name: Apache | Disable the default site
command: a2dissite 000-default
- name: Apache | Enable our new site
command: a2ensite devserver
- name: SSH Keys | Save authorized_keys for local user to vagrant user
authorized_key: user=vagrant key="{{ authorized_keys }}"
##
# Restart services
#
- name: Restart Apache
service:
name=apache2
state=started
- name: Restart MySQL
service:
name=mysql
state=started
##
# Final Drupal Configuraiton
#
- name: Drupal | Create database user
mysql_user:
user={{ project }}
password={{ project }}
priv=*.*:ALL,GRANT
state=present
- name: Drupal | Create database
mysql_db:
db={{ project }}
state=present
- name: Drupal | Configuration folder, sites/{{ server_hostname }}
file:
path=/var/www/{{ project }}/sites/{{ server_hostname }}
state=directory
- name: Drupal | Configuration file, settings.php
template:
src=templates/settings-php.j2
dest=/var/www/{{ project }}/sites/{{ server_hostname }}/settings.php
mode=644
- name: Drupal | Create files folder
file:
path=/var/www/{{ project }}/sites/default/files
state=directory
- name: Drush | Create .drush folder
file:
path=/home/vagrant/.drush
owner=vagrant
group=vagrant
state=directory
- name: Drush | Create site alias on guest.
template:
src=templates/drush-alias-drushrc-php.j2
dest=/home/vagrant/.drush/{{ project }}.vagrant.alias.drushrc.php
- name: Drush | Create drushrc file on guest.
template:
src=templates/drushrc-php.j2
dest=/home/vagrant/.drush/drushrc.php
- name: Solr | Backup Solr config files.
shell: cp -rf /etc/solr/conf /etc/solr/conf.bak
- name: Solr | Setup Solr config files.
shell: cp -rf /var/www/{{ project }}/{{ path_to_solr_conf }}/* /etc/solr/conf
notify:
- restart tomcat
handlers:
- name: restart apache
service: >
name=apache2
state=restarted
- name: restart tomcat
service: >
name=tomcat6
state=restarted