forked from jonpugh/vansible
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplaybook.yml
158 lines (131 loc) · 4.46 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
##
# Attempt at a common set of core tags for php web development.
#
---
- hosts: default
user: root
vars_files:
- settings.global.yml
- settings.project.yml
tasks:
##
# Apt package installation of required software.
#
- name: Packages | Install required packages.
action: apt pkg={{ item }} state=installed update_cache=yes
tags: common
with_items:
- php5
- apache2
- mysql-server
- mysql-client
- php5-mysql
- php-apc
- php5-xmlrpc
- php5-curl
- php5-gd
- sendmail
- unzip
- python-mysqldb
- vim
- solr-tomcat
##
# Set Hostname
#
- hostname: name={{ server_hostname }}
##
# Message of the day explaining server is under control of Ansible.
#
- name: General | Setting message of the day.
action: template src=templates/motd.j2 dest=/etc/update-motd.d/95-ansible mode=755
tags: common
##
# PHP Setup.
#
- name: PHP | Configuration file, php.ini
action: template src=templates/etc-php5-apache2-php-ini.j2 dest=/etc/php5/apache2/php.ini
tags: common
- name: APC | Cache configuration file, apc.ini
action: template src=templates/etc-php5-conf-d-apc-ini.j2 dest=/etc/php5/conf.d/apc.ini
tags: common
##
# MySQL database setup.
#
- name: MySQL | Configuration file, my.cnf
action: template src=templates/etc-mysql-my-cnf.j2 dest=/etc/mysql/my.cnf
tags: common
- include: ./tasks/mysql-secure.yml
##
# Apache2 setup.
#
- name: Apache | Enable some required modules
action: command a2enmod rewrite vhost_alias
tags: common
- name: Apache | Configuration file for our site
action: template src=templates/etc-apache2-sites-available-devserver.j2 dest=/etc/apache2/sites-available/devserver
tags: common
- name: Apache | Disable the default site
action: command a2dissite default
tags: common
- name: Apache | Enable our new site
action: command a2ensite devserver
tags: common
##
# Drush install, a Drupal shell tool.
#
- include: tasks/ubuntu-drush.yml
##
# Save authorized key from Vagrant Host's id_rsa.pub:
#
- name: SSH Keys | Save authorized_keys
authorized_key: user=vagrant key="{{ authorized_keys }}"
tags: common
# Copy host machines SSH keys to guest
# - name: SSH Keys | Copy private key from Host to Guest
# copy: src=/home/vagrant/.ssh_host/id_rsa dest=/home/vagrant/.ssh/id_rsa owner=vagrant group=vagrant mode=0600
# tags: common
#
# - name: SSH Keys | Copy public key from Host to Guest
# copy: src=/home/vagrant/.ssh_host/id_rsa.pub dest=/home/vagrant/.ssh/id_rsa.pub owner=vagrant group=vagrant mode=0600
# tags: common
##
# Restart services
#
- name: Restart Apache
action: service name=apache2 state=restarted
tags: common
- name: Restart MySQL
action: service name=mysql state=restarted
tags: common
##
# Final Drupal Configuraiton
#
- name: Create database user
action: mysql_user user={{ project }} password={{ project }} priv=*.*:ALL,GRANT state=present
tags: common
- name: Create database
action: mysql_db db={{ project }} state=present
tags: common
- name: Drupal | Configuration folder, sites/{{ server_hostname }}
action: file path=/var/www/sites/{{ server_hostname }} state=directory
tags: common
- name: Drupal | Configuration file, settings.php
action: template src=templates/settings-php.j2 dest=/var/www/sites/{{ server_hostname }}/settings.php
tags: common
- name: Drush | Create .drush folder
tags: common
action: file path=/home/vagrant/.drush owner=vagrant group=vagrant state=directory
- name: Drush | Create site alias
action: template src=templates/drush-alias-drushrc-php.j2 dest=/home/vagrant/.drush/{{ project }}.alias.drushrc.php
tags: common
###
# @TODO: Create a server wide site alias.
##
# Install Drupal based on chosen profile
# @TODO: This doesn't work. Fails with ERROR: chdir is not a legal parameter in an Ansible task or handler, which
# is in direct opposition to the documentation.
# - name: Drupal | Installation
# shell: drush site-install {{ install_profile }}
# chdir: /var/www/sites/{{ server_hostname }}
# creates: /var/site-installed
# tags: common