Permalink
Browse files

initial commit

  • Loading branch information...
0 parents commit 8cbd03367d660bb2b05967a7eca0231e51b5fe3d @fxn fxn committed Aug 14, 2012
Showing with 4,493 additions and 0 deletions.
  1. +1 −0 .gitignore
  2. +83 −0 README.md
  3. +14 −0 Vagrantfile
  4. +112 −0 puppet/manifests/default.pp
  5. +2 −0 puppet/modules/memcached/.gitignore
  6. +8 −0 puppet/modules/memcached/Modulefile
  7. +29 −0 puppet/modules/memcached/README.md
  8. +33 −0 puppet/modules/memcached/manifests/init.pp
  9. +21 −0 puppet/modules/memcached/manifests/params.pp
  10. +46 −0 puppet/modules/memcached/templates/memcached.conf.erb
  11. +5 −0 puppet/modules/memcached/templates/memcached_sysconfig.erb
  12. +3 −0 puppet/modules/mysql/.fixtures.yml
  13. +5 −0 puppet/modules/mysql/.gemfile
  14. +201 −0 puppet/modules/mysql/LICENSE
  15. +8 −0 puppet/modules/mysql/Modulefile
  16. +124 −0 puppet/modules/mysql/README.md
  17. +966 −0 puppet/modules/mysql/files/mysqltuner.pl
  18. +15 −0 puppet/modules/mysql/lib/puppet/parser/functions/mysql_password.rb
  19. +42 −0 puppet/modules/mysql/lib/puppet/provider/database/mysql.rb
  20. +177 −0 puppet/modules/mysql/lib/puppet/provider/database_grant/mysql.rb
  21. +42 −0 puppet/modules/mysql/lib/puppet/provider/database_user/mysql.rb
  22. +17 −0 puppet/modules/mysql/lib/puppet/type/database.rb
  23. +75 −0 puppet/modules/mysql/lib/puppet/type/database_grant.rb
  24. +25 −0 puppet/modules/mysql/lib/puppet/type/database_user.rb
  25. +68 −0 puppet/modules/mysql/manifests/backup.pp
  26. +122 −0 puppet/modules/mysql/manifests/config.pp
  27. +77 −0 puppet/modules/mysql/manifests/db.pp
  28. +24 −0 puppet/modules/mysql/manifests/init.pp
  29. +24 −0 puppet/modules/mysql/manifests/java.pp
  30. +91 −0 puppet/modules/mysql/manifests/params.pp
  31. +26 −0 puppet/modules/mysql/manifests/python.pp
  32. +28 −0 puppet/modules/mysql/manifests/ruby.pp
  33. +52 −0 puppet/modules/mysql/manifests/server.pp
  34. +13 −0 puppet/modules/mysql/manifests/server/account_security.pp
  35. +19 −0 puppet/modules/mysql/manifests/server/monitor.pp
  36. +22 −0 puppet/modules/mysql/manifests/server/mysqltuner.pp
  37. +42 −0 puppet/modules/mysql/templates/my.cnf.erb
  38. +6 −0 puppet/modules/mysql/templates/my.cnf.pass.erb
  39. +23 −0 puppet/modules/mysql/templates/mysqlbackup.sh.erb
  40. +674 −0 puppet/modules/postgresql/GPL-3
  41. +13 −0 puppet/modules/postgresql/Modulefile
  42. +156 −0 puppet/modules/postgresql/README.md
  43. +30 −0 puppet/modules/postgresql/lib/puppet/provider/pg_database/debian_postgresql.rb
  44. +17 −0 puppet/modules/postgresql/lib/puppet/provider/pg_database/default.rb
  45. +63 −0 puppet/modules/postgresql/lib/puppet/provider/pg_user/debian_postgresql.rb
  46. +17 −0 puppet/modules/postgresql/lib/puppet/provider/pg_user/default.rb
  47. +29 −0 puppet/modules/postgresql/lib/puppet/type/pg_database.rb
  48. +45 −0 puppet/modules/postgresql/lib/puppet/type/pg_user.rb
  49. +20 −0 puppet/modules/postgresql/manifests/db.pp
  50. +12 −0 puppet/modules/postgresql/manifests/init.pp
  51. +15 −0 puppet/modules/postgresql/manifests/params.pp
  52. +47 −0 puppet/modules/postgresql/manifests/server.pp
  53. +105 −0 puppet/modules/postgresql/templates/pg_hba.conf.erb
  54. +559 −0 puppet/modules/postgresql/templates/postgresql.conf.erb
@@ -0,0 +1 @@
+.vagrant
@@ -0,0 +1,83 @@
+# A Virtual Machine for Ruby on Rails Core Development
+
+## Introduction
+
+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.
+
+## Requirements
+
+### VirtualBox
+
+The virtual machine runs on top of [VirtualBox](https://www.virtualbox.org).
+
+### Vagrant
+
+We use [Vagrant](http://vagrantup.com) to build and provision the virtual machine:
+
+ gem install vagrant
+
+Please install the "precise32" base box if you don't have it already (`vagrant box list` would tell you):
+
+ vagrant box add precise32 http://files.vagrantup.com/precise32.box
+
+That's done only once.
+
+## How To Build The Virtual Machine
+
+Building the virtual machine is this easy:
+
+ git clone https://github.com/rails/rails-dev-box.git
+ cd rails-dev-box
+ vagrant up
+
+That's it.
+
+This initial setup takes about 3 minutes in my MacBook Air. Once the installation has finished, you can access the virtual machine with
+
+ vagrant ssh
+
+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.
+
+## What's In The Box
+
+* Git
+
+* Ruby 1.9.3
+
+* Bundler
+
+* SQLite3, MySQL, and Postgres
+
+* System dependencies for nokogiri, sqlite3, mysql, mysql2, and pg
+
+* Databases and users needed to run the Active Record test suite
+
+* therubyracer
+
+* Memcached
+
+## Virtual Machine Management
+
+Once you are done just log out with `^D` and suspend the virtual machine
+
+ vagrant suspend
+
+then, resume to hack again
+
+ vagrant resume
+
+Run
+
+ vagrant halt
+
+to shutdown the virtual machine, and
+
+ vagrant up
+
+to boot it again.
+
+And to completely wipe the virtual machine from the disk **destroying all its contents**:
+
+ vagrant destroy # DANGER: all is gone
+
+Please check the [Vagrant documentation](http://vagrantup.com/v1/docs/index.html) for more information on Vagrant.
@@ -0,0 +1,14 @@
+Vagrant::Config.run do |config|
+ # Run:
+ #
+ # vagrant box add precise32 http://files.vagrantup.com/precise32.box
+ #
+ # if needed (you need that only once).
+ config.vm.box = 'precise32'
+
+ config.vm.forward_port 3000, 3000
+
+ config.vm.provision :puppet,
+ :manifests_path => 'puppet/manifests',
+ :module_path => 'puppet/modules'
+end
@@ -0,0 +1,112 @@
+$ar_databases = ['activerecord_unittest', 'activerecord_unittest2']
+
+# Make sure apt-get -y update runs before anything else.
+stage { 'preinstall':
+ before => Stage['main']
+}
+
+class apt_get_update {
+ exec { '/usr/bin/apt-get -y update':
+ user => 'root'
+ }
+}
+class { 'apt_get_update':
+ stage => preinstall
+}
+
+class install_sqlite3 {
+ package { 'sqlite3':
+ ensure => installed;
+ }
+
+ package { 'libsqlite3-dev':
+ ensure => installed;
+ }
+}
+class { 'install_sqlite3': }
+
+class install_mysql {
+ class { 'mysql': }
+
+ class { 'mysql::server':
+ config_hash => { 'root_password' => '' }
+ }
+
+ database { $ar_databases:
+ ensure => present,
+ charset => 'utf8',
+ require => Class['mysql::server']
+ }
+
+ database_user { 'rails@localhost':
+ ensure => present,
+ require => Class['mysql::server']
+ }
+
+ database_grant { ['rails@localhost/activerecord_unittest', 'rails@localhost/activerecord_unittest2']:
+ privileges => ['all'],
+ require => Database_user['rails@localhost']
+ }
+
+ package { 'libmysqlclient15-dev':
+ ensure => installed
+ }
+}
+class { 'install_mysql': }
+
+class install_postgres {
+ class { 'postgresql': }
+
+ class { 'postgresql::server': }
+
+ pg_database { $ar_databases:
+ ensure => present,
+ encoding => 'UTF8',
+ require => Class['postgresql::server']
+ }
+
+ pg_user { 'rails':
+ ensure => present,
+ require => Class['postgresql::server']
+ }
+
+ package { "libpq-dev":
+ ensure => installed
+ }
+}
+class { 'install_postgres': }
+
+class install_core_packages {
+ package { ['build-essential', 'git-core']:
+ ensure => installed
+ }
+}
+class { 'install_core_packages': }
+
+class install_ruby {
+ package { 'ruby1.9.3':
+ ensure => installed
+ }
+
+ exec { '/usr/bin/gem install bundler --no-rdoc --no-ri':
+ unless => '/usr/bin/gem list | grep bundler',
+ user => 'root',
+ require => Package['ruby1.9.3']
+ }
+
+ exec { '/usr/bin/gem install therubyracer --no-rdoc --no-ri':
+ unless => '/usr/bin/gem list | grep therubyracer',
+ user => 'root',
+ require => [Package['ruby1.9.3'], Package['build-essential']]
+ }
+}
+class { 'install_ruby': }
+
+class install_nokogiri_dependencies {
+ package { ['libxml2', 'libxml2-dev', 'libxslt1-dev']:
+ ensure => installed
+ }
+}
+class { 'install_nokogiri_dependencies': }
+
+class { 'memcached': }
@@ -0,0 +1,2 @@
+pkg/
+*.swp
@@ -0,0 +1,8 @@
+name 'saz-memcached'
+version '2.0.2'
+source 'git://github.com/saz/puppet-memcached.git'
+author 'saz'
+license 'Apache License, Version 2.0'
+summary 'UNKNOWN'
+description 'Manage memcached via Puppet'
+project_page 'https://github.com/saz/puppet-memcached'
@@ -0,0 +1,29 @@
+
+# puppet-memcached
+
+Manage memcached via Puppet
+
+## How to use
+
+### Use roughly 90% of memory
+
+```
+ class { 'memcached': }
+```
+
+### Set a fixed memory limit in MB
+
+```
+ class { 'memcached':
+ max_memory => 2048
+ }
+```
+
+### Other class parameters
+
+* $logfile = '/var/log/memcached.log'
+* $listen_ip = '0.0.0.0'
+* $tcp_port = 11211
+* $udp_port = 11211
+* $user = '' (OS specific setting, see params.pp)
+* $max_connections = 8192
@@ -0,0 +1,33 @@
+class memcached(
+ $package_ensure = 'present',
+ $logfile = '/var/log/memcached.log',
+ $max_memory = false,
+ $listen_ip = '0.0.0.0',
+ $tcp_port = 11211,
+ $udp_port = 11211,
+ $user = $::memcached::params::user,
+ $max_connections = '8192',
+ $verbosity = undef,
+ $unix_socket = undef
+) inherits memcached::params {
+
+ package { $memcached::params::package_name:
+ ensure => $package_ensure,
+ }
+
+ file { $memcached::params::config_file:
+ owner => 'root',
+ group => 'root',
+ mode => '0644',
+ content => template($memcached::params::config_tmpl),
+ require => Package[$memcached::params::package_name],
+ }
+
+ service { $memcached::params::service_name:
+ ensure => running,
+ enable => true,
+ hasrestart => true,
+ hasstatus => false,
+ subscribe => File[$memcached::params::config_file],
+ }
+}
@@ -0,0 +1,21 @@
+class memcached::params {
+ case $::osfamily {
+ 'Debian': {
+ $package_name = 'memcached'
+ $service_name = 'memcached'
+ $config_file = '/etc/memcached.conf'
+ $config_tmpl = "${module_name}/memcached.conf.erb"
+ $user = 'nobody'
+ }
+ 'RedHat': {
+ $package_name = 'memcached'
+ $service_name = 'memcached'
+ $config_file = '/etc/sysconfig/memcached'
+ $config_tmpl = "${module_name}/memcached_sysconfig.erb"
+ $user = 'memcached'
+ }
+ default: {
+ fail("Unsupported platform: ${::osfamily}")
+ }
+ }
+}
@@ -0,0 +1,46 @@
+# File managed by puppet
+
+# Run memcached as a daemon.
+-d
+
+# pidfile
+-P /var/run/memcached.pid
+
+# Log memcached's output
+logfile <%= logfile %>
+
+<% if @verbosity -%>
+# Verbosity
+-<%= verbosity %>
+<% end -%>
+
+# Use <num> MB memory max to use for object storage.
+<% if max_memory -%>
+-m <%= max_memory %>
+<% else -%>
+-m <%= ((memorysize.to_f*1024)*0.95).floor %>
+<% end -%>
+
+<% if @unix_socket -%>
+# UNIX socket path to listen on
+-s <%= unix_socket %>
+<% else -%>
+
+# IP to listen on
+-l <%= listen_ip %>
+
+# TCP port to listen on
+-p <%= tcp_port %>
+
+# UDP port to listen on
+-U <%= udp_port %>
+<% end -%>
+
+# Run daemon as user
+-u <%= user %>
+
+# Limit the number of simultaneous incoming connections.
+-c <%= max_connections %>
+
+# Number of threads to use to process incoming requests.
+-t <%= processorcount %>
@@ -0,0 +1,5 @@
+PORT="<%= udp_port %>"
+USER="<%= user %>"
+MAXCONN="<%= max_connections %>"
+CACHESIZE="<%= max_memory %>"
+OPTIONS=""
@@ -0,0 +1,3 @@
+fixtures:
+ symlinks:
+ "mysql": "#{source_dir}"
@@ -0,0 +1,5 @@
+source :rubygems
+
+puppetversion = ENV.key?('PUPPET_VERSION') ? "= #{ENV['PUPPET_VERSION']}" : ['>= 2.7']
+gem 'puppet', puppetversion
+gem 'puppetlabs_spec_helper', '>= 0.1.0'
Oops, something went wrong.

0 comments on commit 8cbd033

Please sign in to comment.