This repository has been archived by the owner on Jun 12, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
site.pp
184 lines (157 loc) · 5.29 KB
/
site.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
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
Exec { path => [ '/bin/', '/sbin/' , '/usr/bin/', '/usr/sbin/'] }
# From http://projects.puppetlabs.com/projects/1/wiki/Simple_Text_Patterns
define line($file, $line, $ensure = 'present') {
case $ensure {
default : { err ( "unknown ensure value ${ensure}" ) }
present: {
exec { "/bin/echo '${line}' >> '${file}'":
unless => "/bin/grep -qFx '${line}' '${file}'"
}
}
absent: {
exec { "/bin/grep -vFx '${line}' '${file}' | /usr/bin/tee '${file}' > /dev/null 2>&1":
onlyif => "/bin/grep -qFx '${line}' '${file}'"
}
}
}
}
##################################
# Misc packages
package { [
'curl', 'imagemagick', 'htop', 'exuberant-ctags', 'tmux',
'libtcmalloc-minimal4', 'vim-nox', 'libv8-dev', 'libsqlite3-dev',
'graphviz']:
}
##################################
# Common ground for completions
file { '/home/vagrant/completion_scripts':
ensure => directory,
owner => 'vagrant',
group => 'vagrant'
}
##################################
# Ruby / Rails goodies
wget::fetch { "rake-completion":
source => "https://raw.github.com/calebthompson/dotfiles/master/rake/completion.sh",
destination => "/home/vagrant/completion_scripts/rake",
timeout => 0,
verbose => false,
require => File['/home/vagrant/completion_scripts']
}
line {
'source-rake-completion':
file => "/home/vagrant/.bashrc",
line => "source /home/vagrant/completion_scripts/rake",
require => Wget::Fetch['rake-completion'];
'migrate-alias':
file => '/home/vagrant/.bashrc',
line => 'alias migrate="rake db:migrate && RAILS_ENV=test rake db:migrate"';
'rollback-alias':
file => '/home/vagrant/.bashrc',
line => 'alias rollback="rake db:rollback && RAILS_ENV=test rake db:rollback"';
}
##################################
# NodeJS
include nodejs
package { ['coffee-script', 'istanbul']:
ensure => present,
provider => 'npm',
require => Class['nodejs']
}
##################################
# Heroku Toolbelt
exec {
'wget -qO- https://toolbelt.heroku.com/install-ubuntu.sh | sh':
creates => '/usr/local/heroku/bin/heroku'
}
##################################
# RUBY
$default_ruby = '2.0.0-p195'
file {
'/home/vagrant/.gemrc':
content => "
:verbose: true
gem: --no-ri --no-rdoc
:update_sources: true
:sources:
- http://gems.rubyforge.org
- http://gems.github.com
:backtrace: false
:bulk_threshold: 1000
:benchmark: false
"
}
rbenv::install { 'vagrant': }
rbenv::plugin::rubybuild { 'vagrant': }
rbenv::plugin::rbenvvars { 'vagrant':
require => Rbenv::Install['vagrant']
}
rbenv::compile { $default_ruby:
user => 'vagrant',
global => true
}
rbenv::gem { ['foreman', 'rubygems-bundler', 'tmuxinator', 'lol_dba']:
user => 'vagrant',
ruby => $default_ruby,
require => Rbenv::Compile[$default_ruby]
}
exec { 'gem regenerate_binstubs"':
unless => 'gem list | grep -q rubygems-bundler',
path => "/home/vagrant/.rbenv/bin:/home/vagrant/.rbenv/versions/${default_ruby}/bin:/bin:/usr/bin",
user => 'vagrant',
require => Rbenv::Gem['rubygems-bundler']
}
##################################
# PhantomJS
exec { 'install-phantomjs':
command => 'curl https://phantomjs.googlecode.com/files/phantomjs-1.9.1-linux-x86_64.tar.bz2 | sudo tar xjfv - &&
sudo ln -s /usr/local/share/phantomjs-1.9.1-linux-x86_64/bin/phantomjs /usr/local/bin/phantomjs',
cwd => '/usr/local/share',
creates => '/usr/local/bin/phantomjs'
}
##################################
# Memcached
class { 'memcached':
max_memory => 25,
user => 'root'
}
##################################
# PostgreSQL
package { 'libpq-dev': }
class { 'postgresql::server':
acl => ['host all all 127.0.0.1/32 trust', ],
}
exec {
'vagrant-postgres-user':
command => 'createuser --superuser vagrant 2>/dev/null',
unless => 'psql -c "\du" 2>/dev/null | grep -q vagrant',
user => 'postgres',
require => Class['postgresql::server'];
# Based on https://gist.github.com/ffmike/877447
'fix-psql-default-encoding':
command => 'psql postgres -c "update pg_database set datallowconn = TRUE where datname = \'template0\';"
psql template0 -c "update pg_database set datistemplate = FALSE where datname = \'template1\';"
psql template0 -c "drop database template1;"
psql template0 -c "create database template1 with template = template0 encoding = \'UTF8\';"
psql template0 -c "update pg_database set datistemplate = TRUE where datname = \'template1\';"
psql template1 -c "update pg_database set datallowconn = FALSE where datname = \'template0\';"',
unless => "psql template1 -c 'SHOW SERVER_ENCODING' | grep -q UTF8",
user => 'postgres',
require => Class['postgresql::server']
}
##################################
# Redis
class { 'redis': redis_max_memory => '10mb' }
exec {
'update-rc.d -f redis_6379 defaults 98 02':
creates => '/etc/rc0.d/K02redis_6379',
require => Class['redis']
}
##################################
# ElasticSearch
package { 'openjdk-7-jre-headless': }
exec { 'install-elasticsearch':
command => 'wget https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-0.90.0.deb -O /tmp/elasticsearch.deb -q &&
dpkg -i /tmp/elasticsearch.deb',
unless => 'dpkg -s elasticsearch 2>/dev/null > /dev/null'
}