-
Notifications
You must be signed in to change notification settings - Fork 96
/
vagrant.pp
116 lines (95 loc) · 2.89 KB
/
vagrant.pp
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
$echo = "/bin/echo"
$mysql = "/usr/bin/mysql"
$apt_get = "/usr/bin/apt-get"
$add_apt_repository = "/usr/bin/add-apt-repository"
$a2enmod = "/usr/sbin/a2enmod"
$mysqladmin = "/usr/bin/mysqladmin"
$wget = "/usr/bin/wget"
$dpkg = "/usr/bin/dpkg"
$php = "/usr/bin/php"
exec { "update apt":
command => "${apt_get} update"
}
# Apache
exec { "install apache":
command => "${apt_get} install -y apache2",
require => Exec["update apt"]
}
exec { "enable rewrite module":
command => "${a2enmod} rewrite",
require => Exec["install apache"]
}
file { "/etc/apache2/sites-available/000-default.conf":
ensure => file,
content => "
<VirtualHost *:80>
DocumentRoot /var/www/public
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
SetEnv APPLICATION_ENVIRONMENT local
<Directory '/var/www/public'>
AllowOverride All
</Directory>
</VirtualHost>
"
}
exec { "restart apache":
command => "/etc/init.d/apache2 restart",
require => [
File["/etc/apache2/sites-available/000-default.conf"],
Exec["install php"]
]
}
# MySQL
package { "mysql-server":
ensure => present
}
service { "mysql":
ensure => running,
require => Package["mysql-server"]
}
exec { "set root password":
command => "${mysqladmin} -uroot password vagrant",
require => Service["mysql"]
}
exec { "create user":
command => "${echo} \"CREATE USER 'dev'@'localhost' IDENTIFIED BY 'dev';\" | ${mysql} -uroot -pvagrant",
unless => "${mysql} -udev -pdev",
require => Exec["set root password"]
}
exec { "create database":
command => "${echo} \"CREATE DATABASE dev; GRANT ALL ON dev.* TO 'dev'@'localhost';\" | ${mysql} -uroot -pvagrant",
unless => "${mysql} -udev -pdev dev",
require => Exec["create user"]
}
# PHP
exec { "install python software properties":
command => "${apt_get} install -y python-software-properties",
require => Exec["update apt"]
}
exec { "add php repository":
command => "${add_apt_repository} -y ppa:ondrej/php5",
require => Exec["install python software properties"]
}
exec { "update apt for php":
command => "${apt_get} update -y",
require => Exec["add php repository"]
}
exec { "install php":
command => "${apt_get} install -y libapache2-mod-php5 php5-cli php5-common php5-mysql php5-gd php5-fpm php5-cgi php-pear php5-memcache php5-memcached php-apc php-soap php-xml-serializer php-xml-parser php5-geoip php5-mcrypt php5-curl php5-json php5-sqlite php5-redis",
require => Exec["update apt for php"]
}
# Redis
exec { "install redis":
command => "${apt_get} install -y redis-server",
require => Exec["update apt"]
}
# Laravel
exec { "migrate laravel":
command => "${php} /var/www/artisan migrate --seed --env=local",
require => [
Exec["install php"],
Exec["create database"],
Exec["restart apache"]
]
}