Skip to content

Commit 8cbd033

Browse files
committed
initial commit
0 parents  commit 8cbd033

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+4493
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.vagrant

README.md

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
# A Virtual Machine for Ruby on Rails Core Development
2+
3+
## Introduction
4+
5+
This project automates the setup of a development environment for Ruby on Rails core development. This is the easiest way to build a box with everything ready to start hacking on your pull request, all in an isolated virtual machine.
6+
7+
## Requirements
8+
9+
### VirtualBox
10+
11+
The virtual machine runs on top of [VirtualBox](https://www.virtualbox.org).
12+
13+
### Vagrant
14+
15+
We use [Vagrant](http://vagrantup.com) to build and provision the virtual machine:
16+
17+
gem install vagrant
18+
19+
Please install the "precise32" base box if you don't have it already (`vagrant box list` would tell you):
20+
21+
vagrant box add precise32 http://files.vagrantup.com/precise32.box
22+
23+
That's done only once.
24+
25+
## How To Build The Virtual Machine
26+
27+
Building the virtual machine is this easy:
28+
29+
git clone https://github.com/rails/rails-dev-box.git
30+
cd rails-dev-box
31+
vagrant up
32+
33+
That's it.
34+
35+
This initial setup takes about 3 minutes in my MacBook Air. Once the installation has finished, you can access the virtual machine with
36+
37+
vagrant ssh
38+
39+
Port 3000 in the host computer is forwarded to port 3000 in the virtual machine. Thus, applications running in the virtual machine can be accessed via localhost:3000 in the host computer.
40+
41+
## What's In The Box
42+
43+
* Git
44+
45+
* Ruby 1.9.3
46+
47+
* Bundler
48+
49+
* SQLite3, MySQL, and Postgres
50+
51+
* System dependencies for nokogiri, sqlite3, mysql, mysql2, and pg
52+
53+
* Databases and users needed to run the Active Record test suite
54+
55+
* therubyracer
56+
57+
* Memcached
58+
59+
## Virtual Machine Management
60+
61+
Once you are done just log out with `^D` and suspend the virtual machine
62+
63+
vagrant suspend
64+
65+
then, resume to hack again
66+
67+
vagrant resume
68+
69+
Run
70+
71+
vagrant halt
72+
73+
to shutdown the virtual machine, and
74+
75+
vagrant up
76+
77+
to boot it again.
78+
79+
And to completely wipe the virtual machine from the disk **destroying all its contents**:
80+
81+
vagrant destroy # DANGER: all is gone
82+
83+
Please check the [Vagrant documentation](http://vagrantup.com/v1/docs/index.html) for more information on Vagrant.

Vagrantfile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
Vagrant::Config.run do |config|
2+
# Run:
3+
#
4+
# vagrant box add precise32 http://files.vagrantup.com/precise32.box
5+
#
6+
# if needed (you need that only once).
7+
config.vm.box = 'precise32'
8+
9+
config.vm.forward_port 3000, 3000
10+
11+
config.vm.provision :puppet,
12+
:manifests_path => 'puppet/manifests',
13+
:module_path => 'puppet/modules'
14+
end

puppet/manifests/default.pp

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
$ar_databases = ['activerecord_unittest', 'activerecord_unittest2']
2+
3+
# Make sure apt-get -y update runs before anything else.
4+
stage { 'preinstall':
5+
before => Stage['main']
6+
}
7+
8+
class apt_get_update {
9+
exec { '/usr/bin/apt-get -y update':
10+
user => 'root'
11+
}
12+
}
13+
class { 'apt_get_update':
14+
stage => preinstall
15+
}
16+
17+
class install_sqlite3 {
18+
package { 'sqlite3':
19+
ensure => installed;
20+
}
21+
22+
package { 'libsqlite3-dev':
23+
ensure => installed;
24+
}
25+
}
26+
class { 'install_sqlite3': }
27+
28+
class install_mysql {
29+
class { 'mysql': }
30+
31+
class { 'mysql::server':
32+
config_hash => { 'root_password' => '' }
33+
}
34+
35+
database { $ar_databases:
36+
ensure => present,
37+
charset => 'utf8',
38+
require => Class['mysql::server']
39+
}
40+
41+
database_user { 'rails@localhost':
42+
ensure => present,
43+
require => Class['mysql::server']
44+
}
45+
46+
database_grant { ['rails@localhost/activerecord_unittest', 'rails@localhost/activerecord_unittest2']:
47+
privileges => ['all'],
48+
require => Database_user['rails@localhost']
49+
}
50+
51+
package { 'libmysqlclient15-dev':
52+
ensure => installed
53+
}
54+
}
55+
class { 'install_mysql': }
56+
57+
class install_postgres {
58+
class { 'postgresql': }
59+
60+
class { 'postgresql::server': }
61+
62+
pg_database { $ar_databases:
63+
ensure => present,
64+
encoding => 'UTF8',
65+
require => Class['postgresql::server']
66+
}
67+
68+
pg_user { 'rails':
69+
ensure => present,
70+
require => Class['postgresql::server']
71+
}
72+
73+
package { "libpq-dev":
74+
ensure => installed
75+
}
76+
}
77+
class { 'install_postgres': }
78+
79+
class install_core_packages {
80+
package { ['build-essential', 'git-core']:
81+
ensure => installed
82+
}
83+
}
84+
class { 'install_core_packages': }
85+
86+
class install_ruby {
87+
package { 'ruby1.9.3':
88+
ensure => installed
89+
}
90+
91+
exec { '/usr/bin/gem install bundler --no-rdoc --no-ri':
92+
unless => '/usr/bin/gem list | grep bundler',
93+
user => 'root',
94+
require => Package['ruby1.9.3']
95+
}
96+
97+
exec { '/usr/bin/gem install therubyracer --no-rdoc --no-ri':
98+
unless => '/usr/bin/gem list | grep therubyracer',
99+
user => 'root',
100+
require => [Package['ruby1.9.3'], Package['build-essential']]
101+
}
102+
}
103+
class { 'install_ruby': }
104+
105+
class install_nokogiri_dependencies {
106+
package { ['libxml2', 'libxml2-dev', 'libxslt1-dev']:
107+
ensure => installed
108+
}
109+
}
110+
class { 'install_nokogiri_dependencies': }
111+
112+
class { 'memcached': }

puppet/modules/memcached/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
pkg/
2+
*.swp

puppet/modules/memcached/Modulefile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
name 'saz-memcached'
2+
version '2.0.2'
3+
source 'git://github.com/saz/puppet-memcached.git'
4+
author 'saz'
5+
license 'Apache License, Version 2.0'
6+
summary 'UNKNOWN'
7+
description 'Manage memcached via Puppet'
8+
project_page 'https://github.com/saz/puppet-memcached'

puppet/modules/memcached/README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
2+
# puppet-memcached
3+
4+
Manage memcached via Puppet
5+
6+
## How to use
7+
8+
### Use roughly 90% of memory
9+
10+
```
11+
class { 'memcached': }
12+
```
13+
14+
### Set a fixed memory limit in MB
15+
16+
```
17+
class { 'memcached':
18+
max_memory => 2048
19+
}
20+
```
21+
22+
### Other class parameters
23+
24+
* $logfile = '/var/log/memcached.log'
25+
* $listen_ip = '0.0.0.0'
26+
* $tcp_port = 11211
27+
* $udp_port = 11211
28+
* $user = '' (OS specific setting, see params.pp)
29+
* $max_connections = 8192
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
class memcached(
2+
$package_ensure = 'present',
3+
$logfile = '/var/log/memcached.log',
4+
$max_memory = false,
5+
$listen_ip = '0.0.0.0',
6+
$tcp_port = 11211,
7+
$udp_port = 11211,
8+
$user = $::memcached::params::user,
9+
$max_connections = '8192',
10+
$verbosity = undef,
11+
$unix_socket = undef
12+
) inherits memcached::params {
13+
14+
package { $memcached::params::package_name:
15+
ensure => $package_ensure,
16+
}
17+
18+
file { $memcached::params::config_file:
19+
owner => 'root',
20+
group => 'root',
21+
mode => '0644',
22+
content => template($memcached::params::config_tmpl),
23+
require => Package[$memcached::params::package_name],
24+
}
25+
26+
service { $memcached::params::service_name:
27+
ensure => running,
28+
enable => true,
29+
hasrestart => true,
30+
hasstatus => false,
31+
subscribe => File[$memcached::params::config_file],
32+
}
33+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
class memcached::params {
2+
case $::osfamily {
3+
'Debian': {
4+
$package_name = 'memcached'
5+
$service_name = 'memcached'
6+
$config_file = '/etc/memcached.conf'
7+
$config_tmpl = "${module_name}/memcached.conf.erb"
8+
$user = 'nobody'
9+
}
10+
'RedHat': {
11+
$package_name = 'memcached'
12+
$service_name = 'memcached'
13+
$config_file = '/etc/sysconfig/memcached'
14+
$config_tmpl = "${module_name}/memcached_sysconfig.erb"
15+
$user = 'memcached'
16+
}
17+
default: {
18+
fail("Unsupported platform: ${::osfamily}")
19+
}
20+
}
21+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# File managed by puppet
2+
3+
# Run memcached as a daemon.
4+
-d
5+
6+
# pidfile
7+
-P /var/run/memcached.pid
8+
9+
# Log memcached's output
10+
logfile <%= logfile %>
11+
12+
<% if @verbosity -%>
13+
# Verbosity
14+
-<%= verbosity %>
15+
<% end -%>
16+
17+
# Use <num> MB memory max to use for object storage.
18+
<% if max_memory -%>
19+
-m <%= max_memory %>
20+
<% else -%>
21+
-m <%= ((memorysize.to_f*1024)*0.95).floor %>
22+
<% end -%>
23+
24+
<% if @unix_socket -%>
25+
# UNIX socket path to listen on
26+
-s <%= unix_socket %>
27+
<% else -%>
28+
29+
# IP to listen on
30+
-l <%= listen_ip %>
31+
32+
# TCP port to listen on
33+
-p <%= tcp_port %>
34+
35+
# UDP port to listen on
36+
-U <%= udp_port %>
37+
<% end -%>
38+
39+
# Run daemon as user
40+
-u <%= user %>
41+
42+
# Limit the number of simultaneous incoming connections.
43+
-c <%= max_connections %>
44+
45+
# Number of threads to use to process incoming requests.
46+
-t <%= processorcount %>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
PORT="<%= udp_port %>"
2+
USER="<%= user %>"
3+
MAXCONN="<%= max_connections %>"
4+
CACHESIZE="<%= max_memory %>"
5+
OPTIONS=""

puppet/modules/mysql/.fixtures.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
fixtures:
2+
symlinks:
3+
"mysql": "#{source_dir}"

puppet/modules/mysql/.gemfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
source :rubygems
2+
3+
puppetversion = ENV.key?('PUPPET_VERSION') ? "= #{ENV['PUPPET_VERSION']}" : ['>= 2.7']
4+
gem 'puppet', puppetversion
5+
gem 'puppetlabs_spec_helper', '>= 0.1.0'

0 commit comments

Comments
 (0)