├── .gitignore ├── .vagrant ├── Gemfile ├── Gemfile.lock ├── README.md ├── Rakefile ├── Vagrantfile ├── app ├── controllers │ └── application_controller.rb ├── helpers │ └── application_helper.rb └── views │ └── layouts │ └── application.html.erb ├── config.ru ├── config ├── application.rb ├── boot.rb ├── database.yml ├── environment.rb ├── environments │ ├── development.rb │ ├── production.rb │ └── test.rb ├── initializers │ ├── backtrace_silencers.rb │ ├── inflections.rb │ ├── mime_types.rb │ ├── secret_token.rb │ └── session_store.rb ├── locales │ └── en.yml └── routes.rb ├── cookbooks ├── apt │ ├── README.md │ ├── files │ │ └── default │ │ │ ├── apt-cacher │ │ │ ├── apt-cacher.conf │ │ │ └── apt-proxy-v2.conf │ ├── metadata.json │ ├── metadata.rb │ └── recipes │ │ ├── cacher.rb │ │ ├── default.rb │ │ └── proxy.rb ├── git │ ├── README.rdoc │ ├── metadata.json │ ├── metadata.rb │ ├── recipes │ │ ├── default.rb │ │ └── server.rb │ └── templates │ │ └── default │ │ ├── sv-git-daemon-log-run.erb │ │ └── sv-git-daemon-run.erb ├── java │ ├── README.md │ ├── attributes │ │ └── default.rb │ ├── files │ │ └── default │ │ │ └── java.seed │ ├── metadata.json │ ├── metadata.rb │ ├── recipes │ │ ├── default.rb │ │ ├── openjdk.rb │ │ └── sun.rb │ └── templates │ │ └── ubuntu │ │ └── canonical.com.list.erb ├── mysql │ ├── README.rdoc │ ├── attributes │ │ └── server.rb │ ├── libraries │ │ └── database.rb │ ├── metadata.json │ ├── metadata.rb │ ├── providers │ │ └── database.rb │ ├── recipes │ │ ├── client.rb │ │ ├── default.rb │ │ ├── server.rb │ │ └── server_ec2.rb │ ├── resources │ │ └── database.rb │ └── templates │ │ ├── centos │ │ └── my.cnf.erb │ │ ├── debian │ │ └── my.cnf.erb │ │ ├── default │ │ ├── debian.cnf.erb │ │ ├── grants.sql.erb │ │ ├── my.cnf.erb │ │ ├── mysql-server.seed.erb │ │ └── port_mysql.erb │ │ ├── redhat │ │ └── my.cnf.erb │ │ ├── ubuntu-10.04 │ │ └── my.cnf.erb │ │ ├── ubuntu-8.04 │ │ └── my.cnf.erb │ │ └── ubuntu-9.10 │ │ └── my.cnf.erb ├── openssl │ ├── README.rdoc │ ├── libraries │ │ └── secure_password.rb │ ├── metadata.json │ ├── metadata.rb │ └── recipes │ │ └── default.rb ├── postgresql │ ├── README.rdoc │ ├── attributes │ │ └── default.rb │ ├── metadata.json │ ├── metadata.rb │ ├── recipes │ │ ├── client.rb │ │ ├── default.rb │ │ ├── server.rb │ │ ├── server_debian.rb │ │ └── server_redhat.rb │ └── templates │ │ └── default │ │ ├── debian.pg_hba.conf.erb │ │ ├── debian.postgresql.conf.erb │ │ ├── redhat.pg_hba.conf.erb │ │ └── redhat.postgresql.conf.erb ├── rails │ ├── README.rdoc │ ├── attributes │ │ └── default.rb │ ├── metadata.json │ ├── metadata.rb │ ├── recipes │ │ └── default.rb │ └── templates │ │ └── default │ │ └── rails_app.conf.erb ├── ruby │ ├── README.rdoc │ ├── definitions │ │ ├── ruby_packages.rb │ │ └── ruby_symlinks.rb │ ├── metadata.json │ ├── metadata.rb │ └── recipes │ │ ├── 1.8.rb │ │ ├── 1.9.1.rb │ │ ├── 1.9.rb │ │ ├── default.rb │ │ └── symlinks.rb ├── rubygems │ ├── metadata.json │ ├── metadata.rb │ └── recipes │ │ └── default.rb ├── sqlite │ ├── metadata.json │ ├── metadata.rb │ └── recipes │ │ └── default.rb └── vagrant_main │ └── recipes │ └── default.rb ├── db └── seeds.rb ├── doc └── README_FOR_APP ├── lib └── tasks │ └── .gitkeep ├── public ├── 404.html ├── 422.html ├── 500.html ├── favicon.ico ├── images │ └── rails.png ├── index.html ├── javascripts │ ├── application.js │ ├── controls.js │ ├── dragdrop.js │ ├── effects.js │ ├── prototype.js │ └── rails.js ├── robots.txt └── stylesheets │ └── .gitkeep ├── script └── rails ├── test ├── performance │ └── browsing_test.rb └── test_helper.rb └── vendor └── plugins └── .gitkeep /.gitignore: -------------------------------------------------------------------------------- 1 | .bundle 2 | db/*.sqlite3 3 | log/*.log 4 | tmp/**/* 5 | .vagrant -------------------------------------------------------------------------------- /.vagrant: -------------------------------------------------------------------------------- 1 | {"active":{"default":"136fa04f-d765-48aa-a5cf-443e0891f607"}} -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source 'http://rubygems.org' 2 | 3 | gem 'rails', '3.0.1' 4 | 5 | # Bundle edge Rails instead: 6 | # gem 'rails', :git => 'git://github.com/rails/rails.git' 7 | 8 | gem 'mysql2' 9 | 10 | # Use unicorn as the web server 11 | # gem 'unicorn' 12 | 13 | # Deploy with Capistrano 14 | # gem 'capistrano' 15 | 16 | # To use debugger 17 | # gem 'ruby-debug' 18 | 19 | # Bundle the extra gems: 20 | # gem 'bj' 21 | # gem 'nokogiri' 22 | # gem 'sqlite3-ruby', :require => 'sqlite3' 23 | # gem 'aws-s3', :require => 'aws/s3' 24 | 25 | # Bundle gems for the local environment. Make sure to 26 | # put test-only gems in this group so their generators 27 | # and rake tasks are available in development mode: 28 | # group :development, :test do 29 | # gem 'webrat' 30 | # end 31 | -------------------------------------------------------------------------------- /Gemfile.lock: -------------------------------------------------------------------------------- 1 | GEM 2 | remote: http://rubygems.org/ 3 | specs: 4 | abstract (1.0.0) 5 | actionmailer (3.0.1) 6 | actionpack (= 3.0.1) 7 | mail (~> 2.2.5) 8 | actionpack (3.0.1) 9 | activemodel (= 3.0.1) 10 | activesupport (= 3.0.1) 11 | builder (~> 2.1.2) 12 | erubis (~> 2.6.6) 13 | i18n (~> 0.4.1) 14 | rack (~> 1.2.1) 15 | rack-mount (~> 0.6.12) 16 | rack-test (~> 0.5.4) 17 | tzinfo (~> 0.3.23) 18 | activemodel (3.0.1) 19 | activesupport (= 3.0.1) 20 | builder (~> 2.1.2) 21 | i18n (~> 0.4.1) 22 | activerecord (3.0.1) 23 | activemodel (= 3.0.1) 24 | activesupport (= 3.0.1) 25 | arel (~> 1.0.0) 26 | tzinfo (~> 0.3.23) 27 | activeresource (3.0.1) 28 | activemodel (= 3.0.1) 29 | activesupport (= 3.0.1) 30 | activesupport (3.0.1) 31 | arel (1.0.1) 32 | activesupport (~> 3.0.0) 33 | builder (2.1.2) 34 | erubis (2.6.6) 35 | abstract (>= 1.0.0) 36 | i18n (0.4.2) 37 | mail (2.2.9) 38 | activesupport (>= 2.3.6) 39 | i18n (~> 0.4.1) 40 | mime-types (~> 1.16) 41 | treetop (~> 1.4.8) 42 | mime-types (1.16) 43 | mysql2 (0.2.6) 44 | polyglot (0.3.1) 45 | rack (1.2.1) 46 | rack-mount (0.6.13) 47 | rack (>= 1.0.0) 48 | rack-test (0.5.6) 49 | rack (>= 1.0) 50 | rails (3.0.1) 51 | actionmailer (= 3.0.1) 52 | actionpack (= 3.0.1) 53 | activerecord (= 3.0.1) 54 | activeresource (= 3.0.1) 55 | activesupport (= 3.0.1) 56 | bundler (~> 1.0.0) 57 | railties (= 3.0.1) 58 | railties (3.0.1) 59 | actionpack (= 3.0.1) 60 | activesupport (= 3.0.1) 61 | rake (>= 0.8.4) 62 | thor (~> 0.14.0) 63 | rake (0.8.7) 64 | thor (0.14.3) 65 | treetop (1.4.8) 66 | polyglot (>= 0.3.1) 67 | tzinfo (0.3.23) 68 | 69 | PLATFORMS 70 | ruby 71 | 72 | DEPENDENCIES 73 | mysql2 74 | rails (= 3.0.1) 75 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Sample Rails3, Vagrantfile and testing within Hudson CI 2 | 3 | This README describes how to start up a Hudson CI server, create a VM and add it to Hudson CI server as a slave, and create/build a job to run this project's tests. 4 | 5 | 6 | 7 | This app has a Vagrantfile and Chef recipes to create a VirtualBox VM ready for integration testing. 8 | 9 | It includes a Java JRE so that [Hudson CI](http://hudson-ci.org/) can use the VM as a slave node, SSH into it, inject its slave.jar and automated it. 10 | 11 | ## Preparation 12 | 13 | For the tutorial on running CI tests through Hudson CI with VM instances constructed by Vagrant, there are a couple preparation steps: 14 | 15 | git clone git://github.com/drnic/railsapp-vagrant.git 16 | cd railsapp-vagrant 17 | 18 | Next, install [VirtualBox](http://virtualbox.org/). 19 | 20 | ## Vagrant 21 | 22 | Install [Vagrant](http://vagrantup.com/) and download the Ubuntu Lucid 32bit VirtualBox image: 23 | 24 | gem install vagrant -v 0.6.7 # if other version, the replace '0.6.7' in instructions below 25 | vagrant box add base http://files.vagrantup.com/lucid32.box 26 | 27 | Then to spin up a VM for this Rails app (takes 10 minutes, mostly due to installing Java JRE, I think): 28 | 29 | vagrant init base 30 | vagrant up 31 | 32 | To access this project within the VM: 33 | 34 | vagrant ssh 35 | $ cd /vagrant/ 36 | $ rake test 37 | /vagrant/db/schema.rb doesn't exist yet. 38 | 39 | ## Quick fix of VM 40 | 41 | When I do this the `~/.gem` folder is owned by `root` and not the `vagrant` user. This isn't correct. Fix it within the VM: 42 | 43 | $ sudo chown vagrant:vagrant ~/.gem 44 | $ exit 45 | 46 | ## Testing within Hudson CI 47 | 48 | You can add this VM into Hudson CI as a slave, create a Hudson job for this project, and restrict it to running the tests only within this VM. This will ensure that you have all the system/utility/ruby requirements for your tests. Ideally, these will match your production deployment environment. 49 | 50 | To experiment with Hudson CI: 51 | 52 | gem install hudson 53 | hudson server 54 | 55 | This spins up Hudson CI at http://localhost:3010. 56 | 57 | In another terminal, add the VM as a slave node: 58 | 59 | $ hudson add_node localhost --name "VM" \ 60 | --label railsapp-vagrant \ 61 | --slave-port 2222 \ 62 | --slave-user vagrant \ 63 | --slave-fs /vagrant/tmp/hudson-slave \ 64 | --master-key /Library/Ruby/Gems/1.8/gems/vagrant-0.6.7/keys/vagrant \ 65 | --host localhost --port 3010 66 | 67 | $ hudson nodes --host localhost --port 3001 68 | master 69 | VM 70 | 71 | Visit your Hudson CI to see the Slave node registered as "VM" on the left hand side. 72 | 73 | To add this Rails3 application as a CI job in Hudson: 74 | 75 | hudson create . --template rails3 --assigned-node railsapp-vagrant 76 | 77 | Note: the `--host` and `--port` flags are only required when you want the `hudson` CLI to change/set which Hudson CI master it is communicating with. Well, that's how the CLI works at the time of writing. 78 | 79 | Visit your Hudson CI and see a new job in the list and it should start building automatically. Click through and find the Output Log to see the build in progress. It should end up with `SUCCESS`! 80 | 81 | 82 | 83 | 84 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | # Add your own tasks in files placed in lib/tasks ending in .rake, 2 | # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. 3 | 4 | require File.expand_path('../config/application', __FILE__) 5 | require 'rake' 6 | 7 | RailsappVagrant::Application.load_tasks 8 | -------------------------------------------------------------------------------- /Vagrantfile: -------------------------------------------------------------------------------- 1 | Vagrant::Config.run do |config| 2 | config.vm.box = "base" 3 | 4 | config.vm.provisioner = :chef_solo 5 | config.chef.cookbooks_path = "cookbooks" 6 | %w[apt openssl git ruby rubygems rails mysql mysql::server java].each {|r| 7 | config.chef.add_recipe r 8 | } 9 | 10 | config.chef.json.merge!({ :mysql => { :server_root_password => "" } }) 11 | end 12 | -------------------------------------------------------------------------------- /app/controllers/application_controller.rb: -------------------------------------------------------------------------------- 1 | class ApplicationController < ActionController::Base 2 | protect_from_forgery 3 | end 4 | -------------------------------------------------------------------------------- /app/helpers/application_helper.rb: -------------------------------------------------------------------------------- 1 | module ApplicationHelper 2 | end 3 | -------------------------------------------------------------------------------- /app/views/layouts/application.html.erb: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | RailsappVagrant 5 | <%= stylesheet_link_tag :all %> 6 | <%= javascript_include_tag :defaults %> 7 | <%= csrf_meta_tag %> 8 | 9 | 10 | 11 | <%= yield %> 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /config.ru: -------------------------------------------------------------------------------- 1 | # This file is used by Rack-based servers to start the application. 2 | 3 | require ::File.expand_path('../config/environment', __FILE__) 4 | run RailsappVagrant::Application 5 | -------------------------------------------------------------------------------- /config/application.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../boot', __FILE__) 2 | 3 | require 'rails/all' 4 | 5 | # If you have a Gemfile, require the gems listed there, including any gems 6 | # you've limited to :test, :development, or :production. 7 | Bundler.require(:default, Rails.env) if defined?(Bundler) 8 | 9 | module RailsappVagrant 10 | class Application < Rails::Application 11 | # Settings in config/environments/* take precedence over those specified here. 12 | # Application configuration should go into files in config/initializers 13 | # -- all .rb files in that directory are automatically loaded. 14 | 15 | # Custom directories with classes and modules you want to be autoloadable. 16 | # config.autoload_paths += %W(#{config.root}/extras) 17 | 18 | # Only load the plugins named here, in the order given (default is alphabetical). 19 | # :all can be used as a placeholder for all plugins not explicitly named. 20 | # config.plugins = [ :exception_notification, :ssl_requirement, :all ] 21 | 22 | # Activate observers that should always be running. 23 | # config.active_record.observers = :cacher, :garbage_collector, :forum_observer 24 | 25 | # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. 26 | # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC. 27 | # config.time_zone = 'Central Time (US & Canada)' 28 | 29 | # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. 30 | # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] 31 | # config.i18n.default_locale = :de 32 | 33 | # JavaScript files you want as :defaults (application.js is always included). 34 | # config.action_view.javascript_expansions[:defaults] = %w(jquery rails) 35 | 36 | # Configure the default encoding used in templates for Ruby 1.9. 37 | config.encoding = "utf-8" 38 | 39 | # Configure sensitive parameters which will be filtered from the log file. 40 | config.filter_parameters += [:password] 41 | end 42 | end 43 | -------------------------------------------------------------------------------- /config/boot.rb: -------------------------------------------------------------------------------- 1 | require 'rubygems' 2 | 3 | # Set up gems listed in the Gemfile. 4 | gemfile = File.expand_path('../../Gemfile', __FILE__) 5 | begin 6 | ENV['BUNDLE_GEMFILE'] = gemfile 7 | require 'bundler' 8 | Bundler.setup 9 | rescue Bundler::GemNotFound => e 10 | STDERR.puts e.message 11 | STDERR.puts "Try running `bundle install`." 12 | exit! 13 | end if File.exist?(gemfile) 14 | -------------------------------------------------------------------------------- /config/database.yml: -------------------------------------------------------------------------------- 1 | # MySQL. Versions 4.1 and 5.0 are recommended. 2 | # 3 | # Install the MySQL driver: 4 | # gem install mysql2 5 | # 6 | # And be sure to use new-style password hashing: 7 | # http://dev.mysql.com/doc/refman/5.0/en/old-client.html 8 | development: 9 | adapter: mysql2 10 | encoding: utf8 11 | reconnect: false 12 | database: railsapp-vagrant_development 13 | pool: 5 14 | username: root 15 | password: 16 | host: localhost 17 | 18 | # Warning: The database defined as "test" will be erased and 19 | # re-generated from your development database when you run "rake". 20 | # Do not set this db to the same as development or production. 21 | test: 22 | adapter: mysql2 23 | encoding: utf8 24 | reconnect: false 25 | database: railsapp-vagrant_test 26 | pool: 5 27 | username: root 28 | password: 29 | host: localhost 30 | 31 | production: 32 | adapter: mysql2 33 | encoding: utf8 34 | reconnect: false 35 | database: railsapp-vagrant_production 36 | pool: 5 37 | username: root 38 | password: 39 | host: localhost 40 | -------------------------------------------------------------------------------- /config/environment.rb: -------------------------------------------------------------------------------- 1 | # Load the rails application 2 | require File.expand_path('../application', __FILE__) 3 | 4 | # Initialize the rails application 5 | RailsappVagrant::Application.initialize! 6 | -------------------------------------------------------------------------------- /config/environments/development.rb: -------------------------------------------------------------------------------- 1 | RailsappVagrant::Application.configure do 2 | # Settings specified here will take precedence over those in config/environment.rb 3 | 4 | # In the development environment your application's code is reloaded on 5 | # every request. This slows down response time but is perfect for development 6 | # since you don't have to restart the webserver when you make code changes. 7 | config.cache_classes = false 8 | 9 | # Log error messages when you accidentally call methods on nil. 10 | config.whiny_nils = true 11 | 12 | # Show full error reports and disable caching 13 | config.consider_all_requests_local = true 14 | config.action_view.debug_rjs = true 15 | config.action_controller.perform_caching = false 16 | 17 | # Don't care if the mailer can't send 18 | config.action_mailer.raise_delivery_errors = false 19 | 20 | # Print deprecation notices to the Rails logger 21 | config.active_support.deprecation = :log 22 | 23 | # Only use best-standards-support built into browsers 24 | config.action_dispatch.best_standards_support = :builtin 25 | end 26 | 27 | -------------------------------------------------------------------------------- /config/environments/production.rb: -------------------------------------------------------------------------------- 1 | RailsappVagrant::Application.configure do 2 | # Settings specified here will take precedence over those in config/environment.rb 3 | 4 | # The production environment is meant for finished, "live" apps. 5 | # Code is not reloaded between requests 6 | config.cache_classes = true 7 | 8 | # Full error reports are disabled and caching is turned on 9 | config.consider_all_requests_local = false 10 | config.action_controller.perform_caching = true 11 | 12 | # Specifies the header that your server uses for sending files 13 | config.action_dispatch.x_sendfile_header = "X-Sendfile" 14 | 15 | # For nginx: 16 | # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' 17 | 18 | # If you have no front-end server that supports something like X-Sendfile, 19 | # just comment this out and Rails will serve the files 20 | 21 | # See everything in the log (default is :info) 22 | # config.log_level = :debug 23 | 24 | # Use a different logger for distributed setups 25 | # config.logger = SyslogLogger.new 26 | 27 | # Use a different cache store in production 28 | # config.cache_store = :mem_cache_store 29 | 30 | # Disable Rails's static asset server 31 | # In production, Apache or nginx will already do this 32 | config.serve_static_assets = false 33 | 34 | # Enable serving of images, stylesheets, and javascripts from an asset server 35 | # config.action_controller.asset_host = "http://assets.example.com" 36 | 37 | # Disable delivery errors, bad email addresses will be ignored 38 | # config.action_mailer.raise_delivery_errors = false 39 | 40 | # Enable threaded mode 41 | # config.threadsafe! 42 | 43 | # Enable locale fallbacks for I18n (makes lookups for any locale fall back to 44 | # the I18n.default_locale when a translation can not be found) 45 | config.i18n.fallbacks = true 46 | 47 | # Send deprecation notices to registered listeners 48 | config.active_support.deprecation = :notify 49 | end 50 | -------------------------------------------------------------------------------- /config/environments/test.rb: -------------------------------------------------------------------------------- 1 | RailsappVagrant::Application.configure do 2 | # Settings specified here will take precedence over those in config/environment.rb 3 | 4 | # The test environment is used exclusively to run your application's 5 | # test suite. You never need to work with it otherwise. Remember that 6 | # your test database is "scratch space" for the test suite and is wiped 7 | # and recreated between test runs. Don't rely on the data there! 8 | config.cache_classes = true 9 | 10 | # Log error messages when you accidentally call methods on nil. 11 | config.whiny_nils = true 12 | 13 | # Show full error reports and disable caching 14 | config.consider_all_requests_local = true 15 | config.action_controller.perform_caching = false 16 | 17 | # Raise exceptions instead of rendering exception templates 18 | config.action_dispatch.show_exceptions = false 19 | 20 | # Disable request forgery protection in test environment 21 | config.action_controller.allow_forgery_protection = false 22 | 23 | # Tell Action Mailer not to deliver emails to the real world. 24 | # The :test delivery method accumulates sent emails in the 25 | # ActionMailer::Base.deliveries array. 26 | config.action_mailer.delivery_method = :test 27 | 28 | # Use SQL instead of Active Record's schema dumper when creating the test database. 29 | # This is necessary if your schema can't be completely dumped by the schema dumper, 30 | # like if you have constraints or database-specific column types 31 | # config.active_record.schema_format = :sql 32 | 33 | # Print deprecation notices to the stderr 34 | config.active_support.deprecation = :stderr 35 | end 36 | -------------------------------------------------------------------------------- /config/initializers/backtrace_silencers.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. 4 | # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } 5 | 6 | # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code. 7 | # Rails.backtrace_cleaner.remove_silencers! 8 | -------------------------------------------------------------------------------- /config/initializers/inflections.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Add new inflection rules using the following format 4 | # (all these examples are active by default): 5 | # ActiveSupport::Inflector.inflections do |inflect| 6 | # inflect.plural /^(ox)$/i, '\1en' 7 | # inflect.singular /^(ox)en/i, '\1' 8 | # inflect.irregular 'person', 'people' 9 | # inflect.uncountable %w( fish sheep ) 10 | # end 11 | -------------------------------------------------------------------------------- /config/initializers/mime_types.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Add new mime types for use in respond_to blocks: 4 | # Mime::Type.register "text/richtext", :rtf 5 | # Mime::Type.register_alias "text/html", :iphone 6 | -------------------------------------------------------------------------------- /config/initializers/secret_token.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Your secret key for verifying the integrity of signed cookies. 4 | # If you change this key, all old signed cookies will become invalid! 5 | # Make sure the secret is at least 30 characters and all random, 6 | # no regular words or you'll be exposed to dictionary attacks. 7 | RailsappVagrant::Application.config.secret_token = '49693e8c5f372c5c66d76836f63304a9ae3a6e70a89a4dc8378c9a1c02aab699d711977ac7a0a7f7dbd264e97817571630dd02036f5acfa2598d24bbacbe298b' 8 | -------------------------------------------------------------------------------- /config/initializers/session_store.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | RailsappVagrant::Application.config.session_store :cookie_store, :key => '_railsapp-vagrant_session' 4 | 5 | # Use the database for sessions instead of the cookie-based default, 6 | # which shouldn't be used to store highly confidential information 7 | # (create the session table with "rake db:sessions:create") 8 | # RailsappVagrant::Application.config.session_store :active_record_store 9 | -------------------------------------------------------------------------------- /config/locales/en.yml: -------------------------------------------------------------------------------- 1 | # Sample localization file for English. Add more files in this directory for other locales. 2 | # See http://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points. 3 | 4 | en: 5 | hello: "Hello world" 6 | -------------------------------------------------------------------------------- /config/routes.rb: -------------------------------------------------------------------------------- 1 | RailsappVagrant::Application.routes.draw do 2 | # The priority is based upon order of creation: 3 | # first created -> highest priority. 4 | 5 | # Sample of regular route: 6 | # match 'products/:id' => 'catalog#view' 7 | # Keep in mind you can assign values other than :controller and :action 8 | 9 | # Sample of named route: 10 | # match 'products/:id/purchase' => 'catalog#purchase', :as => :purchase 11 | # This route can be invoked with purchase_url(:id => product.id) 12 | 13 | # Sample resource route (maps HTTP verbs to controller actions automatically): 14 | # resources :products 15 | 16 | # Sample resource route with options: 17 | # resources :products do 18 | # member do 19 | # get 'short' 20 | # post 'toggle' 21 | # end 22 | # 23 | # collection do 24 | # get 'sold' 25 | # end 26 | # end 27 | 28 | # Sample resource route with sub-resources: 29 | # resources :products do 30 | # resources :comments, :sales 31 | # resource :seller 32 | # end 33 | 34 | # Sample resource route with more complex sub-resources 35 | # resources :products do 36 | # resources :comments 37 | # resources :sales do 38 | # get 'recent', :on => :collection 39 | # end 40 | # end 41 | 42 | # Sample resource route within a namespace: 43 | # namespace :admin do 44 | # # Directs /admin/products/* to Admin::ProductsController 45 | # # (app/controllers/admin/products_controller.rb) 46 | # resources :products 47 | # end 48 | 49 | # You can have the root of your site routed with "root" 50 | # just remember to delete public/index.html. 51 | # root :to => "welcome#index" 52 | 53 | # See how all your routes lay out with "rake routes" 54 | 55 | # This is a legacy wild controller route that's not recommended for RESTful applications. 56 | # Note: This route will make all actions in every controller accessible via GET requests. 57 | # match ':controller(/:action(/:id(.:format)))' 58 | end 59 | -------------------------------------------------------------------------------- /cookbooks/apt/README.md: -------------------------------------------------------------------------------- 1 | DESCRIPTION 2 | =========== 3 | 4 | Configures various APT components on Debian-like systems. 5 | 6 | RECIPES 7 | ======= 8 | 9 | default 10 | ------- 11 | 12 | The default recipe runs apt-get update during the Compile Phase of the Chef run to ensure that the system's package cache is updated with the latest. It is recommended that this recipe appear first in a node's run list (directly or through a role) to ensure that when installing packages, Chef will be able to download the latest version available on the remote APT repository. 13 | 14 | This recipe also sets up a local cache directory for preseeding packages. 15 | 16 | cacher 17 | ------ 18 | 19 | Installs the apt-cacher package and service so the system can be an APT cache. 20 | 21 | proxy 22 | ----- 23 | 24 | Installs the apt-proxy package and service so the system can be an APT proxy. 25 | 26 | USAGE 27 | ===== 28 | 29 | Put `recipe[apt]` first in the run list. If you have other recipes that you want to use to configure how apt behaves, like new sources, notify the execute resource to run, e.g.: 30 | 31 | template "/etc/apt/sources.list.d/my_apt_sources.list" do 32 | notifies :run, resources(:execute => "apt-get update"), :immediately 33 | end 34 | 35 | The above will run during execution phase since it is a normal template resource, and should appear before other package resources that need the sources in the template. 36 | 37 | LICENSE AND AUTHOR 38 | ================== 39 | 40 | Author:: Joshua Timberman () 41 | 42 | Copyright 2009, Opscode, Inc. 43 | 44 | Licensed under the Apache License, Version 2.0 (the "License"); 45 | you may not use this file except in compliance with the License. 46 | You may obtain a copy of the License at 47 | 48 | http://www.apache.org/licenses/LICENSE-2.0 49 | 50 | Unless required by applicable law or agreed to in writing, software 51 | distributed under the License is distributed on an "AS IS" BASIS, 52 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 53 | See the License for the specific language governing permissions and 54 | limitations under the License. 55 | 56 | -------------------------------------------------------------------------------- /cookbooks/apt/files/default/apt-cacher: -------------------------------------------------------------------------------- 1 | # apt-cacher startup configuration file 2 | 3 | # IMPORTANT: check the apt-cacher.conf file before using apt-cacher as daemon. 4 | 5 | # set to 1 to start the daemon at boot time 6 | AUTOSTART=1 7 | 8 | # extra settings to override the ones in apt-cacher.conf 9 | # EXTRAOPT=" daemon_port=3142 limit=30 " 10 | -------------------------------------------------------------------------------- /cookbooks/apt/files/default/apt-cacher.conf: -------------------------------------------------------------------------------- 1 | # This file has been modified by ./apt-proxy-to-apt-cacher 2 | # Some lines may have been appended at the bottom of this file 3 | # This file has been modified by /usr/share/apt-cacher/apt-proxy-to-apt-cacher 4 | # Some lines may have been appended at the bottom of this file 5 | ################################################################# 6 | # This is the config file for apt-cacher. On most Debian systems 7 | # you can safely leave the defaults alone. 8 | ################################################################# 9 | 10 | # cache_dir is used to set the location of the local cache. This can 11 | # become quite large, so make sure it is somewhere with plenty of space. 12 | cache_dir=/var/cache/apt-cacher 13 | 14 | # The email address of the administrator is displayed in the info page 15 | # and traffic reports. 16 | admin_email=root@localhost 17 | 18 | # For the daemon startup settings please edit the file /etc/default/apt-cacher. 19 | 20 | # Daemon port setting, only useful in stand-alone mode. You need to run the 21 | # daemon as root to use privileged ports (<1024). 22 | daemon_port = 3142 23 | 24 | # optional settings, user and group to run the daemon as. Make sure they have 25 | # sufficient permissions on the cache and log directories. Comment the settings 26 | # to run apt-cacher as the native user. 27 | group=www-data 28 | user=www-data 29 | 30 | # optional setting, binds the listening daemon to one specified IP. Use IP 31 | # ranges for more advanced configuration, see below. 32 | # daemon_addr=localhost 33 | 34 | # If your apt-cacher machine is directly exposed to the Internet and you are 35 | # worried about unauthorised machines fetching packages through it, you can 36 | # specify a list of IPv4 addresses which are allowed to use it and another 37 | # list of IPv4 addresses which aren't. 38 | # Localhost (127.0.0.1) is always allowed. Other addresses must be matched 39 | # by allowed_hosts and not by denied_hosts to be permitted to use the cache. 40 | # Setting allowed_hosts to "*" means "allow all". 41 | # Otherwise the format is a comma-separated list containing addresses, 42 | # optionally with masks (like 10.0.0.0/22), or ranges of addresses (two 43 | # addresses separated by a hyphen, no masks, like '192.168.0.3-192.168.0.56'). 44 | allowed_hosts=* 45 | denied_hosts= 46 | 47 | # And similiarly for IPv6 with allowed_hosts_6 and denied_hosts_6. 48 | # Note that IPv4-mapped IPv6 addresses (::ffff:w.x.y.z) are truncated to 49 | # w.x.y.z and are handled as IPv4. 50 | allowed_hosts_6=fec0::/16 51 | denied_hosts_6= 52 | 53 | # This thing can be done by Apache but is much simplier here - limit access to 54 | # Debian mirrors based on server names in the URLs 55 | #allowed_locations=ftp.uni-kl.de,ftp.nerim.net,debian.tu-bs.de 56 | 57 | # Apt-cacher can generate usage reports every 24 hours if you set this 58 | # directive to 1. You can view the reports in a web browser by pointing 59 | # to your cache machine with '/apt-cacher/report' on the end, like this: 60 | # http://yourcache.example.com/apt-cacher/report 61 | # Generating reports is very fast even with many thousands of logfile 62 | # lines, so you can safely turn this on without creating much 63 | # additional system load. 64 | generate_reports=1 65 | 66 | # Apt-cacher can clean up its cache directory every 24 hours if you set 67 | # this directive to 1. Cleaning the cache can take some time to run 68 | # (generally in the order of a few minutes) and removes all package 69 | # files that are not mentioned in any existing 'Packages' lists. This 70 | # has the effect of deleting packages that have been superseded by an 71 | # updated 'Packages' list. 72 | clean_cache=1 73 | 74 | # The directory to use for apt-cacher access and error logs. 75 | # The access log records every request in the format: 76 | # date-time|client ip address|HIT/MISS/EXPIRED|object size|object name 77 | # The error log is slightly more free-form, and is also used for debug 78 | # messages if debug mode is turned on. 79 | # Note that the old 'logfile' and 'errorfile' directives are 80 | # deprecated: if you set them explicitly they will be honoured, but it's 81 | # better to just get rid of them from old config files. 82 | logdir=/var/log/apt-cacher 83 | 84 | # apt-cacher can use different methods to decide whether package lists need to 85 | # be updated, 86 | # A) looking at the age of the cached files 87 | # B) getting HTTP header from server and comparing that with cached data. This 88 | # method is more reliable and avoids desynchronisation of data and index files 89 | # but needs to transfer few bytes from the server every time somebody requests 90 | # the files ("apt-get update") 91 | # Set the following value to the maximum age (in hours) for method A or to 0 92 | # for method B 93 | expire_hours=0 94 | 95 | # Apt-cacher can pass all its requests to an external http proxy like 96 | # Squid, which could be very useful if you are using an ISP that blocks 97 | # port 80 and requires all web traffic to go through its proxy. The 98 | # format is 'hostname:port', eg: 'proxy.example.com:8080'. 99 | http_proxy=proxy.example.com:8080 100 | 101 | # Use of an external proxy can be turned on or off with this flag. 102 | # Value should be either 0 (off) or 1 (on). 103 | use_proxy=0 104 | 105 | # External http proxy sometimes need authentication to get full access. The 106 | # format is 'username:password'. 107 | http_proxy_auth=proxyuser:proxypass 108 | 109 | # Use of external proxy authentication can be turned on or off with this flag. 110 | # Value should be either 0 (off) or 1 (on). 111 | use_proxy_auth=0 112 | 113 | # Rate limiting sets the maximum bandwidth in bytes per second to use 114 | # for fetching packages. Syntax is fully defined in 'man wget'. 115 | # Use 'k' or 'm' to use kilobits or megabits / second: eg, 'limit=25k'. 116 | # Use 0 or a negative value for no rate limiting. 117 | limit=0 118 | 119 | # Debug mode makes apt-cacher spew a lot of extra debug junk to the 120 | # error log (whose location is defined with the 'logdir' directive). 121 | # Leave this off unless you need it, or your error log will get very 122 | # big. Acceptable values are 0 or 1. 123 | debug=0 124 | 125 | # Adapt the line in the usage info web page to match your server configuration 126 | # example_sources_line=deb http://my.cacher.server:3142/ftp.au.debian.org/debian unstable main contrib non-free 127 | 128 | # Print a 410 (Gone) HTTP message with the specified text when accessed via 129 | # CGI. Useful to tell users to adapt their sources.list files when the 130 | # apt-cacher server is beeing relocated (via apt-get's error messages while 131 | # running "update") 132 | #cgi_advise_to_use = Please use http://cacheserver:3142/ as apt-cacher access URL 133 | #cgi_advise_to_use = Server relocated. To change sources.list, run perl -pe "s,/apt-cacher\??,:3142," -i /etc/apt/sources.list 134 | 135 | # Server mapping - this allows to hide real server names behind virtual paths 136 | # that appear in the access URL. This method is known from apt-proxy. This is 137 | # also the only method to use FTP access to the target hosts. The syntax is simple, the part of the beginning to replace, followed by a list of mirror urls, all space separated. Multiple profile are separated by semicolons 138 | # path_map = debian ftp.uni-kl.de/pub/linux/debian ftp2.de.debian.org/debian ; ubuntu archive.ubuntu.com/ubuntu ; security security.debian.org/debian-security ftp2.de.debian.org/debian-security 139 | # Note that you need to specify all target servers in the allowed_locations 140 | # options if you make use of it. Also note that the paths should not overlap 141 | # each other. FTP access method not supported yet, maybe in the future. 142 | 143 | # extra setting from apt-proxy configuration 144 | path_map = ubuntu us.archive.ubuntu.com/ubuntu ; ubuntu-security security.ubuntu.com/ubuntu ; debian debian.osuosl.org/debian/ ; security security.debian.org/debian-security 145 | -------------------------------------------------------------------------------- /cookbooks/apt/files/default/apt-proxy-v2.conf: -------------------------------------------------------------------------------- 1 | [DEFAULT] 2 | ;; All times are in seconds, but you can add a suffix 3 | ;; for minutes(m), hours(h) or days(d) 4 | 5 | ;; commented out address so apt-proxy will listen on all IPs 6 | ;; address = 127.0.0.1 7 | port = 9999 8 | cache_dir = /var/cache/apt-proxy 9 | 10 | ;; Control files (Packages/Sources/Contents) refresh rate 11 | min_refresh_delay = 1s 12 | complete_clientless_downloads = 1 13 | 14 | ;; Debugging settings. 15 | debug = all:4 db:0 16 | 17 | time = 30 18 | passive_ftp = on 19 | 20 | ;;-------------------------------------------------------------- 21 | ;; Cache housekeeping 22 | 23 | cleanup_freq = 1d 24 | max_age = 120d 25 | max_versions = 3 26 | 27 | ;;--------------------------------------------------------------- 28 | ;; Backend servers 29 | ;; 30 | ;; Place each server in its own [section] 31 | 32 | [ubuntu] 33 | ; Ubuntu archive 34 | backends = 35 | http://us.archive.ubuntu.com/ubuntu 36 | 37 | [ubuntu-security] 38 | ; Ubuntu security updates 39 | backends = http://security.ubuntu.com/ubuntu 40 | 41 | [debian] 42 | ;; Backend servers, in order of preference 43 | backends = 44 | http://debian.osuosl.org/debian/ 45 | 46 | [security] 47 | ;; Debian security archive 48 | backends = 49 | http://security.debian.org/debian-security 50 | http://ftp2.de.debian.org/debian-security 51 | -------------------------------------------------------------------------------- /cookbooks/apt/metadata.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": { 3 | }, 4 | "attributes": { 5 | }, 6 | "maintainer": "Opscode, Inc.", 7 | "suggestions": { 8 | }, 9 | "dependencies": { 10 | }, 11 | "maintainer_email": "cookbooks@opscode.com", 12 | "conflicting": { 13 | }, 14 | "platforms": { 15 | "debian": [ 16 | 17 | ], 18 | "ubuntu": [ 19 | 20 | ] 21 | }, 22 | "license": "Apache 2.0", 23 | "version": "0.9.1", 24 | "providing": { 25 | }, 26 | "recipes": { 27 | "apt::proxy": "Set up an APT proxy", 28 | "apt": "Runs apt-get update during compile phase and sets up preseed directories", 29 | "apt::cacher": "Set up an APT cache" 30 | }, 31 | "replacing": { 32 | }, 33 | "name": "apt", 34 | "description": "Configures apt and apt services", 35 | "groupings": { 36 | }, 37 | "long_description": "" 38 | } -------------------------------------------------------------------------------- /cookbooks/apt/metadata.rb: -------------------------------------------------------------------------------- 1 | maintainer "Opscode, Inc." 2 | maintainer_email "cookbooks@opscode.com" 3 | license "Apache 2.0" 4 | description "Configures apt and apt services" 5 | version "0.9.1" 6 | recipe "apt", "Runs apt-get update during compile phase and sets up preseed directories" 7 | recipe "apt::cacher", "Set up an APT cache" 8 | recipe "apt::proxy", "Set up an APT proxy" 9 | 10 | %w{ ubuntu debian }.each do |os| 11 | supports os 12 | end 13 | -------------------------------------------------------------------------------- /cookbooks/apt/recipes/cacher.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: apt 3 | # Recipe:: cacher 4 | # 5 | # Copyright 2008-2009, Opscode, Inc. 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | package "apt-cacher" do 20 | action :install 21 | end 22 | 23 | service "apt-cacher" do 24 | supports :restart => true, :status => false 25 | action [ :enable, :start ] 26 | end 27 | 28 | cookbook_file "/etc/apt-cacher/apt-cacher.conf" do 29 | source "apt-cacher.conf" 30 | owner "root" 31 | group "root" 32 | mode 0644 33 | notifies :restart, resources(:service => "apt-cacher") 34 | end 35 | 36 | cookbook_file "/etc/default/apt-cacher" do 37 | source "apt-cacher" 38 | owner "root" 39 | group "root" 40 | mode 0644 41 | notifies :restart, resources(:service => "apt-cacher") 42 | end 43 | -------------------------------------------------------------------------------- /cookbooks/apt/recipes/default.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: apt 3 | # Recipe:: default 4 | # 5 | # Copyright 2008-2009, Opscode, Inc. 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | 20 | e = execute "apt-get update" do 21 | action :nothing 22 | end 23 | 24 | e.run_action(:run) 25 | 26 | %w{/var/cache/local /var/cache/local/preseeding}.each do |dirname| 27 | directory dirname do 28 | owner "root" 29 | group "root" 30 | mode 0755 31 | action :create 32 | end 33 | end 34 | -------------------------------------------------------------------------------- /cookbooks/apt/recipes/proxy.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: apt 3 | # Recipe:: proxy 4 | # 5 | # Copyright 2008-2009, Opscode, Inc. 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | package "apt-proxy" do 20 | action :install 21 | end 22 | 23 | service "apt-proxy" do 24 | supports :restart => true, :status => false 25 | action [ :enable, :start ] 26 | end 27 | 28 | cookbook_file "/etc/apt-proxy/apt-proxy-v2.conf" do 29 | source "apt-proxy-v2.conf" 30 | owner "root" 31 | group "root" 32 | mode 0644 33 | notifies :restart, resources(:service => "apt-proxy") 34 | end 35 | -------------------------------------------------------------------------------- /cookbooks/git/README.rdoc: -------------------------------------------------------------------------------- 1 | = DESCRIPTION: 2 | 3 | Installs git. 4 | 5 | = REQUIREMENTS: 6 | 7 | == Cookbooks: 8 | 9 | Opscode Cookbooks (http://github.com/opscode/cookbooks/tree/master) 10 | 11 | * runit 12 | 13 | = USAGE: 14 | 15 | This cookbook primarily installs git core packages. It can also be used to serve git repositories. 16 | 17 | include_recipe "git::server" 18 | 19 | This creates the directory /srv/git and starts a git daemon, exporting all repositories found. Repositories need to be added manually, but will be available once they are created. 20 | 21 | = LICENSE and AUTHOR: 22 | 23 | Author:: Joshua Timberman () 24 | 25 | Copyright:: 2009, Opscode, Inc 26 | 27 | Licensed under the Apache License, Version 2.0 (the "License"); 28 | you may not use this file except in compliance with the License. 29 | You may obtain a copy of the License at 30 | 31 | http://www.apache.org/licenses/LICENSE-2.0 32 | 33 | Unless required by applicable law or agreed to in writing, software 34 | distributed under the License is distributed on an "AS IS" BASIS, 35 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 36 | See the License for the specific language governing permissions and 37 | limitations under the License. -------------------------------------------------------------------------------- /cookbooks/git/metadata.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "git", 3 | "description": "Installs git and/or sets up a Git server daemon", 4 | "long_description": "= DESCRIPTION:\n\nInstalls git.\n\n= REQUIREMENTS:\n\n== Cookbooks:\n\nOpscode Cookbooks (http://github.com/opscode/cookbooks/tree/master)\n\n* runit\n\n= USAGE:\n\nThis cookbook primarily installs git core packages. It can also be used to serve git repositories.\n\n include_recipe \"git::server\"\n\nThis creates the directory /srv/git and starts a git daemon, exporting all repositories found. Repositories need to be added manually, but will be available once they are created.\n\n= LICENSE and AUTHOR:\n \nAuthor:: Joshua Timberman ()\n\nCopyright:: 2009, Opscode, Inc\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.", 5 | "maintainer": "Opscode, Inc.", 6 | "maintainer_email": "cookbooks@opscode.com", 7 | "license": "Apache 2.0", 8 | "platforms": { 9 | "ubuntu": [ 10 | 11 | ], 12 | "debian": [ 13 | 14 | ], 15 | "arch": [ 16 | 17 | ] 18 | }, 19 | "dependencies": { 20 | "runit": [ 21 | 22 | ] 23 | }, 24 | "recommendations": { 25 | }, 26 | "suggestions": { 27 | }, 28 | "conflicting": { 29 | }, 30 | "providing": { 31 | }, 32 | "replacing": { 33 | }, 34 | "attributes": { 35 | }, 36 | "groupings": { 37 | }, 38 | "recipes": { 39 | "git": "Installs git", 40 | "git::server": "Sets up a runit_service for git daemon" 41 | }, 42 | "version": "0.9.0" 43 | } -------------------------------------------------------------------------------- /cookbooks/git/metadata.rb: -------------------------------------------------------------------------------- 1 | maintainer "Opscode, Inc." 2 | maintainer_email "cookbooks@opscode.com" 3 | license "Apache 2.0" 4 | description "Installs git and/or sets up a Git server daemon" 5 | long_description IO.read(File.join(File.dirname(__FILE__), 'README.rdoc')) 6 | version "0.9.0" 7 | recipe "git", "Installs git" 8 | recipe "git::server", "Sets up a runit_service for git daemon" 9 | 10 | %w{ ubuntu debian arch}.each do |os| 11 | supports os 12 | end 13 | 14 | %w{ runit }.each do |cb| 15 | depends cb 16 | end 17 | -------------------------------------------------------------------------------- /cookbooks/git/recipes/default.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: git 3 | # Recipe:: default 4 | # 5 | # Copyright 2008-2009, Opscode, Inc. 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | 19 | case node[:platform] 20 | when "debian", "ubuntu" 21 | package "git-core" 22 | else 23 | package "git" 24 | end 25 | -------------------------------------------------------------------------------- /cookbooks/git/recipes/server.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: git 3 | # Recipe:: server 4 | # 5 | # Copyright 2009, Opscode, Inc. 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | 19 | include_recipe "git" 20 | 21 | directory "/srv/git" do 22 | owner "root" 23 | group "root" 24 | mode 0755 25 | end 26 | 27 | case node[:platform] 28 | when "debian", "ubuntu" 29 | include_recipe "runit" 30 | runit_service "git-daemon" 31 | else 32 | log "Platform requires setting up a git daemon service script." 33 | log "Hint: /usr/bin/git daemon --export-all --user=nobody --group=daemon --base-path=/srv/git" 34 | end 35 | -------------------------------------------------------------------------------- /cookbooks/git/templates/default/sv-git-daemon-log-run.erb: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | exec svlogd -tt ./main 3 | -------------------------------------------------------------------------------- /cookbooks/git/templates/default/sv-git-daemon-run.erb: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | exec 2>&1 3 | exec /usr/bin/git daemon --export-all --user=nobody --group=daemon --base-path=/srv/git /srv/git 4 | -------------------------------------------------------------------------------- /cookbooks/java/README.md: -------------------------------------------------------------------------------- 1 | Description 2 | =========== 3 | 4 | Installs a Java. Uses OpenJDK by default but supports installation of the Sun's Java (Debian and Ubuntu platforms only). 5 | 6 | Requirements 7 | ============ 8 | 9 | Platform: 10 | 11 | * Debian, Ubuntu (OpenJDK, Sun) 12 | * CentOS, Red Hat, Fedora (OpenJDK) 13 | 14 | The following Opscode cookbooks are dependencies: 15 | 16 | * apt 17 | 18 | Attributes 19 | ========== 20 | 21 | * `node["java"]["install_flavor"]` - Type of JRE you would like installed ("sun" or "openjdk"), default "openjdk". 22 | 23 | Usage 24 | ===== 25 | 26 | Simply include the recipe where you want Java installed. 27 | 28 | If you would like to use the Sun flavor of Java, create a role and set the `java[install_flavor]` attribute to `'sun'`. 29 | 30 | % knife role show java 31 | { 32 | "name": "java", 33 | "chef_type": "role", 34 | "json_class": "Chef::Role", 35 | "default_attributes": { 36 | "java": { 37 | "install_flavor":"sun" 38 | } 39 | }, 40 | "description": "", 41 | "run_list": [ 42 | "recipe[java]" 43 | ], 44 | "override_attributes": { 45 | } 46 | } 47 | 48 | The Sun flavor of Java is only supported on Debian and Ubuntu systems, the recipe will preseed the package and update java alternatives. 49 | 50 | License and Author 51 | ================== 52 | 53 | Author:: Seth Chisamore () 54 | 55 | Copyright:: 2008-2010, Opscode, Inc 56 | 57 | Licensed under the Apache License, Version 2.0 (the "License"); 58 | you may not use this file except in compliance with the License. 59 | You may obtain a copy of the License at 60 | 61 | http://www.apache.org/licenses/LICENSE-2.0 62 | 63 | Unless required by applicable law or agreed to in writing, software 64 | distributed under the License is distributed on an "AS IS" BASIS, 65 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 66 | See the License for the specific language governing permissions and 67 | limitations under the License. 68 | -------------------------------------------------------------------------------- /cookbooks/java/attributes/default.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: java 3 | # Attributes:: default 4 | # 5 | # Copyright 2010, Opscode, Inc. 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | 19 | default["java"]["install_flavor"] = "openjdk" 20 | 21 | case platform 22 | when "centos","redhat","fedora" 23 | set["java"]["java_home"] = "/usr/lib/jvm/java" 24 | else 25 | set["java"]["java_home"] = "/usr/lib/jvm/default-java" 26 | end -------------------------------------------------------------------------------- /cookbooks/java/files/default/java.seed: -------------------------------------------------------------------------------- 1 | sun-java6-bin shared/accepted-sun-dlj-v1-1 boolean true 2 | sun-java6-jdk shared/accepted-sun-dlj-v1-1 boolean true 3 | sun-java6-jre shared/accepted-sun-dlj-v1-1 boolean true 4 | sun-java6-jre sun-java6-jre/stopthread boolean true 5 | sun-java6-jre sun-java6-jre/jcepolicy note 6 | sun-java6-bin shared/error-sun-dlj-v1-1 error 7 | sun-java6-jdk shared/error-sun-dlj-v1-1 error 8 | sun-java6-jre shared/error-sun-dlj-v1-1 error 9 | sun-java6-bin shared/present-sun-dlj-v1-1 note 10 | sun-java6-jdk shared/present-sun-dlj-v1-1 note 11 | sun-java6-jre shared/present-sun-dlj-v1-1 note -------------------------------------------------------------------------------- /cookbooks/java/metadata.json: -------------------------------------------------------------------------------- 1 | { 2 | "providing": { 3 | }, 4 | "maintainer": "Opscode, Inc.", 5 | "replacing": { 6 | }, 7 | "description": "Installs java via openjdk.", 8 | "maintainer_email": "cookbooks@opscode.com", 9 | "groupings": { 10 | }, 11 | "attributes": { 12 | }, 13 | "recommendations": { 14 | }, 15 | "dependencies": { 16 | "apt": [ 17 | 18 | ] 19 | }, 20 | "suggestions": { 21 | }, 22 | "long_description": "Description\n===========\n\nInstalls a Java. Uses OpenJDK by default but supports installation of the Sun's Java (Debian and Ubuntu platforms only).\n\nRequirements\n============\n\nPlatform: \n\n* Debian, Ubuntu (OpenJDK, Sun)\n* CentOS, Red Hat, Fedora (OpenJDK)\n\nThe following Opscode cookbooks are dependencies:\n\n* apt\n\nAttributes\n==========\n\n* `node[\"java\"][\"install_flavor\"]` - Type of JRE you would like installed (\"sun\" or \"openjdk\"), default \"openjdk\".\n\nUsage\n=====\n\nSimply include the recipe where you want Java installed.\n\nIf you would like to use the Sun flavor of Java, create a role and set the `java[install_flavor]` attribute to `'sun'`. \n\n % knife role show java\n {\n \"name\": \"java\",\n \"chef_type\": \"role\",\n \"json_class\": \"Chef::Role\",\n \"default_attributes\": {\n \"java\": {\n \"install_flavor\":\"sun\"\n }\n },\n \"description\": \"\",\n \"run_list\": [\n \"recipe[java]\"\n ],\n \"override_attributes\": {\n }\n }\n\nThe Sun flavor of Java is only supported on Debian and Ubuntu systems, the recipe will preseed the package and update java alternatives.\n\nLicense and Author\n==================\n\nAuthor:: Seth Chisamore ()\n\nCopyright:: 2008-2010, Opscode, Inc\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n", 23 | "platforms": { 24 | "debian": [ 25 | 26 | ], 27 | "fedora": [ 28 | 29 | ], 30 | "centos": [ 31 | 32 | ], 33 | "ubuntu": [ 34 | 35 | ], 36 | "redhat": [ 37 | 38 | ] 39 | }, 40 | "name": "java", 41 | "version": "0.10.2", 42 | "conflicting": { 43 | }, 44 | "license": "Apache 2.0", 45 | "recipes": { 46 | "java": "Installs openjdk to provide Java" 47 | } 48 | } -------------------------------------------------------------------------------- /cookbooks/java/metadata.rb: -------------------------------------------------------------------------------- 1 | maintainer "Opscode, Inc." 2 | maintainer_email "cookbooks@opscode.com" 3 | license "Apache 2.0" 4 | description "Installs java via openjdk." 5 | long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) 6 | version "0.10.2" 7 | depends "apt" 8 | %w{ debian ubuntu centos redhat fedora }.each do |os| 9 | supports os 10 | end 11 | recipe "java", "Installs openjdk to provide Java" -------------------------------------------------------------------------------- /cookbooks/java/recipes/default.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: java 3 | # Recipe:: default 4 | # 5 | # Copyright 2008-2010, Opscode, Inc. 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | include_recipe "java::#{node["java"]["install_flavor"]}" 20 | 21 | current_java_version_pattern = (node.java.install_flavor == 'sun') ? /Java HotSpot\(TM\)/ : /^OpenJDK/ 22 | 23 | # force ohai to run and pick up new languages.java data 24 | ruby_block "reload_ohai" do 25 | block do 26 | o = Ohai::System.new 27 | o.all_plugins 28 | node.automatic_attrs.merge! o.data 29 | end 30 | action :nothing 31 | end 32 | 33 | execute "update-java-alternatives" do 34 | command "update-java-alternatives --jre -s java-6-#{node["java"]["install_flavor"]}" 35 | returns 0 36 | only_if do platform?("ubuntu", "debian") end 37 | action :nothing 38 | notifies :create, resources(:ruby_block => "reload_ohai") 39 | end 40 | 41 | node.run_state[:java_pkgs].each do |pkg| 42 | package pkg do 43 | action :install 44 | if platform?("ubuntu", "debian") 45 | if node.java.install_flavor == "sun" 46 | response_file "java.seed" 47 | end 48 | notifies :run, resources(:execute => "update-java-alternatives"), :delayed 49 | end 50 | end 51 | end 52 | 53 | # re-run update-java-alternatives if our java flavor changes 54 | if node.languages.attribute?("java") 55 | unless node.languages.java.hotspot.name.match(current_java_version_pattern) 56 | log "Java install_flavor has changed, re-running 'update-java-alternatives'" do 57 | level :info 58 | notifies :run, resources(:execute => "update-java-alternatives"), :delayed 59 | end 60 | end 61 | end 62 | 63 | node.run_state.delete(:java_pkgs) 64 | -------------------------------------------------------------------------------- /cookbooks/java/recipes/openjdk.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: java 3 | # Recipe:: openjdk 4 | # 5 | # Copyright 2010, Opscode, Inc. 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | 19 | node.run_state[:java_pkgs] = value_for_platform( 20 | ["debian","ubuntu"] => { 21 | "default" => ["openjdk-6-jre","default-jre","icedtea6-plugin"] # icedtea6-plugin included to make update-java-alternatives work correctly 22 | }, 23 | ["centos","redhat","fedora"] => { 24 | "default" => ["java-1.6.0-openjdk","java-1.6.0-openjdk-devel"] 25 | }, 26 | "default" => ["openjdk-6-jre-headless","default-jre-headless","default-jre"] 27 | ) 28 | -------------------------------------------------------------------------------- /cookbooks/java/recipes/sun.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: java 3 | # Recipe:: sun 4 | # 5 | # Copyright 2010, Opscode, Inc. 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | 19 | node.run_state[:java_pkgs] = value_for_platform( 20 | ["debian","ubuntu"] => { 21 | "default" => ["sun-java6-jre","default-jre-headless"] 22 | }, 23 | "default" => ["sun-java6-jre"] 24 | ) 25 | 26 | case node.platform 27 | when "debian","ubuntu" 28 | include_recipe "apt" 29 | 30 | template "/etc/apt/sources.list.d/canonical.com.list" do 31 | mode "0644" 32 | source "canonical.com.list.erb" 33 | notifies :run, resources(:execute => "apt-get update"), :immediately 34 | end 35 | else 36 | Chef::Log.error("Installation of Sun Java packages are only supported on Debian/Ubuntu at this time.") 37 | end -------------------------------------------------------------------------------- /cookbooks/java/templates/ubuntu/canonical.com.list.erb: -------------------------------------------------------------------------------- 1 | deb http://archive.canonical.com/ubuntu <%= node[:lsb][:codename] %> partner 2 | deb-src http://archive.canonical.com/ubuntu <%= node[:lsb][:codename] %> partner -------------------------------------------------------------------------------- /cookbooks/mysql/README.rdoc: -------------------------------------------------------------------------------- 1 | = DESCRIPTION: 2 | 3 | Installs and configures MySQL client or server. 4 | 5 | = REQUIREMENTS: 6 | 7 | == Platform: 8 | 9 | Best tested on Ubuntu 9.04,9.10. On EC2, requires platform that supports -o bind option for the 'mount' command. 10 | 11 | == Cookbooks: 12 | 13 | Requires Opscode's openssl cookbook for secure password generation. 14 | 15 | Requires a C compiler and Ruby development package in order to build mysql gem with native extensions. On Debian and Ubuntu systems this is satisfied by installing the "build-essential" and "ruby-dev" packages before running Chef. See USAGE below for information on how to handle this during a Chef run. 16 | 17 | = RESOURCES AND PROVIDERS 18 | 19 | The cookbook contains a LWRP, +mysql_database+ which can be used to manage databases through calls to the MySQL API. The mysql gem is installed to make this usable. The provider currently supports three actions: 20 | 21 | * +flush_tables_with_read_lock+ - sends the sql command "flush tables with read lock", used for setting up mysql master/slave replication. 22 | * +unflush_tables+ - sends the sql command "unflush tables", used for setting up master/slave replication. 23 | * +create_db+ - specify a database to be created. 24 | 25 | For example see the USAGE section below. 26 | 27 | = ATTRIBUTES: 28 | 29 | * +mysql[:server_root_password]+ - Set the server's root password with this, default is a randomly generated password with +OpenSSL::Random.random_bytes+. 30 | * +mysql[:server_repl_password]+ - Set the replication user 'repl' password with this, default is a randomly generated password with +OpenSSL::Random.random_bytes+. 31 | * +mysql[:server_debian_password]+ - Set the debian-sys-maint user password with this, default is a randomly generated password with +OpenSSL::Random.random_bytes+. 32 | * +mysql[:bind_address]+ - Listen address for MySQLd, default is node's ipaddress. 33 | * +mysql[:datadir]+ - Location for mysql data directory, default is "/var/lib/mysql" 34 | * +mysql[:ec2_path]+ - location of mysql datadir on EC2 nodes, default "/mnt/mysql" 35 | 36 | Performance tuning attributes, each corresponds to the same-named parameter in my.cnf; default values listed 37 | 38 | * +mysql[:tunable][:key_buffer]+ = "250M" 39 | * +mysql[:tunable][:max_connections]+ = "800" 40 | * +mysql[:tunable][:wait_timeout]+ = "180" 41 | * +mysql[:tunable][:net_write_timeout]+ = "30" 42 | * +mysql[:tunable][:net_write_timeout]+ = "30" 43 | * +mysql[:tunable][:back_log]+ = "128" 44 | * +mysql[:tunable][:table_cache]+ = "128" 45 | * +mysql[:tunable][:max_heap_table_size]+ = "32M" 46 | 47 | = USAGE: 48 | 49 | On client nodes, 50 | 51 | include_recipe "mysql::client" 52 | 53 | This will install the MySQL client libraries and development headers on the system. It will also install the Ruby Gem +mysql+, so that the cookbook's LWRP (above) can be used. This is done during the compile-phase of the Chef run. 54 | 55 | r = package ... do 56 | action :nothing 57 | end 58 | 59 | r.run_action(:install) 60 | 61 | This creates a resource object for the package and does the installation before other recipes are parsed. You'll need to have the C compiler and such (ie, build-essential on Ubuntu) before running the recipes, but we already do that when installing Chef :-). If you want to be able to access a MySQL database via Ruby within another recipe, you could do so, like so: 62 | 63 | Gem.clear_paths # needed for Chef to find the gem... 64 | require 'mysql' # requires the mysql gem 65 | 66 | mysql_database "create application_production database" do 67 | host "localhost" 68 | username "root" 69 | password node[:mysql][:server_root_password] 70 | database "application_production" 71 | action :create_db 72 | end 73 | 74 | This will connect to the MySQL server running on localhost as "root" and password as +mysql[:server_root_password]+ attribute (see below) and create the database specified with the +database+ parameter. The provider will attempt to determine whether the database exists first. 75 | 76 | On server nodes, 77 | 78 | include_recipe "mysql::server" 79 | 80 | On Debian and Ubuntu, this will preseed the mysql-server package with the randomly generated root password from the attributes file. On other platforms, it simply installs the required packages. It will also create an SQL file, /etc/mysql/grants.sql, that will be used to set up grants for the root, repl and debian-sys-maint users. 81 | 82 | On EC2 nodes, 83 | 84 | include_recipe "mysql::server_ec2" 85 | 86 | When the ec2_path doesn't exist we look for a mounted filesystem (eg, EBS) and move the datadir there. 87 | 88 | The client recipe is already included by server and 'default' recipes. 89 | 90 | To make sure that a C compiler and the Ruby development libraries are installed, use the following run list in the node or in a role: 91 | 92 | { 93 | "run_list": [ 94 | "recipe[build-essential]", 95 | "recipe[ruby]", 96 | "recipe[mysql::server]" 97 | ] 98 | } 99 | 100 | The build-essential and ruby cookbooks install the packages in question during the "execution" phase of the Chef client run, rather than the compile phase when the MySQL gem is installed. To work around this for now until the build-essential and ruby packages are updated, modify your local copies of the recipes: 101 | 102 | In the Opscode build-essential default recipe: 103 | 104 | %w{build-essential binutils-doc}.each do |pkg| 105 | p = package pkg do 106 | action :nothing 107 | end 108 | p.run_action(:install) 109 | end 110 | 111 | And the ruby recipe to have the following: 112 | 113 | extra_packages.each do |pkg| 114 | p = package pkg do 115 | action :nothing 116 | end 117 | p.run_action(:install) 118 | end 119 | 120 | These cookbooks aren't strict dependencies, and not if the installation process already included installing build-essential and ruby1.8-dev (e.g. RubyGems installation). 121 | 122 | For more infromation on the compile vs execution phase of a Chef run: 123 | 124 | http://wiki.opscode.com/display/chef/Anatomy+of+a+Chef+Run 125 | 126 | = LICENSE and AUTHOR: 127 | 128 | Author:: Joshua Timberman () 129 | Author:: AJ Christensen () 130 | 131 | Copyright:: 2009, Opscode, Inc 132 | 133 | Licensed under the Apache License, Version 2.0 (the "License"); 134 | you may not use this file except in compliance with the License. 135 | You may obtain a copy of the License at 136 | 137 | http://www.apache.org/licenses/LICENSE-2.0 138 | 139 | Unless required by applicable law or agreed to in writing, software 140 | distributed under the License is distributed on an "AS IS" BASIS, 141 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 142 | See the License for the specific language governing permissions and 143 | limitations under the License. 144 | -------------------------------------------------------------------------------- /cookbooks/mysql/attributes/server.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: mysql 3 | # Attributes:: server 4 | # 5 | # Copyright 2008-2009, Opscode, Inc. 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | 20 | ::Chef::Node.send(:include, Opscode::OpenSSL::Password) 21 | 22 | set_unless[:mysql][:server_debian_password] = secure_password 23 | set_unless[:mysql][:server_root_password] = secure_password 24 | set_unless[:mysql][:server_repl_password] = secure_password 25 | default[:mysql][:bind_address] = ipaddress 26 | default[:mysql][:datadir] = "/var/lib/mysql" 27 | 28 | if attribute?(:ec2) 29 | default[:mysql][:ec2_path] = "/mnt/mysql" 30 | default[:mysql][:ebs_vol_dev] = "/dev/sdi" 31 | default[:mysql][:ebs_vol_size] = 50 32 | end 33 | 34 | default[:mysql][:tunable][:back_log] = "128" 35 | default[:mysql][:tunable][:key_buffer] = "256M" 36 | default[:mysql][:tunable][:max_allowed_packet] = "16M" 37 | default[:mysql][:tunable][:max_connections] = "800" 38 | default[:mysql][:tunable][:max_heap_table_size] = "32M" 39 | default[:mysql][:tunable][:myisam_recover] = "BACKUP" 40 | default[:mysql][:tunable][:net_read_timeout] = "30" 41 | default[:mysql][:tunable][:net_write_timeout] = "30" 42 | default[:mysql][:tunable][:table_cache] = "128" 43 | default[:mysql][:tunable][:table_open_cache] = "128" 44 | default[:mysql][:tunable][:thread_cache] = "128" 45 | default[:mysql][:tunable][:thread_cache_size] = 8 46 | default[:mysql][:tunable][:thread_concurrency] = 10 47 | default[:mysql][:tunable][:thread_stack] = "256K" 48 | default[:mysql][:tunable][:wait_timeout] = "180" 49 | 50 | default[:mysql][:tunable][:query_cache_limit] = "1M" 51 | default[:mysql][:tunable][:query_cache_size] = "16M" 52 | 53 | default[:mysql][:tunable][:log_slow_queries] = "/var/log/mysql/slow.log" 54 | default[:mysql][:tunable][:long_query_time] = 2 55 | 56 | default[:mysql][:tunable][:innodb_buffer_pool_size] = "256M" 57 | -------------------------------------------------------------------------------- /cookbooks/mysql/libraries/database.rb: -------------------------------------------------------------------------------- 1 | begin 2 | require 'mysql' 3 | rescue LoadError 4 | Chef::Log.warn("Missing gem 'mysql'") 5 | end 6 | 7 | module Opscode 8 | module Mysql 9 | module Database 10 | def db 11 | @@db ||= ::Mysql.new new_resource.host, new_resource.username, new_resource.password 12 | end 13 | end 14 | end 15 | end 16 | -------------------------------------------------------------------------------- /cookbooks/mysql/metadata.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "mysql", 3 | "description": "Installs and configures mysql for client or server", 4 | "long_description": "= DESCRIPTION:\n\nInstalls and configures MySQL client or server.\n\n= REQUIREMENTS:\n\n== Platform:\n\nBest tested on Ubuntu 9.04,9.10. On EC2, requires platform that supports -o bind option for the 'mount' command.\n\n== Cookbooks:\n\nRequires Opscode's openssl cookbook for secure password generation.\n\nRequires a C compiler and Ruby development package in order to build mysql gem with native extensions. On Debian and Ubuntu systems this is satisfied by installing the \"build-essential\" and \"ruby-dev\" packages before running Chef. See USAGE below for information on how to handle this during a Chef run.\n\n= RESOURCES AND PROVIDERS\n\nThe cookbook contains a LWRP, +mysql_database+ which can be used to manage databases through calls to the MySQL API. The mysql gem is installed to make this usable. The provider currently supports three actions:\n\n* +flush_tables_with_read_lock+ - sends the sql command \"flush tables with read lock\", used for setting up mysql master/slave replication.\n* +unflush_tables+ - sends the sql command \"unflush tables\", used for setting up master/slave replication.\n* +create_db+ - specify a database to be created.\n\nFor example see the USAGE section below.\n\n= ATTRIBUTES:\n\n* +mysql[:server_root_password]+ - Set the server's root password with this, default is a randomly generated password with +OpenSSL::Random.random_bytes+.\n* +mysql[:server_repl_password]+ - Set the replication user 'repl' password with this, default is a randomly generated password with +OpenSSL::Random.random_bytes+.\n* +mysql[:server_debian_password]+ - Set the debian-sys-maint user password with this, default is a randomly generated password with +OpenSSL::Random.random_bytes+.\n* +mysql[:bind_address]+ - Listen address for MySQLd, default is node's ipaddress.\n* +mysql[:datadir]+ - Location for mysql data directory, default is \"/var/lib/mysql\"\n* +mysql[:ec2_path]+ - location of mysql datadir on EC2 nodes, default \"/mnt/mysql\"\n\nPerformance tuning attributes, each corresponds to the same-named parameter in my.cnf; default values listed\n\n* +mysql[:tunable][:key_buffer]+ = \"250M\"\n* +mysql[:tunable][:max_connections]+ = \"800\"\n* +mysql[:tunable][:wait_timeout]+ = \"180\"\n* +mysql[:tunable][:net_write_timeout]+ = \"30\"\n* +mysql[:tunable][:net_write_timeout]+ = \"30\"\n* +mysql[:tunable][:back_log]+ = \"128\"\n* +mysql[:tunable][:table_cache]+ = \"128\"\n* +mysql[:tunable][:max_heap_table_size]+ = \"32M\"\n\n= USAGE:\n\nOn client nodes,\n\n include_recipe \"mysql::client\"\n\nThis will install the MySQL client libraries and development headers on the system. It will also install the Ruby Gem +mysql+, so that the cookbook's LWRP (above) can be used. This is done during the compile-phase of the Chef run.\n\n r = package ... do\n action :nothing\n end\n\n r.run_action(:install)\n\nThis creates a resource object for the package and does the installation before other recipes are parsed. You'll need to have the C compiler and such (ie, build-essential on Ubuntu) before running the recipes, but we already do that when installing Chef :-). If you want to be able to access a MySQL database via Ruby within another recipe, you could do so, like so:\n\n Gem.clear_paths # needed for Chef to find the gem...\n require 'mysql' # requires the mysql gem\n\n mysql_database \"create application_production database\" do\n host \"localhost\"\n username \"root\"\n password node[:mysql][:server_root_password]\n database \"application_production\"\n action :create_db\n end\n\nThis will connect to the MySQL server running on localhost as \"root\" and password as +mysql[:server_root_password]+ attribute (see below) and create the database specified with the +database+ parameter. The provider will attempt to determine whether the database exists first.\n\nOn server nodes,\n\n include_recipe \"mysql::server\"\n\nOn Debian and Ubuntu, this will preseed the mysql-server package with the randomly generated root password from the attributes file. On other platforms, it simply installs the required packages. It will also create an SQL file, /etc/mysql/grants.sql, that will be used to set up grants for the root, repl and debian-sys-maint users.\n\nOn EC2 nodes,\n\n include_recipe \"mysql::server_ec2\"\n\nWhen the ec2_path doesn't exist we look for a mounted filesystem (eg, EBS) and move the datadir there.\n\nThe client recipe is already included by server and 'default' recipes.\n\nTo make sure that a C compiler and the Ruby development libraries are installed, use the following run list in the node or in a role:\n\n {\n \"run_list\": [\n \"recipe[build-essential]\",\n \"recipe[ruby]\",\n \"recipe[mysql::server]\"\n ]\n }\n\nThe build-essential and ruby cookbooks install the packages in question during the \"execution\" phase of the Chef client run, rather than the compile phase when the MySQL gem is installed. To work around this for now until the build-essential and ruby packages are updated, modify your local copies of the recipes:\n\nIn the Opscode build-essential default recipe:\n\n %w{build-essential binutils-doc}.each do |pkg|\n p = package pkg do\n action :nothing\n end\n p.run_action(:install)\n end\n\nAnd the ruby recipe to have the following:\n\n extra_packages.each do |pkg|\n p = package pkg do\n action :nothing\n end\n p.run_action(:install)\n end\n\nThese cookbooks aren't strict dependencies, and not if the installation process already included installing build-essential and ruby1.8-dev (e.g. RubyGems installation).\n\nFor more infromation on the compile vs execution phase of a Chef run:\n\n http://wiki.opscode.com/display/chef/Anatomy+of+a+Chef+Run\n\n= LICENSE and AUTHOR:\n\nAuthor:: Joshua Timberman ()\nAuthor:: AJ Christensen ()\n\nCopyright:: 2009, Opscode, Inc\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n", 5 | "maintainer": "Opscode, Inc.", 6 | "maintainer_email": "cookbooks@opscode.com", 7 | "license": "Apache 2.0", 8 | "platforms": { 9 | "debian": [ 10 | 11 | ], 12 | "ubuntu": [ 13 | 14 | ], 15 | "centos": [ 16 | 17 | ], 18 | "suse": [ 19 | 20 | ], 21 | "fedora": [ 22 | 23 | ], 24 | "redhat": [ 25 | 26 | ] 27 | }, 28 | "dependencies": { 29 | "openssl": [ 30 | 31 | ] 32 | }, 33 | "recommendations": { 34 | }, 35 | "suggestions": { 36 | }, 37 | "conflicting": { 38 | }, 39 | "providing": { 40 | }, 41 | "replacing": { 42 | }, 43 | "attributes": { 44 | "mysql/server_root_password": { 45 | "display_name": "MySQL Server Root Password", 46 | "description": "Randomly generated password for the mysqld root user", 47 | "default": "randomly generated", 48 | "choice": [ 49 | 50 | ], 51 | "calculated": false, 52 | "type": "string", 53 | "required": "optional", 54 | "recipes": [ 55 | 56 | ] 57 | }, 58 | "mysql/bind_address": { 59 | "display_name": "MySQL Bind Address", 60 | "description": "Address that mysqld should listen on", 61 | "default": "ipaddress", 62 | "choice": [ 63 | 64 | ], 65 | "calculated": false, 66 | "type": "string", 67 | "required": "optional", 68 | "recipes": [ 69 | 70 | ] 71 | }, 72 | "mysql/datadir": { 73 | "display_name": "MySQL Data Directory", 74 | "description": "Location of mysql databases", 75 | "default": "/var/lib/mysql", 76 | "choice": [ 77 | 78 | ], 79 | "calculated": false, 80 | "type": "string", 81 | "required": "optional", 82 | "recipes": [ 83 | 84 | ] 85 | }, 86 | "mysql/ec2_path": { 87 | "display_name": "MySQL EC2 Path", 88 | "description": "Location of mysql directory on EC2 instance EBS volumes", 89 | "default": "/mnt/mysql", 90 | "choice": [ 91 | 92 | ], 93 | "calculated": false, 94 | "type": "string", 95 | "required": "optional", 96 | "recipes": [ 97 | 98 | ] 99 | }, 100 | "mysql/tunable": { 101 | "display_name": "MySQL Tunables", 102 | "description": "Hash of MySQL tunable attributes", 103 | "type": "hash", 104 | "choice": [ 105 | 106 | ], 107 | "calculated": false, 108 | "required": "optional", 109 | "recipes": [ 110 | 111 | ] 112 | }, 113 | "mysql/tunable/key_buffer": { 114 | "display_name": "MySQL Tuntable Key Buffer", 115 | "default": "250M", 116 | "choice": [ 117 | 118 | ], 119 | "calculated": false, 120 | "type": "string", 121 | "required": "optional", 122 | "recipes": [ 123 | 124 | ] 125 | }, 126 | "mysql/tunable/max_connections": { 127 | "display_name": "MySQL Tunable Max Connections", 128 | "default": "800", 129 | "choice": [ 130 | 131 | ], 132 | "calculated": false, 133 | "type": "string", 134 | "required": "optional", 135 | "recipes": [ 136 | 137 | ] 138 | }, 139 | "mysql/tunable/wait_timeout": { 140 | "display_name": "MySQL Tunable Wait Timeout", 141 | "default": "180", 142 | "choice": [ 143 | 144 | ], 145 | "calculated": false, 146 | "type": "string", 147 | "required": "optional", 148 | "recipes": [ 149 | 150 | ] 151 | }, 152 | "mysql/tunable/net_read_timeout": { 153 | "display_name": "MySQL Tunable Net Read Timeout", 154 | "default": "30", 155 | "choice": [ 156 | 157 | ], 158 | "calculated": false, 159 | "type": "string", 160 | "required": "optional", 161 | "recipes": [ 162 | 163 | ] 164 | }, 165 | "mysql/tunable/net_write_timeout": { 166 | "display_name": "MySQL Tunable Net Write Timeout", 167 | "default": "30", 168 | "choice": [ 169 | 170 | ], 171 | "calculated": false, 172 | "type": "string", 173 | "required": "optional", 174 | "recipes": [ 175 | 176 | ] 177 | }, 178 | "mysql/tunable/back_log": { 179 | "display_name": "MySQL Tunable Back Log", 180 | "default": "128", 181 | "choice": [ 182 | 183 | ], 184 | "calculated": false, 185 | "type": "string", 186 | "required": "optional", 187 | "recipes": [ 188 | 189 | ] 190 | }, 191 | "mysql/tunable/table_cache": { 192 | "display_name": "MySQL Tunable Table Cache for MySQL < 5.1.3", 193 | "default": "128", 194 | "choice": [ 195 | 196 | ], 197 | "calculated": false, 198 | "type": "string", 199 | "required": "optional", 200 | "recipes": [ 201 | 202 | ] 203 | }, 204 | "mysql/tunable/table_open_cache": { 205 | "display_name": "MySQL Tunable Table Cache for MySQL >= 5.1.3", 206 | "default": "128", 207 | "choice": [ 208 | 209 | ], 210 | "calculated": false, 211 | "type": "string", 212 | "required": "optional", 213 | "recipes": [ 214 | 215 | ] 216 | }, 217 | "mysql/tunable/max_heap_table_size": { 218 | "display_name": "MySQL Tunable Max Heap Table Size", 219 | "default": "32M", 220 | "choice": [ 221 | 222 | ], 223 | "calculated": false, 224 | "type": "string", 225 | "required": "optional", 226 | "recipes": [ 227 | 228 | ] 229 | } 230 | }, 231 | "groupings": { 232 | }, 233 | "recipes": { 234 | "mysql": "Includes the client recipe to configure a client", 235 | "mysql::client": "Installs packages required for mysql clients using run_action magic", 236 | "mysql::server": "Installs packages required for mysql servers w/o manual intervention", 237 | "mysql::server_ec2": "Performs EC2-specific mountpoint manipulation" 238 | }, 239 | "version": "0.24.1" 240 | } -------------------------------------------------------------------------------- /cookbooks/mysql/metadata.rb: -------------------------------------------------------------------------------- 1 | maintainer "Opscode, Inc." 2 | maintainer_email "cookbooks@opscode.com" 3 | license "Apache 2.0" 4 | description "Installs and configures mysql for client or server" 5 | long_description IO.read(File.join(File.dirname(__FILE__), 'README.rdoc')) 6 | version "0.24.1" 7 | recipe "mysql", "Includes the client recipe to configure a client" 8 | recipe "mysql::client", "Installs packages required for mysql clients using run_action magic" 9 | recipe "mysql::server", "Installs packages required for mysql servers w/o manual intervention" 10 | recipe "mysql::server_ec2", "Performs EC2-specific mountpoint manipulation" 11 | 12 | %w{ debian ubuntu centos suse fedora redhat}.each do |os| 13 | supports os 14 | end 15 | 16 | depends "openssl" 17 | 18 | attribute "mysql/server_root_password", 19 | :display_name => "MySQL Server Root Password", 20 | :description => "Randomly generated password for the mysqld root user", 21 | :default => "randomly generated" 22 | 23 | attribute "mysql/bind_address", 24 | :display_name => "MySQL Bind Address", 25 | :description => "Address that mysqld should listen on", 26 | :default => "ipaddress" 27 | 28 | attribute "mysql/datadir", 29 | :display_name => "MySQL Data Directory", 30 | :description => "Location of mysql databases", 31 | :default => "/var/lib/mysql" 32 | 33 | attribute "mysql/ec2_path", 34 | :display_name => "MySQL EC2 Path", 35 | :description => "Location of mysql directory on EC2 instance EBS volumes", 36 | :default => "/mnt/mysql" 37 | 38 | attribute "mysql/tunable", 39 | :display_name => "MySQL Tunables", 40 | :description => "Hash of MySQL tunable attributes", 41 | :type => "hash" 42 | 43 | attribute "mysql/tunable/key_buffer", 44 | :display_name => "MySQL Tuntable Key Buffer", 45 | :default => "250M" 46 | 47 | attribute "mysql/tunable/max_connections", 48 | :display_name => "MySQL Tunable Max Connections", 49 | :default => "800" 50 | 51 | attribute "mysql/tunable/wait_timeout", 52 | :display_name => "MySQL Tunable Wait Timeout", 53 | :default => "180" 54 | 55 | attribute "mysql/tunable/net_read_timeout", 56 | :display_name => "MySQL Tunable Net Read Timeout", 57 | :default => "30" 58 | 59 | attribute "mysql/tunable/net_write_timeout", 60 | :display_name => "MySQL Tunable Net Write Timeout", 61 | :default => "30" 62 | 63 | attribute "mysql/tunable/back_log", 64 | :display_name => "MySQL Tunable Back Log", 65 | :default => "128" 66 | 67 | attribute "mysql/tunable/table_cache", 68 | :display_name => "MySQL Tunable Table Cache for MySQL < 5.1.3", 69 | :default => "128" 70 | 71 | attribute "mysql/tunable/table_open_cache", 72 | :display_name => "MySQL Tunable Table Cache for MySQL >= 5.1.3", 73 | :default => "128" 74 | 75 | attribute "mysql/tunable/max_heap_table_size", 76 | :display_name => "MySQL Tunable Max Heap Table Size", 77 | :default => "32M" 78 | 79 | -------------------------------------------------------------------------------- /cookbooks/mysql/providers/database.rb: -------------------------------------------------------------------------------- 1 | include Opscode::Mysql::Database 2 | 3 | action :flush_tables_with_read_lock do 4 | Chef::Log.info "mysql_database: flushing tables with read lock" 5 | db.query "flush tables with read lock" 6 | new_resource.updated_by_last_action(true) 7 | end 8 | 9 | action :unflush_tables do 10 | Chef::Log.info "mysql_database: unlocking tables" 11 | db.query "unlock tables" 12 | new_resource.updated_by_last_action(true) 13 | end 14 | 15 | action :create_db do 16 | unless @mysqldb.exists 17 | Chef::Log.info "mysql_database: Creating database #{new_resource.database}" 18 | db.query("create database #{new_resource.database}") 19 | new_resource.updated_by_last_action(true) 20 | end 21 | end 22 | 23 | def load_current_resource 24 | @mysqldb = Chef::Resource::MysqlDatabase.new(new_resource.name) 25 | @mysqldb.database(new_resource.database) 26 | exists = db.list_dbs.include?(new_resource.database) 27 | @mysqldb.exists(exists) 28 | end 29 | -------------------------------------------------------------------------------- /cookbooks/mysql/recipes/client.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: mysql 3 | # Recipe:: client 4 | # 5 | # Copyright 2008-2009, Opscode, Inc. 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | 20 | p = package "mysql-devel" do 21 | package_name value_for_platform( 22 | [ "centos", "redhat", "suse", "fedora"] => { "default" => "mysql-devel" }, 23 | "debian" => { 24 | "5.0" => "libmysqlclient15-dev", 25 | "5.0.1" => "libmysqlclient15-dev", 26 | "5.0.2" => "libmysqlclient15-dev", 27 | "5.0.3" => "libmysqlclient15-dev", 28 | "5.0.4" => "libmysqlclient15-dev", 29 | "5.0.5" => "libmysqlclient15-dev" 30 | }, 31 | "ubuntu" => { 32 | "8.04" => "libmysqlclient15-dev", 33 | "8.10" => "libmysqlclient15-dev", 34 | "9.04" => "libmysqlclient15-dev" 35 | }, 36 | "default" => 'libmysqlclient-dev' 37 | ) 38 | action :nothing 39 | end 40 | 41 | p.run_action(:install) 42 | 43 | o = package "mysql-client" do 44 | package_name value_for_platform( 45 | [ "centos", "redhat", "suse", "fedora"] => { "default" => "mysql" }, 46 | "default" => "mysql-client" 47 | ) 48 | action :nothing 49 | end 50 | 51 | o.run_action(:install) 52 | 53 | case node[:platform] 54 | when "centos","redhat", "suse", "fedora" 55 | package "ruby-mysql" do 56 | action :install 57 | end 58 | 59 | else 60 | r = gem_package "mysql" do 61 | action :nothing 62 | end 63 | 64 | r.run_action(:install) 65 | end 66 | -------------------------------------------------------------------------------- /cookbooks/mysql/recipes/default.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: mysql 3 | # Recipe:: default 4 | # 5 | # Copyright 2008-2009, Opscode, Inc. 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | 20 | include_recipe "mysql::client" 21 | -------------------------------------------------------------------------------- /cookbooks/mysql/recipes/server.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: mysql 3 | # Recipe:: default 4 | # 5 | # Copyright 2008-2009, Opscode, Inc. 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | 20 | include_recipe "mysql::client" 21 | 22 | case node[:platform] 23 | when "debian","ubuntu" 24 | 25 | directory "/var/cache/local/preseeding" do 26 | owner "root" 27 | group "root" 28 | mode 0755 29 | recursive true 30 | end 31 | 32 | execute "preseed mysql-server" do 33 | command "debconf-set-selections /var/cache/local/preseeding/mysql-server.seed" 34 | action :nothing 35 | end 36 | 37 | template "/var/cache/local/preseeding/mysql-server.seed" do 38 | source "mysql-server.seed.erb" 39 | owner "root" 40 | group "root" 41 | mode "0600" 42 | notifies :run, resources(:execute => "preseed mysql-server"), :immediately 43 | end 44 | template "/etc/mysql/debian.cnf" do 45 | source "debian.cnf.erb" 46 | owner "root" 47 | group "root" 48 | mode "0600" 49 | end 50 | end 51 | 52 | package "mysql-server" do 53 | action :install 54 | end 55 | 56 | service "mysql" do 57 | service_name value_for_platform([ "centos", "redhat", "suse", "fedora" ] => {"default" => "mysqld"}, "default" => "mysql") 58 | if (platform?("ubuntu") && node.platform_version.to_f >= 10.04) 59 | restart_command "restart mysql" 60 | stop_command "stop mysql" 61 | start_command "start mysql" 62 | end 63 | supports :status => true, :restart => true, :reload => true 64 | action :nothing 65 | end 66 | 67 | template value_for_platform([ "centos", "redhat", "suse" , "fedora" ] => {"default" => "/etc/my.cnf"}, "default" => "/etc/mysql/my.cnf") do 68 | source "my.cnf.erb" 69 | owner "root" 70 | group "root" 71 | mode "0644" 72 | notifies :restart, resources(:service => "mysql"), :immediately 73 | end 74 | 75 | unless Chef::Config[:solo] 76 | ruby_block "save node data" do 77 | block do 78 | node.save 79 | end 80 | action :create 81 | end 82 | end 83 | 84 | grants_path = value_for_platform( 85 | ["centos", "redhat", "suse", "fedora" ] => { 86 | "default" => "/etc/mysql_grants.sql" 87 | }, 88 | "default" => "/etc/mysql/grants.sql" 89 | ) 90 | 91 | begin 92 | t = resources(:template => "/etc/mysql/grants.sql") 93 | rescue 94 | Chef::Log.warn("Could not find previously defined grants.sql resource") 95 | t = template "/etc/mysql/grants.sql" do 96 | path grants_path 97 | source "grants.sql.erb" 98 | owner "root" 99 | group "root" 100 | mode "0600" 101 | action :create 102 | end 103 | end 104 | 105 | execute "mysql-install-privileges" do 106 | command "/usr/bin/mysql -u root #{node[:mysql][:server_root_password].empty? ? '' : '-p' }#{node[:mysql][:server_root_password]} < #{grants_path}" 107 | action :nothing 108 | subscribes :run, resources(:template => "/etc/mysql/grants.sql"), :immediately 109 | end 110 | -------------------------------------------------------------------------------- /cookbooks/mysql/recipes/server_ec2.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: mysql 3 | # Recipe:: default 4 | # 5 | # Copyright 2008-2009, Opscode, Inc. 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | 20 | 21 | if (node[:ec2] && ! FileTest.directory?(node[:mysql][:ec2_path])) 22 | 23 | service "mysql" do 24 | action :stop 25 | end 26 | 27 | execute "install-mysql" do 28 | command "mv #{node[:mysql][:datadir]} #{node[:mysql][:ec2_path]}" 29 | not_if do FileTest.directory?(node[:mysql][:ec2_path]) end 30 | end 31 | 32 | directory node[:mysql][:ec2_path] do 33 | owner "mysql" 34 | group "mysql" 35 | end 36 | 37 | mount node[:mysql][:datadir] do 38 | device node[:mysql][:ec2_path] 39 | fstype "none" 40 | options "bind,rw" 41 | action :mount 42 | end 43 | 44 | service "mysql" do 45 | action :start 46 | end 47 | 48 | end 49 | 50 | -------------------------------------------------------------------------------- /cookbooks/mysql/resources/database.rb: -------------------------------------------------------------------------------- 1 | actions :flush_tables_with_read_lock, :unflush_tables, :create_db 2 | 3 | attribute :host, :kind_of => String 4 | attribute :username, :kind_of => String 5 | attribute :password, :kind_of => String 6 | attribute :database, :kind_of => String 7 | attribute :exists, :default => false 8 | -------------------------------------------------------------------------------- /cookbooks/mysql/templates/centos/my.cnf.erb: -------------------------------------------------------------------------------- 1 | [mysqld] 2 | datadir=/var/lib/mysql 3 | socket=/var/lib/mysql/mysql.sock 4 | user=mysql 5 | # Default to using old password format for compatibility with mysql 3.x 6 | # clients (those using the mysqlclient10 compatibility package). 7 | old_passwords=1 8 | 9 | [mysqld_safe] 10 | log-error=/var/log/mysqld.log 11 | pid-file=/var/run/mysqld/mysqld.pid 12 | 13 | -------------------------------------------------------------------------------- /cookbooks/mysql/templates/debian/my.cnf.erb: -------------------------------------------------------------------------------- 1 | # 2 | # Generated by Chef for <%= node[:hostname] %> 3 | # 4 | # Local modifications will be overwritten. 5 | # 6 | # The MySQL database server configuration file. 7 | # 8 | # You can copy this to one of: 9 | # - "/etc/mysql/my.cnf" to set global options, 10 | # - "~/.my.cnf" to set user-specific options. 11 | # 12 | # One can use all long options that the program supports. 13 | # Run program with --help to get a list of available options and with 14 | # --print-defaults to see which it would actually understand and use. 15 | # 16 | # For explanations see 17 | # http://dev.mysql.com/doc/mysql/en/server-system-variables.html 18 | 19 | # This will be passed to all mysql clients 20 | # It has been reported that passwords should be enclosed with ticks/quotes 21 | # escpecially if they contain "#" chars... 22 | # Remember to edit /etc/mysql/debian.cnf when changing the socket location. 23 | [client] 24 | port = 3306 25 | socket = /var/run/mysqld/mysqld.sock 26 | 27 | # Here is entries for some specific programs 28 | # The following values assume you have at least 32M ram 29 | 30 | # This was formally known as [safe_mysqld]. Both versions are currently parsed. 31 | [mysqld_safe] 32 | socket = /var/run/mysqld/mysqld.sock 33 | nice = 0 34 | 35 | [mysqld] 36 | # 37 | # * Basic Settings 38 | # 39 | 40 | # 41 | # * IMPORTANT 42 | # If you make changes to these settings and your system uses apparmor, you may 43 | # also need to also adjust /etc/apparmor.d/usr.sbin.mysqld. 44 | # 45 | 46 | user = mysql 47 | pid-file = /var/run/mysqld/mysqld.pid 48 | socket = /var/run/mysqld/mysqld.sock 49 | port = 3306 50 | basedir = /usr 51 | datadir = <%= node[:mysql][:datadir] %> 52 | tmpdir = /tmp 53 | skip-external-locking 54 | # 55 | # Instead of skip-networking the default is now to listen only on 56 | # localhost which is more compatible and is not less secure. 57 | bind-address = <%= node[:mysql][:bind_address] %> 58 | # 59 | # * Fine Tuning 60 | # 61 | key_buffer = <%= node[:mysql][:tunable][:key_buffer] %> 62 | max_allowed_packet = 16M 63 | thread_stack = 128K 64 | thread_cache_size = 8 65 | # This replaces the startup script and checks MyISAM tables if needed 66 | # the first time they are touched 67 | myisam-recover = BACKUP 68 | #max_connections = 100 69 | #table_cache = 64 70 | #thread_concurrency = 10 71 | max_connections = <%= node[:mysql][:tunable][:max_connections] %> 72 | wait_timeout = <%= node[:mysql][:tunable][:wait_timeout] %> 73 | net_read_timeout = <%= node[:mysql][:tunable][:net_read_timeout] %> 74 | net_write_timeout = <%= node[:mysql][:tunable][:net_write_timeout] %> 75 | back_log = <%= node[:mysql][:tunable][:back_log] %> 76 | table_cache = <%= node[:mysql][:tunable][:table_cache] %> 77 | max_heap_table_size = <%= node[:mysql][:tunable][:max_heap_table_size] %> 78 | 79 | # 80 | # * Query Cache Configuration 81 | # 82 | query_cache_limit = 1M 83 | query_cache_size = 16M 84 | # 85 | # * Logging and Replication 86 | # 87 | # Both location gets rotated by the cronjob. 88 | # Be aware that this log type is a performance killer. 89 | #log = /var/log/mysql/mysql.log 90 | # 91 | # Error logging goes to syslog. This is a Debian improvement :) 92 | # 93 | # Here you can see queries with especially long duration 94 | log_slow_queries = /var/log/mysql/mysql-slow.log 95 | long_query_time = 2 96 | log-queries-not-using-indexes 97 | # 98 | # The following can be used as easy to replay backup logs or for replication. 99 | # note: if you are setting up a replication slave, see README.Debian about 100 | # other settings you may need to change. 101 | #server-id = 1 102 | #log_bin = /var/log/mysql/mysql-bin.log 103 | expire_logs_days = 10 104 | max_binlog_size = 100M 105 | #binlog_do_db = include_database_name 106 | #binlog_ignore_db = include_database_name 107 | # 108 | # * BerkeleyDB 109 | # 110 | # Using BerkeleyDB is now discouraged as its support will cease in 5.1.12. 111 | skip-bdb 112 | # 113 | # * InnoDB 114 | # 115 | # InnoDB is enabled by default with a 10MB datafile in /var/lib/mysql/. 116 | # Read the manual for more InnoDB related options. There are many! 117 | # You might want to disable InnoDB to shrink the mysqld process by circa 100MB. 118 | #skip-innodb 119 | # 120 | # * Security Features 121 | # 122 | # Read the manual, too, if you want chroot! 123 | # chroot = /var/lib/mysql/ 124 | # 125 | # For generating SSL certificates I recommend the OpenSSL GUI "tinyca". 126 | # 127 | # ssl-ca=/etc/mysql/cacert.pem 128 | # ssl-cert=/etc/mysql/server-cert.pem 129 | # ssl-key=/etc/mysql/server-key.pem 130 | 131 | [mysqldump] 132 | quick 133 | quote-names 134 | max_allowed_packet = 16M 135 | 136 | [mysql] 137 | #no-auto-rehash # faster start of mysql but no tab completition 138 | 139 | [isamchk] 140 | key_buffer = 16M 141 | 142 | # 143 | # * NDB Cluster 144 | # 145 | # See /usr/share/doc/mysql-server-*/README.Debian for more information. 146 | # 147 | # The following configuration is read by the NDB Data Nodes (ndbd processes) 148 | # not from the NDB Management Nodes (ndb_mgmd processes). 149 | # 150 | # [MYSQL_CLUSTER] 151 | # ndb-connectstring=127.0.0.1 152 | # 153 | # * IMPORTANT: Additional settings that can override those from this file! 154 | # The files must end with '.cnf', otherwise they'll be ignored. 155 | # 156 | <%= "!includedir /etc/mysql/conf.d/" unless ["centos", "redhat","suse"].include?(node[:platform]) %> 157 | -------------------------------------------------------------------------------- /cookbooks/mysql/templates/default/debian.cnf.erb: -------------------------------------------------------------------------------- 1 | [client] 2 | host = localhost 3 | user = debian-sys-maint 4 | password = <%= node[:mysql][:server_debian_password] %> 5 | socket = /var/run/mysqld/mysqld.sock 6 | [mysql_upgrade] 7 | host = localhost 8 | user = debian-sys-maint 9 | password = <%= node[:mysql][:server_debian_password] %> 10 | socket = /var/run/mysqld/mysqld.sock 11 | basedir = /usr 12 | -------------------------------------------------------------------------------- /cookbooks/mysql/templates/default/grants.sql.erb: -------------------------------------------------------------------------------- 1 | # Generated by Chef for <%= node[:fqdn] %>. 2 | # Local modifications will be overwritten. 3 | 4 | <% case node[:platform] -%> 5 | <% when "debian","ubuntu" -%> 6 | GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, SHUTDOWN, PROCESS, FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, SUPER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT ON *.* TO 'debian-sys-maint'@'localhost' IDENTIFIED BY '<%= node[:mysql][:server_debian_password] %>' WITH GRANT OPTION; 7 | <% end -%> 8 | # Grant replication for a slave user. 9 | GRANT REPLICATION SLAVE ON *.* TO 'repl'@'%' identified by '<%= node[:mysql][:server_repl_password] %>'; 10 | 11 | # Set the server root password. This should be preseeded by the package installation. 12 | SET PASSWORD FOR 'root'@'localhost' = PASSWORD('<%= node[:mysql][:server_root_password] %>'); 13 | -------------------------------------------------------------------------------- /cookbooks/mysql/templates/default/my.cnf.erb: -------------------------------------------------------------------------------- 1 | # 2 | # Generated by Chef for <%= node[:hostname] %> 3 | # 4 | # Local modifications will be overwritten. 5 | # 6 | # The MySQL database server configuration file. 7 | # 8 | # You can copy this to one of: 9 | # - "/etc/mysql/my.cnf" to set global options, 10 | # - "~/.my.cnf" to set user-specific options. 11 | # 12 | # One can use all long options that the program supports. 13 | # Run program with --help to get a list of available options and with 14 | # --print-defaults to see which it would actually understand and use. 15 | # 16 | # For explanations see 17 | # http://dev.mysql.com/doc/mysql/en/server-system-variables.html 18 | 19 | # This will be passed to all mysql clients 20 | # It has been reported that passwords should be enclosed with ticks/quotes 21 | # escpecially if they contain "#" chars... 22 | # Remember to edit /etc/mysql/debian.cnf when changing the socket location. 23 | [client] 24 | port = 3306 25 | socket = /var/run/mysqld/mysqld.sock 26 | 27 | # Here is entries for some specific programs 28 | # The following values assume you have at least 32M ram 29 | 30 | # This was formally known as [safe_mysqld]. Both versions are currently parsed. 31 | [mysqld_safe] 32 | socket = /var/run/mysqld/mysqld.sock 33 | nice = 0 34 | 35 | [mysqld] 36 | # 37 | # * Basic Settings 38 | # 39 | 40 | # 41 | # * IMPORTANT 42 | # If you make changes to these settings and your system uses apparmor, you may 43 | # also need to also adjust /etc/apparmor.d/usr.sbin.mysqld. 44 | # 45 | 46 | user = mysql 47 | pid-file = /var/run/mysqld/mysqld.pid 48 | socket = /var/run/mysqld/mysqld.sock 49 | port = 3306 50 | basedir = /usr 51 | datadir = <%= node[:mysql][:datadir] %> 52 | tmpdir = /tmp 53 | skip-external-locking 54 | # 55 | # Instead of skip-networking the default is now to listen only on 56 | # localhost which is more compatible and is not less secure. 57 | bind-address = <%= node[:mysql][:bind_address] %> 58 | # 59 | # * Fine Tuning 60 | # 61 | key_buffer = <%= node[:mysql][:tunable][:key_buffer] %> 62 | max_allowed_packet = 16M 63 | thread_stack = 128K 64 | thread_cache_size = 8 65 | # This replaces the startup script and checks MyISAM tables if needed 66 | # the first time they are touched 67 | myisam-recover = BACKUP 68 | #max_connections = 100 69 | #table_cache = 64 70 | #thread_concurrency = 10 71 | max_connections = <%= node[:mysql][:tunable][:max_connections] %> 72 | wait_timeout = <%= node[:mysql][:tunable][:wait_timeout] %> 73 | net_read_timeout = <%= node[:mysql][:tunable][:net_read_timeout] %> 74 | net_write_timeout = <%= node[:mysql][:tunable][:net_write_timeout] %> 75 | back_log = <%= node[:mysql][:tunable][:back_log] %> 76 | table_cache = <%= node[:mysql][:tunable][:table_cache] %> 77 | max_heap_table_size = <%= node[:mysql][:tunable][:max_heap_table_size] %> 78 | 79 | # 80 | # * Query Cache Configuration 81 | # 82 | query_cache_limit = 1M 83 | query_cache_size = 16M 84 | # 85 | # * Logging and Replication 86 | # 87 | # Both location gets rotated by the cronjob. 88 | # Be aware that this log type is a performance killer. 89 | #log = /var/log/mysql/mysql.log 90 | # 91 | # Error logging goes to syslog. This is a Debian improvement :) 92 | # 93 | # Here you can see queries with especially long duration 94 | log_slow_queries = /var/log/mysql/mysql-slow.log 95 | long_query_time = 2 96 | log-queries-not-using-indexes 97 | # 98 | # The following can be used as easy to replay backup logs or for replication. 99 | # note: if you are setting up a replication slave, see README.Debian about 100 | # other settings you may need to change. 101 | #server-id = 1 102 | #log_bin = /var/log/mysql/mysql-bin.log 103 | expire_logs_days = 10 104 | max_binlog_size = 100M 105 | #binlog_do_db = include_database_name 106 | #binlog_ignore_db = include_database_name 107 | # 108 | # * BerkeleyDB 109 | # 110 | # Using BerkeleyDB is now discouraged as its support will cease in 5.1.12. 111 | skip-bdb 112 | # 113 | # * InnoDB 114 | # 115 | # InnoDB is enabled by default with a 10MB datafile in /var/lib/mysql/. 116 | # Read the manual for more InnoDB related options. There are many! 117 | # You might want to disable InnoDB to shrink the mysqld process by circa 100MB. 118 | #skip-innodb 119 | # 120 | # * Federated 121 | # 122 | # The FEDERATED storage engine is disabled since 5.0.67 by default in the .cnf files 123 | # shipped with MySQL distributions (my-huge.cnf, my-medium.cnf, and so forth). 124 | # 125 | skip-federated 126 | # 127 | # * Security Features 128 | # 129 | # Read the manual, too, if you want chroot! 130 | # chroot = /var/lib/mysql/ 131 | # 132 | # For generating SSL certificates I recommend the OpenSSL GUI "tinyca". 133 | # 134 | # ssl-ca=/etc/mysql/cacert.pem 135 | # ssl-cert=/etc/mysql/server-cert.pem 136 | # ssl-key=/etc/mysql/server-key.pem 137 | 138 | [mysqldump] 139 | quick 140 | quote-names 141 | max_allowed_packet = 16M 142 | 143 | [mysql] 144 | #no-auto-rehash # faster start of mysql but no tab completition 145 | 146 | [isamchk] 147 | key_buffer = 16M 148 | 149 | # 150 | # * NDB Cluster 151 | # 152 | # See /usr/share/doc/mysql-server-*/README.Debian for more information. 153 | # 154 | # The following configuration is read by the NDB Data Nodes (ndbd processes) 155 | # not from the NDB Management Nodes (ndb_mgmd processes). 156 | # 157 | # [MYSQL_CLUSTER] 158 | # ndb-connectstring=127.0.0.1 159 | # 160 | # * IMPORTANT: Additional settings that can override those from this file! 161 | # The files must end with '.cnf', otherwise they'll be ignored. 162 | # 163 | <%= "!includedir /etc/mysql/conf.d/" unless ["centos", "redhat","suse"].include?(node[:platform]) %> 164 | -------------------------------------------------------------------------------- /cookbooks/mysql/templates/default/mysql-server.seed.erb: -------------------------------------------------------------------------------- 1 | mysql-server-5.0 mysql-server/root_password_again select <%= node[:mysql][:server_root_password] %> 2 | mysql-server-5.0 mysql-server/root_password select <%= node[:mysql][:server_root_password] %> 3 | mysql-server-5.0 mysql-server-5.0/really_downgrade boolean false 4 | mysql-server-5.0 mysql-server-5.0/need_sarge_compat boolean false 5 | mysql-server-5.0 mysql-server-5.0/start_on_boot boolean true 6 | mysql-server-5.0 mysql-server/error_setting_password boolean false 7 | mysql-server-5.0 mysql-server-5.0/nis_warning note 8 | mysql-server-5.0 mysql-server-5.0/postrm_remove_databases boolean false 9 | mysql-server-5.0 mysql-server/password_mismatch boolean false 10 | mysql-server-5.0 mysql-server-5.0/need_sarge_compat_done boolean true 11 | -------------------------------------------------------------------------------- /cookbooks/mysql/templates/default/port_mysql.erb: -------------------------------------------------------------------------------- 1 | # MySQL 2 | -A FWR -p tcp -m tcp --dport 3306 -j ACCEPT 3 | -A FWR -p udp -m udp --dport 3306 -j ACCEPT -------------------------------------------------------------------------------- /cookbooks/mysql/templates/redhat/my.cnf.erb: -------------------------------------------------------------------------------- 1 | [mysqld] 2 | datadir=/var/lib/mysql 3 | socket=/var/lib/mysql/mysql.sock 4 | user=mysql 5 | # Default to using old password format for compatibility with mysql 3.x 6 | # clients (those using the mysqlclient10 compatibility package). 7 | old_passwords=1 8 | 9 | [mysqld_safe] 10 | log-error=/var/log/mysqld.log 11 | pid-file=/var/run/mysqld/mysqld.pid 12 | 13 | -------------------------------------------------------------------------------- /cookbooks/mysql/templates/ubuntu-10.04/my.cnf.erb: -------------------------------------------------------------------------------- 1 | # 2 | # Generated by Chef for <%= node[:hostname] %> 3 | # 4 | # Local modifications will be overwritten. 5 | # 6 | # The MySQL database server configuration file. 7 | # 8 | # You can copy this to one of: 9 | # - "/etc/mysql/my.cnf" to set global options, 10 | # - "~/.my.cnf" to set user-specific options. 11 | # 12 | # One can use all long options that the program supports. 13 | # Run program with --help to get a list of available options and with 14 | # --print-defaults to see which it would actually understand and use. 15 | # 16 | # For explanations see 17 | # http://dev.mysql.com/doc/mysql/en/server-system-variables.html 18 | 19 | # This will be passed to all mysql clients 20 | # It has been reported that passwords should be enclosed with ticks/quotes 21 | # escpecially if they contain "#" chars... 22 | # Remember to edit /etc/mysql/debian.cnf when changing the socket location. 23 | [client] 24 | port = 3306 25 | socket = /var/run/mysqld/mysqld.sock 26 | 27 | # Here is entries for some specific programs 28 | # The following values assume you have at least 32M ram 29 | 30 | # This was formally known as [safe_mysqld]. Both versions are currently parsed. 31 | [mysqld_safe] 32 | socket = /var/run/mysqld/mysqld.sock 33 | nice = 0 34 | 35 | [mysqld] 36 | # 37 | # * Basic Settings 38 | # 39 | 40 | # 41 | # * IMPORTANT 42 | # If you make changes to these settings and your system uses apparmor, you may 43 | # also need to also adjust /etc/apparmor.d/usr.sbin.mysqld. 44 | # 45 | 46 | user = mysql 47 | pid-file = /var/run/mysqld/mysqld.pid 48 | socket = /var/run/mysqld/mysqld.sock 49 | port = 3306 50 | basedir = /usr 51 | datadir = <%= node[:mysql][:datadir] %> 52 | tmpdir = /tmp 53 | skip-external-locking 54 | # 55 | # Instead of skip-networking the default is now to listen only on 56 | # localhost which is more compatible and is not less secure. 57 | bind-address = <%= node[:mysql][:bind_address] %> 58 | # 59 | # * Fine Tuning 60 | # 61 | key_buffer = <%= node[:mysql][:tunable][:key_buffer] %> 62 | max_allowed_packet = <%= node[:mysql][:tunable][:max_allowed_packet] %> 63 | thread_stack = <%= node[:mysql][:tunable][:thread_stack] %> 64 | thread_cache_size = <%= node[:mysql][:tunable][:thread_cache_size] %> 65 | # This replaces the startup script and checks MyISAM tables if needed 66 | # the first time they are touched 67 | myisam-recover = <%= node[:mysql][:tunable][:myisam_recover] %> 68 | max_connections = <%= node[:mysql][:tunable][:max_connections] %> 69 | table_open_cache = <%= node[:mysql][:tunable][:table_open_cache] %> 70 | thread_concurrency = <%= node[:mysql][:tunable][:thread_concurrency] %> 71 | max_connections = <%= node[:mysql][:tunable][:max_connections] %> 72 | wait_timeout = <%= node[:mysql][:tunable][:wait_timeout] %> 73 | net_read_timeout = <%= node[:mysql][:tunable][:net_read_timeout] %> 74 | net_write_timeout = <%= node[:mysql][:tunable][:net_write_timeout] %> 75 | back_log = <%= node[:mysql][:tunable][:back_log] %> 76 | max_heap_table_size = <%= node[:mysql][:tunable][:max_heap_table_size] %> 77 | 78 | # 79 | # * Query Cache Configuration 80 | # 81 | query_cache_limit = <%= node[:mysql][:tunable][:query_cache_limit] %> 82 | query_cache_size = <%= node[:mysql][:tunable][:query_cache_size] %> 83 | # 84 | # * Logging and Replication 85 | # 86 | # Both location gets rotated by the cronjob. 87 | # Be aware that this log type is a performance killer. 88 | #log = /var/log/mysql/mysql.log 89 | # 90 | # Error logging goes to syslog. This is a Debian improvement :) 91 | # 92 | # Here you can see queries with especially long duration 93 | log_slow_queries = <%= node[:mysql][:tunable][:log_slow_queries] %> 94 | long_query_time = <%= node[:mysql][:tunable][:long_query_time] %> 95 | log-queries-not-using-indexes 96 | # 97 | # The following can be used as easy to replay backup logs or for replication. 98 | # note: if you are setting up a replication slave, see README.Debian about 99 | # other settings you may need to change. 100 | #server-id = 1 101 | #log_bin = /var/log/mysql/mysql-bin.log 102 | expire_logs_days = 10 103 | max_binlog_size = 100M 104 | #binlog_do_db = include_database_name 105 | #binlog_ignore_db = include_database_name 106 | # 107 | # * InnoDB 108 | # 109 | # InnoDB is enabled by default with a 10MB datafile in /var/lib/mysql/. 110 | # Read the manual for more InnoDB related options. There are many! 111 | # You might want to disable InnoDB to shrink the mysqld process by circa 100MB. 112 | #skip-innodb 113 | innodb_buffer_pool_size = <%= node[:mysql][:tunable][:innodb_buffer_pool_size] %> 114 | # 115 | # * Federated 116 | # 117 | # The FEDERATED storage engine is disabled since 5.0.67 by default in the .cnf files 118 | # shipped with MySQL distributions (my-huge.cnf, my-medium.cnf, and so forth). 119 | # 120 | skip-federated 121 | # 122 | # * Security Features 123 | # 124 | # Read the manual, too, if you want chroot! 125 | # chroot = /var/lib/mysql/ 126 | # 127 | # For generating SSL certificates I recommend the OpenSSL GUI "tinyca". 128 | # 129 | # ssl-ca=/etc/mysql/cacert.pem 130 | # ssl-cert=/etc/mysql/server-cert.pem 131 | # ssl-key=/etc/mysql/server-key.pem 132 | 133 | [mysqldump] 134 | quick 135 | quote-names 136 | max_allowed_packet = 16M 137 | 138 | [mysql] 139 | #no-auto-rehash # faster start of mysql but no tab completition 140 | 141 | [isamchk] 142 | key_buffer = 16M 143 | 144 | # 145 | # * NDB Cluster 146 | # 147 | # See /usr/share/doc/mysql-server-*/README.Debian for more information. 148 | # 149 | # The following configuration is read by the NDB Data Nodes (ndbd processes) 150 | # not from the NDB Management Nodes (ndb_mgmd processes). 151 | # 152 | # [MYSQL_CLUSTER] 153 | # ndb-connectstring=127.0.0.1 154 | # 155 | # * IMPORTANT: Additional settings that can override those from this file! 156 | # The files must end with '.cnf', otherwise they'll be ignored. 157 | # 158 | <%= "!includedir /etc/mysql/conf.d/" unless ["centos", "redhat","suse", "fedora"].include?(node[:platform]) %> 159 | -------------------------------------------------------------------------------- /cookbooks/mysql/templates/ubuntu-8.04/my.cnf.erb: -------------------------------------------------------------------------------- 1 | # 2 | # Generated by Chef for <%= node[:hostname] %> 3 | # 4 | # Local modifications will be overwritten. 5 | # 6 | # The MySQL database server configuration file. 7 | # 8 | # You can copy this to one of: 9 | # - "/etc/mysql/my.cnf" to set global options, 10 | # - "~/.my.cnf" to set user-specific options. 11 | # 12 | # One can use all long options that the program supports. 13 | # Run program with --help to get a list of available options and with 14 | # --print-defaults to see which it would actually understand and use. 15 | # 16 | # For explanations see 17 | # http://dev.mysql.com/doc/mysql/en/server-system-variables.html 18 | 19 | # This will be passed to all mysql clients 20 | # It has been reported that passwords should be enclosed with ticks/quotes 21 | # escpecially if they contain "#" chars... 22 | # Remember to edit /etc/mysql/debian.cnf when changing the socket location. 23 | [client] 24 | port = 3306 25 | socket = /var/run/mysqld/mysqld.sock 26 | 27 | # Here is entries for some specific programs 28 | # The following values assume you have at least 32M ram 29 | 30 | # This was formally known as [safe_mysqld]. Both versions are currently parsed. 31 | [mysqld_safe] 32 | socket = /var/run/mysqld/mysqld.sock 33 | nice = 0 34 | 35 | [mysqld] 36 | # 37 | # * Basic Settings 38 | # 39 | 40 | # 41 | # * IMPORTANT 42 | # If you make changes to these settings and your system uses apparmor, you may 43 | # also need to also adjust /etc/apparmor.d/usr.sbin.mysqld. 44 | # 45 | 46 | user = mysql 47 | pid-file = /var/run/mysqld/mysqld.pid 48 | socket = /var/run/mysqld/mysqld.sock 49 | port = 3306 50 | basedir = /usr 51 | datadir = <%= node[:mysql][:datadir] %> 52 | tmpdir = /tmp 53 | skip-external-locking 54 | # 55 | # Instead of skip-networking the default is now to listen only on 56 | # localhost which is more compatible and is not less secure. 57 | bind-address = <%= node[:mysql][:bind_address] %> 58 | # 59 | # * Fine Tuning 60 | # 61 | key_buffer = <%= node[:mysql][:tunable][:key_buffer] %> 62 | max_allowed_packet = 16M 63 | thread_stack = 128K 64 | thread_cache_size = 8 65 | # This replaces the startup script and checks MyISAM tables if needed 66 | # the first time they are touched 67 | myisam-recover = BACKUP 68 | #max_connections = 100 69 | #table_cache = 64 70 | #thread_concurrency = 10 71 | max_connections = <%= node[:mysql][:tunable][:max_connections] %> 72 | wait_timeout = <%= node[:mysql][:tunable][:wait_timeout] %> 73 | net_read_timeout = <%= node[:mysql][:tunable][:net_read_timeout] %> 74 | net_write_timeout = <%= node[:mysql][:tunable][:net_write_timeout] %> 75 | back_log = <%= node[:mysql][:tunable][:back_log] %> 76 | table_cache = <%= node[:mysql][:tunable][:table_cache] %> 77 | max_heap_table_size = <%= node[:mysql][:tunable][:max_heap_table_size] %> 78 | 79 | # 80 | # * Query Cache Configuration 81 | # 82 | query_cache_limit = 1M 83 | query_cache_size = 16M 84 | # 85 | # * Logging and Replication 86 | # 87 | # Both location gets rotated by the cronjob. 88 | # Be aware that this log type is a performance killer. 89 | #log = /var/log/mysql/mysql.log 90 | # 91 | # Error logging goes to syslog. This is a Debian improvement :) 92 | # 93 | # Here you can see queries with especially long duration 94 | log_slow_queries = /var/log/mysql/mysql-slow.log 95 | long_query_time = 2 96 | log-queries-not-using-indexes 97 | # 98 | # The following can be used as easy to replay backup logs or for replication. 99 | # note: if you are setting up a replication slave, see README.Debian about 100 | # other settings you may need to change. 101 | #server-id = 1 102 | #log_bin = /var/log/mysql/mysql-bin.log 103 | expire_logs_days = 10 104 | max_binlog_size = 100M 105 | #binlog_do_db = include_database_name 106 | #binlog_ignore_db = include_database_name 107 | # 108 | # * BerkeleyDB 109 | # 110 | # Using BerkeleyDB is now discouraged as its support will cease in 5.1.12. 111 | skip-bdb 112 | # 113 | # * InnoDB 114 | # 115 | # InnoDB is enabled by default with a 10MB datafile in /var/lib/mysql/. 116 | # Read the manual for more InnoDB related options. There are many! 117 | # You might want to disable InnoDB to shrink the mysqld process by circa 100MB. 118 | #skip-innodb 119 | # 120 | # * Security Features 121 | # 122 | # Read the manual, too, if you want chroot! 123 | # chroot = /var/lib/mysql/ 124 | # 125 | # For generating SSL certificates I recommend the OpenSSL GUI "tinyca". 126 | # 127 | # ssl-ca=/etc/mysql/cacert.pem 128 | # ssl-cert=/etc/mysql/server-cert.pem 129 | # ssl-key=/etc/mysql/server-key.pem 130 | 131 | [mysqldump] 132 | quick 133 | quote-names 134 | max_allowed_packet = 16M 135 | 136 | [mysql] 137 | #no-auto-rehash # faster start of mysql but no tab completition 138 | 139 | [isamchk] 140 | key_buffer = 16M 141 | 142 | # 143 | # * NDB Cluster 144 | # 145 | # See /usr/share/doc/mysql-server-*/README.Debian for more information. 146 | # 147 | # The following configuration is read by the NDB Data Nodes (ndbd processes) 148 | # not from the NDB Management Nodes (ndb_mgmd processes). 149 | # 150 | # [MYSQL_CLUSTER] 151 | # ndb-connectstring=127.0.0.1 152 | # 153 | # * IMPORTANT: Additional settings that can override those from this file! 154 | # The files must end with '.cnf', otherwise they'll be ignored. 155 | # 156 | <%= "!includedir /etc/mysql/conf.d/" unless ["centos", "redhat","suse", "fedora"].include?(node[:platform]) %> 157 | -------------------------------------------------------------------------------- /cookbooks/mysql/templates/ubuntu-9.10/my.cnf.erb: -------------------------------------------------------------------------------- 1 | # 2 | # Generated by Chef for <%= node[:hostname] %> 3 | # 4 | # Local modifications will be overwritten. 5 | # 6 | # The MySQL database server configuration file. 7 | # 8 | # You can copy this to one of: 9 | # - "/etc/mysql/my.cnf" to set global options, 10 | # - "~/.my.cnf" to set user-specific options. 11 | # 12 | # One can use all long options that the program supports. 13 | # Run program with --help to get a list of available options and with 14 | # --print-defaults to see which it would actually understand and use. 15 | # 16 | # For explanations see 17 | # http://dev.mysql.com/doc/mysql/en/server-system-variables.html 18 | 19 | # This will be passed to all mysql clients 20 | # It has been reported that passwords should be enclosed with ticks/quotes 21 | # escpecially if they contain "#" chars... 22 | # Remember to edit /etc/mysql/debian.cnf when changing the socket location. 23 | [client] 24 | port = 3306 25 | socket = /var/run/mysqld/mysqld.sock 26 | 27 | # Here is entries for some specific programs 28 | # The following values assume you have at least 32M ram 29 | 30 | # This was formally known as [safe_mysqld]. Both versions are currently parsed. 31 | [mysqld_safe] 32 | socket = /var/run/mysqld/mysqld.sock 33 | nice = 0 34 | 35 | [mysqld] 36 | # 37 | # * Basic Settings 38 | # 39 | 40 | # 41 | # * IMPORTANT 42 | # If you make changes to these settings and your system uses apparmor, you may 43 | # also need to also adjust /etc/apparmor.d/usr.sbin.mysqld. 44 | # 45 | 46 | user = mysql 47 | pid-file = /var/run/mysqld/mysqld.pid 48 | socket = /var/run/mysqld/mysqld.sock 49 | port = 3306 50 | basedir = /usr 51 | datadir = <%= node[:mysql][:datadir] %> 52 | tmpdir = /tmp 53 | skip-external-locking 54 | # 55 | # Instead of skip-networking the default is now to listen only on 56 | # localhost which is more compatible and is not less secure. 57 | bind-address = <%= node[:mysql][:bind_address] %> 58 | # 59 | # * Fine Tuning 60 | # 61 | key_buffer = <%= node[:mysql][:tunable][:key_buffer] %> 62 | max_allowed_packet = 16M 63 | thread_stack = 192K 64 | thread_cache_size = 8 65 | # This replaces the startup script and checks MyISAM tables if needed 66 | # the first time they are touched 67 | myisam-recover = BACKUP 68 | #max_connections = 100 69 | #table_cache = 64 70 | #thread_concurrency = 10 71 | max_connections = <%= node[:mysql][:tunable][:max_connections] %> 72 | wait_timeout = <%= node[:mysql][:tunable][:wait_timeout] %> 73 | net_read_timeout = <%= node[:mysql][:tunable][:net_read_timeout] %> 74 | net_write_timeout = <%= node[:mysql][:tunable][:net_write_timeout] %> 75 | back_log = <%= node[:mysql][:tunable][:back_log] %> 76 | table_cache = <%= node[:mysql][:tunable][:table_cache] %> 77 | max_heap_table_size = <%= node[:mysql][:tunable][:max_heap_table_size] %> 78 | 79 | # 80 | # * Query Cache Configuration 81 | # 82 | query_cache_limit = 1M 83 | query_cache_size = 16M 84 | # 85 | # * Logging and Replication 86 | # 87 | # Both location gets rotated by the cronjob. 88 | # Be aware that this log type is a performance killer. 89 | #log = /var/log/mysql/mysql.log 90 | # 91 | # Error logging goes to syslog. This is a Debian improvement :) 92 | # 93 | # Here you can see queries with especially long duration 94 | log_slow_queries = /var/log/mysql/mysql-slow.log 95 | long_query_time = 2 96 | log-queries-not-using-indexes 97 | # 98 | # The following can be used as easy to replay backup logs or for replication. 99 | # note: if you are setting up a replication slave, see README.Debian about 100 | # other settings you may need to change. 101 | #server-id = 1 102 | #log_bin = /var/log/mysql/mysql-bin.log 103 | expire_logs_days = 10 104 | max_binlog_size = 100M 105 | #binlog_do_db = include_database_name 106 | #binlog_ignore_db = include_database_name 107 | # 108 | # * InnoDB 109 | # 110 | # InnoDB is enabled by default with a 10MB datafile in /var/lib/mysql/. 111 | # Read the manual for more InnoDB related options. There are many! 112 | # You might want to disable InnoDB to shrink the mysqld process by circa 100MB. 113 | #skip-innodb 114 | # 115 | # * Federated 116 | # 117 | # The FEDERATED storage engine is disabled since 5.0.67 by default in the .cnf files 118 | # shipped with MySQL distributions (my-huge.cnf, my-medium.cnf, and so forth). 119 | # 120 | skip-federated 121 | # 122 | # * Security Features 123 | # 124 | # Read the manual, too, if you want chroot! 125 | # chroot = /var/lib/mysql/ 126 | # 127 | # For generating SSL certificates I recommend the OpenSSL GUI "tinyca". 128 | # 129 | # ssl-ca=/etc/mysql/cacert.pem 130 | # ssl-cert=/etc/mysql/server-cert.pem 131 | # ssl-key=/etc/mysql/server-key.pem 132 | 133 | [mysqldump] 134 | quick 135 | quote-names 136 | max_allowed_packet = 16M 137 | 138 | [mysql] 139 | #no-auto-rehash # faster start of mysql but no tab completition 140 | 141 | [isamchk] 142 | key_buffer = 16M 143 | 144 | # 145 | # * NDB Cluster 146 | # 147 | # See /usr/share/doc/mysql-server-*/README.Debian for more information. 148 | # 149 | # The following configuration is read by the NDB Data Nodes (ndbd processes) 150 | # not from the NDB Management Nodes (ndb_mgmd processes). 151 | # 152 | # [MYSQL_CLUSTER] 153 | # ndb-connectstring=127.0.0.1 154 | # 155 | # * IMPORTANT: Additional settings that can override those from this file! 156 | # The files must end with '.cnf', otherwise they'll be ignored. 157 | # 158 | <%= "!includedir /etc/mysql/conf.d/" unless ["centos", "redhat","suse", "fedora"].include?(node[:platform]) %> 159 | -------------------------------------------------------------------------------- /cookbooks/openssl/README.rdoc: -------------------------------------------------------------------------------- 1 | = DESCRIPTION: 2 | 3 | Library provides a method to generate secure passwords for use in recipes. 4 | 5 | = REQUIREMENTS: 6 | 7 | OpenSSL Ruby bindings must be installed, which are a requirement for Chef anyway. 8 | 9 | = USAGE: 10 | 11 | Most often this will be used to generate a secure password for an attribute. 12 | 13 | include Opscode::OpenSSL::Password 14 | 15 | set_unless[:my_password] = secure_password 16 | 17 | = LICENSE and AUTHOR: 18 | 19 | Author:: Joshua Timberman () 20 | 21 | Copyright:: 2009, Opscode, Inc 22 | 23 | Licensed under the Apache License, Version 2.0 (the "License"); 24 | you may not use this file except in compliance with the License. 25 | You may obtain a copy of the License at 26 | 27 | http://www.apache.org/licenses/LICENSE-2.0 28 | 29 | Unless required by applicable law or agreed to in writing, software 30 | distributed under the License is distributed on an "AS IS" BASIS, 31 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 32 | See the License for the specific language governing permissions and 33 | limitations under the License. 34 | -------------------------------------------------------------------------------- /cookbooks/openssl/libraries/secure_password.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: openssl 3 | # Library:: secure_password 4 | # Author:: Joshua Timberman 5 | # 6 | # Copyright 2009, Opscode, Inc. 7 | # 8 | # Licensed under the Apache License, Version 2.0 (the "License"); 9 | # you may not use this file except in compliance with the License. 10 | # You may obtain a copy of the License at 11 | # 12 | # http://www.apache.org/licenses/LICENSE-2.0 13 | # 14 | # Unless required by applicable law or agreed to in writing, software 15 | # distributed under the License is distributed on an "AS IS" BASIS, 16 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | # See the License for the specific language governing permissions and 18 | # limitations under the License. 19 | # 20 | 21 | require 'openssl' 22 | 23 | module Opscode 24 | module OpenSSL 25 | module Password 26 | def secure_password 27 | pw = String.new 28 | 29 | while pw.length < 20 30 | pw << ::OpenSSL::Random.random_bytes(1).gsub(/\W/, '') 31 | end 32 | 33 | pw 34 | end 35 | end 36 | end 37 | end 38 | -------------------------------------------------------------------------------- /cookbooks/openssl/metadata.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": { 3 | }, 4 | "attributes": { 5 | }, 6 | "maintainer": "Opscode, Inc.", 7 | "suggestions": { 8 | }, 9 | "dependencies": { 10 | }, 11 | "maintainer_email": "cookbooks@opscode.com", 12 | "conflicting": { 13 | }, 14 | "platforms": { 15 | }, 16 | "license": "Apache 2.0", 17 | "version": "0.1.0", 18 | "providing": { 19 | }, 20 | "recipes": { 21 | "openssl": "Empty, this cookbook provides a library, see README" 22 | }, 23 | "replacing": { 24 | }, 25 | "name": "openssl", 26 | "description": "Installs/Configures openssl", 27 | "groupings": { 28 | }, 29 | "long_description": "= DESCRIPTION:\n\nLibrary provides a method to generate secure passwords for use in recipes.\n\n= REQUIREMENTS:\n\nOpenSSL Ruby bindings must be installed, which are a requirement for Chef anyway.\n\n= USAGE:\n\nMost often this will be used to generate a secure password for an attribute.\n\n include Opscode::OpenSSL::Password\n\n set_unless[:my_password] = secure_password\n\n= LICENSE and AUTHOR:\n\nAuthor:: Joshua Timberman ()\n\nCopyright:: 2009, Opscode, Inc\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n" 30 | } -------------------------------------------------------------------------------- /cookbooks/openssl/metadata.rb: -------------------------------------------------------------------------------- 1 | maintainer "Opscode, Inc." 2 | maintainer_email "cookbooks@opscode.com" 3 | license "Apache 2.0" 4 | description "Installs/Configures openssl" 5 | long_description IO.read(File.join(File.dirname(__FILE__), 'README.rdoc')) 6 | version "0.1" 7 | 8 | recipe "openssl", "Empty, this cookbook provides a library, see README" 9 | -------------------------------------------------------------------------------- /cookbooks/openssl/recipes/default.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: openssl 3 | # Recipe:: default 4 | # 5 | # Copyright 2009, Opscode, Inc. 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | 20 | -------------------------------------------------------------------------------- /cookbooks/postgresql/README.rdoc: -------------------------------------------------------------------------------- 1 | = DESCRIPTION: 2 | 3 | Installs and configures postgresql client or server. 4 | 5 | = REQUIREMENTS: 6 | 7 | == Platform: 8 | 9 | Tested on CentOS 5.5, Ubuntu 10.04 but should support centos, redhat, fedora, suse, ubuntu and debian. 10 | 11 | == Cookbooks: 12 | 13 | = ATTRIBUTES: 14 | 15 | * postgresql[:dir] - configuration file location. 16 | * postgresql[:version] - Version of postgresql to use. Configured in attributes based on platform. 17 | * postgresql[:ssl] - used on debian family installs to enable ssl support. The debian post installation script automatically builds the certificates. 18 | 19 | = USAGE: 20 | 21 | For clients: 22 | 23 | include_recipe "postgresql::client" 24 | 25 | For server: 26 | 27 | include_recipe "postgresql::server" 28 | 29 | (client is already included by server). This will check the platform that the node is and include either redhat family recipe (postgresql::server_redhat) or debian family (postgresql::server_debian) because the two styles differ quite a bit. 30 | 31 | The templates provided by this cookbook will probably need to be tweaked for the local environment, no tuning parameters are specified in them. The templates are separated by family designation in the template directory, since Chef doesn't do "platform family" style file specificity. 32 | 33 | = LICENSE and AUTHOR: 34 | 35 | Author:: Joshua Timberman () 36 | 37 | Copyright:: 2009-2010, Opscode, Inc 38 | 39 | Licensed under the Apache License, Version 2.0 (the "License"); 40 | you may not use this file except in compliance with the License. 41 | You may obtain a copy of the License at 42 | 43 | http://www.apache.org/licenses/LICENSE-2.0 44 | 45 | Unless required by applicable law or agreed to in writing, software 46 | distributed under the License is distributed on an "AS IS" BASIS, 47 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 48 | See the License for the specific language governing permissions and 49 | limitations under the License. 50 | -------------------------------------------------------------------------------- /cookbooks/postgresql/attributes/default.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: postgresql 3 | # Attributes:: postgresql 4 | # 5 | # Copyright 2008-2009, Opscode, Inc. 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | case platform 20 | when "debian" 21 | 22 | if platform_version.to_f == 5.0 23 | default[:postgresql][:version] = "8.3" 24 | elsif platform_version =~ /.*sid/ 25 | default[:postgresql][:version] = "8.4" 26 | end 27 | 28 | set[:postgresql][:dir] = "/etc/postgresql/#{node[:postgresql][:version]}/main" 29 | 30 | when "ubuntu" 31 | 32 | if platform_version.to_f <= 9.04 33 | default[:postgresql][:version] = "8.3" 34 | else 35 | default[:postgresql][:version] = "8.4" 36 | end 37 | 38 | set[:postgresql][:dir] = "/etc/postgresql/#{node[:postgresql][:version]}/main" 39 | 40 | when "fedora" 41 | 42 | if platform_version.to_f <= 12 43 | default[:postgresql][:version] = "8.3" 44 | else 45 | default[:postgresql][:version] = "8.4" 46 | end 47 | 48 | set[:postgresql][:dir] = "/var/lib/pgsql/data" 49 | 50 | when "redhat","centos" 51 | 52 | default[:postgresql][:version] = "8.4" 53 | set[:postgresql][:dir] = "/var/lib/pgsql/data" 54 | 55 | when "suse" 56 | 57 | if platform_version.to_f <= 11.1 58 | default[:postgresql][:version] = "8.3" 59 | else 60 | default[:postgresql][:version] = "8.4" 61 | end 62 | 63 | set[:postgresql][:dir] = "/var/lib/pgsql/data" 64 | 65 | else 66 | default[:postgresql][:version] = "8.4" 67 | set[:postgresql][:dir] = "/etc/postgresql/#{node[:postgresql][:version]}/main" 68 | end 69 | -------------------------------------------------------------------------------- /cookbooks/postgresql/metadata.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "postgresql", 3 | "description": "Installs and configures postgresql for clients or servers", 4 | "long_description": "= DESCRIPTION:\n\nInstalls and configures postgresql client or server.\n\n= REQUIREMENTS:\n\n== Platform:\n\nTested on CentOS 5.5, Ubuntu 10.04 but should support centos, redhat, fedora, suse, ubuntu and debian.\n\n== Cookbooks:\n\n= ATTRIBUTES: \n\n* postgresql[:dir] - configuration file location.\n* postgresql[:version] - Version of postgresql to use. Configured in attributes based on platform.\n* postgresql[:ssl] - used on debian family installs to enable ssl support. The debian post installation script automatically builds the certificates.\n\n= USAGE:\n\nFor clients:\n\n include_recipe \"postgresql::client\"\n \nFor server: \n\n include_recipe \"postgresql::server\"\n \n(client is already included by server). This will check the platform that the node is and include either redhat family recipe (postgresql::server_redhat) or debian family (postgresql::server_debian) because the two styles differ quite a bit.\n\nThe templates provided by this cookbook will probably need to be tweaked for the local environment, no tuning parameters are specified in them. The templates are separated by family designation in the template directory, since Chef doesn't do \"platform family\" style file specificity.\n\n= LICENSE and AUTHOR:\n \nAuthor:: Joshua Timberman ()\n\nCopyright:: 2009-2010, Opscode, Inc\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n", 5 | "maintainer": "Opscode, Inc.", 6 | "maintainer_email": "cookbooks@opscode.com", 7 | "license": "Apache 2.0", 8 | "platforms": { 9 | "rhel": [ 10 | 11 | ], 12 | "centos": [ 13 | 14 | ], 15 | "fedora": [ 16 | 17 | ], 18 | "ubuntu": [ 19 | 20 | ], 21 | "debian": [ 22 | 23 | ], 24 | "suse": [ 25 | 26 | ] 27 | }, 28 | "dependencies": { 29 | }, 30 | "recommendations": { 31 | }, 32 | "suggestions": { 33 | }, 34 | "conflicting": { 35 | }, 36 | "providing": { 37 | }, 38 | "replacing": { 39 | }, 40 | "attributes": { 41 | }, 42 | "groupings": { 43 | }, 44 | "recipes": { 45 | "postgresql": "Empty, use one of the other recipes", 46 | "postgresql::client": "Installs postgresql client package(s)", 47 | "postgresql::server": "Installs postgresql server packages, debian family style", 48 | "postgresql::redhat": "Installs postgresql server packages, redhat family style" 49 | }, 50 | "version": "0.11.1" 51 | } -------------------------------------------------------------------------------- /cookbooks/postgresql/metadata.rb: -------------------------------------------------------------------------------- 1 | maintainer "Opscode, Inc." 2 | maintainer_email "cookbooks@opscode.com" 3 | license "Apache 2.0" 4 | description "Installs and configures postgresql for clients or servers" 5 | long_description IO.read(File.join(File.dirname(__FILE__), 'README.rdoc')) 6 | version "0.11.1" 7 | recipe "postgresql", "Empty, use one of the other recipes" 8 | recipe "postgresql::client", "Installs postgresql client package(s)" 9 | recipe "postgresql::server", "Installs postgresql server packages, templates" 10 | recipe "postgresql::redhat", "Installs postgresql server packages, redhat family style" 11 | recipe "postgresql::server", "Installs postgresql server packages, debian family style" 12 | 13 | %w{rhel centos fedora ubuntu debian suse}.each do |os| 14 | supports os 15 | end 16 | -------------------------------------------------------------------------------- /cookbooks/postgresql/recipes/client.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: postgresql 3 | # Recipe:: client 4 | # 5 | # Copyright 2009, Opscode, Inc. 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | 20 | case node.platform 21 | when "ubuntu","debian" 22 | package "postgresql-client" 23 | when "fedora","suse" 24 | package "postgresql-devel" 25 | when "redhat","centos" 26 | package "postgresql#{node.postgresql.version.split('.').join}-devel" 27 | end 28 | -------------------------------------------------------------------------------- /cookbooks/postgresql/recipes/default.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: postgresql 3 | # Recipe:: default 4 | # 5 | # Copyright 2009, Opscode, Inc. 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | 20 | include_recipe "postgresql::client" 21 | -------------------------------------------------------------------------------- /cookbooks/postgresql/recipes/server.rb: -------------------------------------------------------------------------------- 1 | #/postgresql.conf. 2 | # Cookbook Name:: postgresql 3 | # Recipe:: server 4 | # 5 | # Copyright 2009-2010, Opscode, Inc. 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | 20 | include_recipe "postgresql::client" 21 | 22 | case node[:postgresql][:version] 23 | when "8.3" 24 | node.default[:postgresql][:ssl] = "off" 25 | when "8.4" 26 | node.default[:postgresql][:ssl] = "true" 27 | end 28 | 29 | # Include the right "family" recipe for installing the server 30 | # since they do things slightly differently. 31 | case node.platform 32 | when "redhat", "centos", "fedora", "suse" 33 | include_recipe "postgresql::server_redhat" 34 | when "debian", "ubuntu" 35 | include_recipe "postgresql::server_debian" 36 | end 37 | -------------------------------------------------------------------------------- /cookbooks/postgresql/recipes/server_debian.rb: -------------------------------------------------------------------------------- 1 | #/postgresql.conf. 2 | # Cookbook Name:: postgresql 3 | # Recipe:: server 4 | # 5 | # Copyright 2009-2010, Opscode, Inc. 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | 20 | include_recipe "postgresql::client" 21 | 22 | case node[:postgresql][:version] 23 | when "8.3" 24 | node.default[:postgresql][:ssl] = "off" 25 | when "8.4" 26 | node.default[:postgresql][:ssl] = "true" 27 | end 28 | 29 | package "postgresql" 30 | 31 | service "postgresql" do 32 | service_name "postgresql-#{node.postgresql.version}" 33 | supports :restart => true, :status => true, :reload => true 34 | action :nothing 35 | end 36 | 37 | template "#{node[:postgresql][:dir]}/pg_hba.conf" do 38 | source "debian.pg_hba.conf.erb" 39 | owner "postgres" 40 | group "postgres" 41 | mode 0600 42 | notifies :reload, resources(:service => "postgresql") 43 | end 44 | 45 | template "#{node[:postgresql][:dir]}/postgresql.conf" do 46 | source "debian.postgresql.conf.erb" 47 | owner "postgres" 48 | group "postgres" 49 | mode 0600 50 | notifies :restart, resources(:service => "postgresql") 51 | end 52 | -------------------------------------------------------------------------------- /cookbooks/postgresql/recipes/server_redhat.rb: -------------------------------------------------------------------------------- 1 | #/postgresql.conf. 2 | # Cookbook Name:: postgresql 3 | # Recipe:: server 4 | # 5 | # Copyright 2009-2010, Opscode, Inc. 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | 20 | include_recipe "postgresql::client" 21 | 22 | # Create a group and user like the package will. 23 | # Otherwise the templates fail. 24 | 25 | group "postgres" do 26 | # Workaround lack of option for -r and -o... 27 | group_name "-r -o postgres" 28 | not_if { Etc.getgrnam("postgres") } 29 | gid 26 30 | end 31 | 32 | user "postgres" do 33 | # Workaround lack of option for -M and -n... 34 | username "-M -n postgres" 35 | not_if { Etc.getpwnam("postgres") } 36 | shell "/bin/bash" 37 | comment "PostgreSQL Server" 38 | home "/var/lib/pgsql" 39 | gid "postgres" 40 | system true 41 | uid 26 42 | supports :non_unique => true 43 | end 44 | 45 | package "postgresql" do 46 | case node.platform 47 | when "redhat","centos" 48 | package_name "postgresql#{node.postgresql.version.split('.').join}" 49 | else 50 | package_name "postgresql" 51 | end 52 | end 53 | 54 | case node.platform 55 | when "redhat","centos" 56 | package "postgresql#{node.postgresql.version.split('.').join}-server" 57 | when "fedora","suse" 58 | package "postgresql-server" 59 | end 60 | 61 | execute "/sbin/service postgresql initdb" do 62 | not_if { ::FileTest.exist?(File.join(node.postgresql.dir, "PG_VERSION")) } 63 | end 64 | 65 | service "postgresql" do 66 | supports :restart => true, :status => true, :reload => true 67 | action [:enable, :start] 68 | end 69 | 70 | template "#{node[:postgresql][:dir]}/pg_hba.conf" do 71 | source "redhat.pg_hba.conf.erb" 72 | owner "postgres" 73 | group "postgres" 74 | mode 0600 75 | notifies :reload, resources(:service => "postgresql") 76 | end 77 | 78 | template "#{node[:postgresql][:dir]}/postgresql.conf" do 79 | source "redhat.postgresql.conf.erb" 80 | owner "postgres" 81 | group "postgres" 82 | mode 0600 83 | notifies :restart, resources(:service => "postgresql") 84 | end 85 | -------------------------------------------------------------------------------- /cookbooks/postgresql/templates/default/debian.pg_hba.conf.erb: -------------------------------------------------------------------------------- 1 | # PostgreSQL Client Authentication Configuration File 2 | # =================================================== 3 | # 4 | # Refer to the "Client Authentication" section in the 5 | # PostgreSQL documentation for a complete description 6 | # of this file. A short synopsis follows. 7 | # 8 | # This file controls: which hosts are allowed to connect, how clients 9 | # are authenticated, which PostgreSQL user names they can use, which 10 | # databases they can access. Records take one of these forms: 11 | # 12 | # local DATABASE USER METHOD [OPTION] 13 | # host DATABASE USER CIDR-ADDRESS METHOD [OPTION] 14 | # hostssl DATABASE USER CIDR-ADDRESS METHOD [OPTION] 15 | # hostnossl DATABASE USER CIDR-ADDRESS METHOD [OPTION] 16 | # 17 | # (The uppercase items must be replaced by actual values.) 18 | # 19 | # The first field is the connection type: "local" is a Unix-domain socket, 20 | # "host" is either a plain or SSL-encrypted TCP/IP socket, "hostssl" is an 21 | # SSL-encrypted TCP/IP socket, and "hostnossl" is a plain TCP/IP socket. 22 | # 23 | # DATABASE can be "all", "sameuser", "samerole", a database name, or 24 | # a comma-separated list thereof. 25 | # 26 | # USER can be "all", a user name, a group name prefixed with "+", or 27 | # a comma-separated list thereof. In both the DATABASE and USER fields 28 | # you can also write a file name prefixed with "@" to include names from 29 | # a separate file. 30 | # 31 | # CIDR-ADDRESS specifies the set of hosts the record matches. 32 | # It is made up of an IP address and a CIDR mask that is an integer 33 | # (between 0 and 32 (IPv4) or 128 (IPv6) inclusive) that specifies 34 | # the number of significant bits in the mask. Alternatively, you can write 35 | # an IP address and netmask in separate columns to specify the set of hosts. 36 | # 37 | # METHOD can be "trust", "reject", "md5", "crypt", "password", "gss", "sspi", 38 | # "krb5", "ident", "pam" or "ldap". Note that "password" sends passwords 39 | # in clear text; "md5" is preferred since it sends encrypted passwords. 40 | # 41 | # OPTION is the ident map or the name of the PAM service, depending on METHOD. 42 | # 43 | # Database and user names containing spaces, commas, quotes and other special 44 | # characters must be quoted. Quoting one of the keywords "all", "sameuser" or 45 | # "samerole" makes the name lose its special character, and just match a 46 | # database or username with that name. 47 | # 48 | # This file is read on server startup and when the postmaster receives 49 | # a SIGHUP signal. If you edit the file on a running system, you have 50 | # to SIGHUP the postmaster for the changes to take effect. You can use 51 | # "pg_ctl reload" to do that. 52 | 53 | # Put your actual configuration here 54 | # ---------------------------------- 55 | # 56 | # If you want to allow non-local connections, you need to add more 57 | # "host" records. In that case you will also need to make PostgreSQL listen 58 | # on a non-local interface via the listen_addresses configuration parameter, 59 | # or via the -i or -h command line switches. 60 | # 61 | 62 | 63 | 64 | 65 | # DO NOT DISABLE! 66 | # If you change this first entry you will need to make sure that the 67 | # database 68 | # super user can access the database using some other method. 69 | # Noninteractive 70 | # access to all databases is required during automatic maintenance 71 | # (autovacuum, daily cronjob, replication, and similar tasks). 72 | # 73 | # Database administrative login by UNIX sockets 74 | local all postgres ident 75 | 76 | # TYPE DATABASE USER CIDR-ADDRESS METHOD 77 | 78 | # "local" is for Unix domain socket connections only 79 | local all all ident 80 | # IPv4 local connections: 81 | host all all 127.0.0.1/32 md5 82 | # IPv6 local connections: 83 | host all all ::1/128 md5 84 | -------------------------------------------------------------------------------- /cookbooks/postgresql/templates/default/redhat.pg_hba.conf.erb: -------------------------------------------------------------------------------- 1 | # PostgreSQL Client Authentication Configuration File 2 | # =================================================== 3 | # 4 | # Refer to the "Client Authentication" section in the 5 | # PostgreSQL documentation for a complete description 6 | # of this file. A short synopsis follows. 7 | # 8 | # This file controls: which hosts are allowed to connect, how clients 9 | # are authenticated, which PostgreSQL user names they can use, which 10 | # databases they can access. Records take one of these forms: 11 | # 12 | # local DATABASE USER METHOD [OPTIONS] 13 | # host DATABASE USER CIDR-ADDRESS METHOD [OPTIONS] 14 | # hostssl DATABASE USER CIDR-ADDRESS METHOD [OPTIONS] 15 | # hostnossl DATABASE USER CIDR-ADDRESS METHOD [OPTIONS] 16 | # 17 | # (The uppercase items must be replaced by actual values.) 18 | # 19 | # The first field is the connection type: "local" is a Unix-domain socket, 20 | # "host" is either a plain or SSL-encrypted TCP/IP socket, "hostssl" is an 21 | # SSL-encrypted TCP/IP socket, and "hostnossl" is a plain TCP/IP socket. 22 | # 23 | # DATABASE can be "all", "sameuser", "samerole", a database name, or 24 | # a comma-separated list thereof. 25 | # 26 | # USER can be "all", a user name, a group name prefixed with "+", or 27 | # a comma-separated list thereof. In both the DATABASE and USER fields 28 | # you can also write a file name prefixed with "@" to include names from 29 | # a separate file. 30 | # 31 | # CIDR-ADDRESS specifies the set of hosts the record matches. 32 | # It is made up of an IP address and a CIDR mask that is an integer 33 | # (between 0 and 32 (IPv4) or 128 (IPv6) inclusive) that specifies 34 | # the number of significant bits in the mask. Alternatively, you can write 35 | # an IP address and netmask in separate columns to specify the set of hosts. 36 | # 37 | # METHOD can be "trust", "reject", "md5", "password", "gss", "sspi", "krb5", 38 | # "ident", "pam", "ldap" or "cert". Note that "password" sends passwords 39 | # in clear text; "md5" is preferred since it sends encrypted passwords. 40 | # 41 | # OPTIONS are a set of options for the authentication in the format 42 | # NAME=VALUE. The available options depend on the different authentication 43 | # methods - refer to the "Client Authentication" section in the documentation 44 | # for a list of which options are available for which authentication methods. 45 | # 46 | # Database and user names containing spaces, commas, quotes and other special 47 | # characters must be quoted. Quoting one of the keywords "all", "sameuser" or 48 | # "samerole" makes the name lose its special character, and just match a 49 | # database or username with that name. 50 | # 51 | # This file is read on server startup and when the postmaster receives 52 | # a SIGHUP signal. If you edit the file on a running system, you have 53 | # to SIGHUP the postmaster for the changes to take effect. You can use 54 | # "pg_ctl reload" to do that. 55 | 56 | # Put your actual configuration here 57 | # ---------------------------------- 58 | # 59 | # If you want to allow non-local connections, you need to add more 60 | # "host" records. In that case you will also need to make PostgreSQL listen 61 | # on a non-local interface via the listen_addresses configuration parameter, 62 | # or via the -i or -h command line switches. 63 | # 64 | 65 | 66 | 67 | # TYPE DATABASE USER CIDR-ADDRESS METHOD 68 | 69 | # "local" is for Unix domain socket connections only 70 | local all all ident 71 | # IPv4 local connections: 72 | host all all 127.0.0.1/32 ident 73 | # IPv6 local connections: 74 | host all all ::1/128 ident 75 | -------------------------------------------------------------------------------- /cookbooks/rails/README.rdoc: -------------------------------------------------------------------------------- 1 | = DESCRIPTION: 2 | 3 | Installs Rails and contains Rails tuning parameters. 4 | 5 | = REQUIREMENTS: 6 | 7 | == Platform: 8 | 9 | Tested on Ubuntu 8.10, should work on other platforms. 10 | 11 | == Cookbooks: 12 | 13 | Opscode cookbooks, http://github.com/opscode/cookbooks/tree/master: 14 | 15 | * ruby 16 | * apache2 17 | * passenger 18 | 19 | = ATTRIBUTES: 20 | 21 | * rails[:version] - Install the specified version. Default false (installs latest). 22 | * rails[:environment] - Set Rails environment. Default production. 23 | 24 | = USAGE: 25 | 26 | The recommended Rails application deployment method is Passenger and use the Apache2 cookbook's web_app define. 27 | 28 | include_recipe "apache2" 29 | include_recipe "passenger" 30 | include_recipe "rails" 31 | 32 | web_app "some_rails_app" do 33 | docroot "/srv/some_rails_app/public" 34 | template "some_rails_app.conf.erb" 35 | end 36 | 37 | We provide an example rails application vhost config file in this cookbook. Remember, for Passenger, DocumentRoot (docroot) needs 'public'. Per the web_app define, other parameters can be passed arbitrarily and used in the template. 38 | 39 | = LICENSE and AUTHOR: 40 | 41 | Author:: Joshua Timberman () 42 | Copyright:: 2009, Opscode, Inc 43 | 44 | Licensed under the Apache License, Version 2.0 (the "License"); 45 | you may not use this file except in compliance with the License. 46 | You may obtain a copy of the License at 47 | 48 | http://www.apache.org/licenses/LICENSE-2.0 49 | 50 | Unless required by applicable law or agreed to in writing, software 51 | distributed under the License is distributed on an "AS IS" BASIS, 52 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 53 | See the License for the specific language governing permissions and 54 | limitations under the License. 55 | -------------------------------------------------------------------------------- /cookbooks/rails/attributes/default.rb: -------------------------------------------------------------------------------- 1 | default[:rails][:version] = false 2 | default[:rails][:environment] = "production" 3 | default[:rails][:max_pool_size] = 4 4 | -------------------------------------------------------------------------------- /cookbooks/rails/metadata.json: -------------------------------------------------------------------------------- 1 | { 2 | "providing": { 3 | }, 4 | "attributes": { 5 | "rails/version": { 6 | "required": "optional", 7 | "calculated": false, 8 | "choice": [ 9 | 10 | ], 11 | "default": "false", 12 | "type": "string", 13 | "recipes": [ 14 | 15 | ], 16 | "description": "Specify the version of Rails to install", 17 | "display_name": "Rails Version" 18 | }, 19 | "rails": { 20 | "required": "optional", 21 | "calculated": false, 22 | "choice": [ 23 | 24 | ], 25 | "type": "hash", 26 | "recipes": [ 27 | 28 | ], 29 | "description": "Hash of Rails attributes", 30 | "display_name": "Rails" 31 | }, 32 | "rails/max_pool_size": { 33 | "required": "optional", 34 | "calculated": false, 35 | "choice": [ 36 | 37 | ], 38 | "default": "4", 39 | "type": "string", 40 | "recipes": [ 41 | 42 | ], 43 | "description": "Specify the MaxPoolSize in the Apache vhost", 44 | "display_name": "Rails Max Pool Size" 45 | }, 46 | "rails/environment": { 47 | "required": "optional", 48 | "calculated": false, 49 | "choice": [ 50 | 51 | ], 52 | "default": "production", 53 | "type": "string", 54 | "recipes": [ 55 | 56 | ], 57 | "description": "Specify the environment to use for Rails", 58 | "display_name": "Rails Environment" 59 | } 60 | }, 61 | "replacing": { 62 | }, 63 | "dependencies": { 64 | "apache2": [ 65 | 66 | ], 67 | "ruby": [ 68 | 69 | ] 70 | }, 71 | "groupings": { 72 | }, 73 | "recommendations": { 74 | }, 75 | "platforms": { 76 | "debian": [ 77 | 78 | ], 79 | "fedora": [ 80 | 81 | ], 82 | "centos": [ 83 | 84 | ], 85 | "ubuntu": [ 86 | 87 | ], 88 | "redhat": [ 89 | 90 | ] 91 | }, 92 | "license": "Apache 2.0", 93 | "version": "0.9.2", 94 | "maintainer": "Opscode, Inc.", 95 | "suggestions": { 96 | }, 97 | "recipes": { 98 | "rails": "Installs rails gems" 99 | }, 100 | "maintainer_email": "cookbooks@opscode.com", 101 | "name": "rails", 102 | "conflicting": { 103 | }, 104 | "description": "Installs rails and provides a sample template for use with passenger", 105 | "long_description": "= DESCRIPTION:\n\nInstalls Rails and contains Rails tuning parameters.\n\n= REQUIREMENTS:\n\n== Platform:\n\nTested on Ubuntu 8.10, should work on other platforms.\n\n== Cookbooks:\n\nOpscode cookbooks, http://github.com/opscode/cookbooks/tree/master:\n\n* ruby \n* apache2 \n* passenger \n\n= ATTRIBUTES: \n\n* rails[:version] - Install the specified version. Default false (installs latest).\n* rails[:environment] - Set Rails environment. Default production.\n\n= USAGE:\n\nThe recommended Rails application deployment method is Passenger and use the Apache2 cookbook's web_app define.\n\n include_recipe \"apache2\"\n include_recipe \"passenger\"\n include_recipe \"rails\"\n\n web_app \"some_rails_app\" do\n docroot \"/srv/some_rails_app/public\"\n template \"some_rails_app.conf.erb\"\n end\n\nWe provide an example rails application vhost config file in this cookbook. Remember, for Passenger, DocumentRoot (docroot) needs 'public'. Per the web_app define, other parameters can be passed arbitrarily and used in the template. \n\n= LICENSE and AUTHOR:\n\nAuthor:: Joshua Timberman ()\nCopyright:: 2009, Opscode, Inc\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n" 106 | } -------------------------------------------------------------------------------- /cookbooks/rails/metadata.rb: -------------------------------------------------------------------------------- 1 | maintainer "Opscode, Inc." 2 | maintainer_email "cookbooks@opscode.com" 3 | license "Apache 2.0" 4 | description "Installs rails and provides a sample template for use with passenger" 5 | long_description IO.read(File.join(File.dirname(__FILE__), 'README.rdoc')) 6 | version "0.9.2" 7 | 8 | recipe "rails", "Installs rails gems" 9 | 10 | %w{ ruby apache2 }.each do |cb| 11 | depends cb 12 | end 13 | 14 | %w{ ubuntu debian centos redhat fedora}.each do |os| 15 | supports os 16 | end 17 | 18 | attribute "rails", 19 | :display_name => "Rails", 20 | :description => "Hash of Rails attributes", 21 | :type => "hash" 22 | 23 | attribute "rails/version", 24 | :display_name => "Rails Version", 25 | :description => "Specify the version of Rails to install", 26 | :default => "false" 27 | 28 | attribute "rails/environment", 29 | :display_name => "Rails Environment", 30 | :description => "Specify the environment to use for Rails", 31 | :default => "production" 32 | 33 | attribute "rails/max_pool_size", 34 | :display_name => "Rails Max Pool Size", 35 | :description => "Specify the MaxPoolSize in the Apache vhost", 36 | :default => "4" 37 | 38 | -------------------------------------------------------------------------------- /cookbooks/rails/recipes/default.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: rails 3 | # Recipe:: default 4 | # 5 | # Copyright 2009, Opscode, Inc. 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | 20 | include_recipe "ruby" 21 | 22 | %w{ rails actionmailer actionpack activerecord activesupport activeresource }.each do |rails_gem| 23 | gem_package rails_gem do 24 | if node[:rails][:version] 25 | version node[:rails][:version] 26 | action :install 27 | else 28 | action :install 29 | end 30 | end 31 | end 32 | -------------------------------------------------------------------------------- /cookbooks/rails/templates/default/rails_app.conf.erb: -------------------------------------------------------------------------------- 1 | 2 | ServerName <%= @params[:server_name] %> 3 | DocumentRoot <%= @params[:docroot] %> 4 | 5 | RailsBaseURI / 6 | RailsMaxPoolSize <%= node[:rails][:max_pool_size] %> 7 | RailsPoolIdleTime 3600 8 | RailsEnv '<%= node[:rails][:environment] %>' 9 | 10 | LogLevel info 11 | ErrorLog <%= node[:apache][:log_dir] %>/<%= @params[:name] %>_error.log 12 | CustomLog <%= node[:apache][:log_dir] %>/<%= @params[:name] %>_access.log combined 13 | 14 | ErrorDocument 404 /404.html 15 | ErrorDocument 500 /500.html 16 | 17 | RewriteEngine On 18 | 19 | # Handle maintenance mode 20 | RewriteCond %{DOCUMENT_ROOT}/system/maintenance.html -f 21 | RewriteCond %{SCRIPT_FILENAME} !maintenance.html 22 | RewriteRule ^/(.*)$ /system/maintenance.html [L] 23 | 24 | > 25 | Options FollowSymLinks 26 | AllowOverride None 27 | Order allow,deny 28 | Allow from all 29 | 30 | 31 | -------------------------------------------------------------------------------- /cookbooks/ruby/README.rdoc: -------------------------------------------------------------------------------- 1 | = DESCRIPTION: 2 | 3 | Installs Ruby and related packages. 4 | 5 | = REQUIREMENTS: 6 | 7 | == Platform: 8 | 9 | Tested on Ubuntu 10.04. Debian and Gentoo should also work fully. CentOS, Red Hat, Fedora and Arch are partially supported. 10 | 11 | = ATTRIBUTES: 12 | 13 | * +languages[:ruby][:default_version]+ - The Ruby version to install with the ruby recipe and create symlinks for with the symlinks recipe. 14 | 15 | = USAGE: 16 | 17 | Previous versions of this cookbook gave you no control over which version of Ruby would be installed. We are now in the middle of an awkward period where you are equally likely to want 1.8 or 1.9. You may even want both. This is now catered for. To install specific versions side-by-side, use the 1.8, 1.9 or 1.9.1 recipes. The ruby recipe will install the version specified by +languages[:ruby][:default_version]+. If you want to do something other than install these packages, the +ruby_packages+ definition is provided as a wrapper around the package resource. Just specify the version number. 18 | 19 | For example, to use the default recipe in a role named "base", use 'ruby' in the run list and set the +languages[:ruby][:default_version]+ attribute: 20 | 21 | { 22 | "name": "base", 23 | "description": "Base role is applied to all systems", 24 | "json_class": "Chef::Role", 25 | "default_attributes": { 26 | }, 27 | "override_attributes": { 28 | "languages": { 29 | "ruby": { 30 | "default_version": "1.8" 31 | } 32 | } 33 | }, 34 | "chef_type": "role", 35 | "run_list": [ 36 | "recipe[ruby]" 37 | ] 38 | } 39 | 40 | Many scripts, including those provided by Rails, don't ask for a particular version of Ruby such as "ruby1.8" and simply look for "ruby" instead. Sometimes a symlink is provided and sometimes the executable is simply called "ruby" in the first place but generally speaking, it is difficult to predict this behaviour, especially when Ruby Gems is thrown into the mix. The symlinks recipe seeks to relieve you of this headache by creating symlinks for the common executables pointing to the Ruby version specified by +languages[:ruby][:default_version]+. This is also available as a definition called +ruby_symlinks+, which is a wrapper around the link resource. As before, just specify the version number. Non-symlinks will not be overwritten unless you set force to true. You can also set a path other than /usr/bin if necessary. 41 | 42 | *IMPORTANT!* Only Ubuntu, Debian and Gentoo support installing a specific Ruby version at all. yum-based distributions install 1.8 by default but require you to give the full package version otherwise. Maybe some magic could be added to Chef? Arch installs 1.9.2 by default but 1.8 is only available from AUR. Additionally, Ubuntu and Debian group 1.9.2 with 1.9.1 while Gentoo lumps all 1.9 releases together. 43 | 44 | = LICENSE and AUTHOR: 45 | 46 | Author:: Joshua Timberman (), James Le Cuirot () 47 | 48 | Copyright:: 2009-2010, Opscode, Inc; 2010, FindsYou Limited 49 | 50 | Licensed under the Apache License, Version 2.0 (the "License"); 51 | you may not use this file except in compliance with the License. 52 | You may obtain a copy of the License at 53 | 54 | http://www.apache.org/licenses/LICENSE-2.0 55 | 56 | Unless required by applicable law or agreed to in writing, software 57 | distributed under the License is distributed on an "AS IS" BASIS, 58 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 59 | See the License for the specific language governing permissions and 60 | limitations under the License. 61 | -------------------------------------------------------------------------------- /cookbooks/ruby/definitions/ruby_packages.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: ruby 3 | # Definition:: ruby_packages 4 | # 5 | # Copyright 2008-2009, Opscode, Inc. 6 | # Copyright 2010, FindsYou Limited 7 | # 8 | # Licensed under the Apache License, Version 2.0 (the "License"); 9 | # you may not use this file except in compliance with the License. 10 | # You may obtain a copy of the License at 11 | # 12 | # http://www.apache.org/licenses/LICENSE-2.0 13 | # 14 | # Unless required by applicable law or agreed to in writing, software 15 | # distributed under the License is distributed on an "AS IS" BASIS, 16 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | # See the License for the specific language governing permissions and 18 | # limitations under the License. 19 | # 20 | 21 | define :ruby_packages, :action => :install do 22 | rv = params[:name].to_s 23 | raise "A Ruby version such as 1.8, 1.9 or 1.9.1 must be given" if rv.empty? 24 | 25 | packages = case node[:platform] 26 | when "ubuntu","debian" 27 | [ 28 | "ruby#{rv}", 29 | "ruby#{rv}-dev", 30 | "rdoc#{rv}", 31 | "ri#{rv}", 32 | "irb#{rv}", 33 | "libopenssl-ruby#{rv}", 34 | ("libshadow-ruby1.8" if rv == "1.8") 35 | ].compact 36 | 37 | when "gentoo" 38 | rv = rv.slice(0..2) 39 | target = "ruby" + rv.delete('.') 40 | 41 | [ 42 | # ruby-ssl is before ruby to ensure that ruby is initially 43 | # installed with the ssl USE flag enabled. 44 | "virtual/ruby-ssl:#{target}", 45 | "dev-lang/ruby:#{rv}", 46 | "virtual/ruby-rdoc:#{target}", 47 | ("dev-ruby/ruby-shadow" if rv == "1.8") 48 | ].compact 49 | 50 | when "centos","redhat","fedora" 51 | # yum requires full version numbers. :( 52 | %w{ 53 | ruby 54 | ruby-libs 55 | ruby-devel 56 | ruby-docs 57 | ruby-ri 58 | ruby-irb 59 | ruby-rdoc 60 | ruby-mode 61 | } 62 | 63 | when "arch" 64 | # 1.8 only available from AUR. :( 65 | %w{ 66 | ruby 67 | ruby-docs 68 | } 69 | end 70 | 71 | unless packages.nil? 72 | packages.each do |pkg| 73 | package pkg do 74 | action params[:action] 75 | end 76 | end 77 | end 78 | end 79 | -------------------------------------------------------------------------------- /cookbooks/ruby/definitions/ruby_symlinks.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: ruby 3 | # Definition:: ruby_symlinks 4 | # 5 | # Copyright 2010, FindsYou Limited 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | 20 | define :ruby_symlinks, :action => :create, :force => false, :path => '/usr/bin' do 21 | rv = params[:name].to_s 22 | rv = rv.slice(0..2).delete(".") if node[:platform] == "gentoo" 23 | 24 | %w( ruby irb erb ri testrb rdoc gem rake ).each do |name| 25 | path = File.join(params[:path], name) 26 | scope = self 27 | 28 | link path do 29 | to path + rv 30 | action params[:action] 31 | 32 | unless params[:force] 33 | not_if do 34 | if File.exists?(path) and not File.symlink?(path) 35 | scope.log "Not modifying non-symbolic-link #{path}" 36 | true 37 | end 38 | end 39 | end 40 | end 41 | end 42 | end 43 | -------------------------------------------------------------------------------- /cookbooks/ruby/metadata.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ruby", 3 | "description": "Installs Ruby and related packages", 4 | "long_description": "= DESCRIPTION:\n\nInstalls Ruby and related packages.\n\n= REQUIREMENTS:\n\n== Platform:\n\nTested on Ubuntu 10.04. Debian and Gentoo should also work fully. CentOS, Red Hat, Fedora and Arch are partially supported.\n\n= ATTRIBUTES:\n\n* +languages[:ruby][:default_version]+ - The Ruby version to install with the ruby recipe and create symlinks for with the symlinks recipe.\n\n= USAGE:\n\nPrevious versions of this cookbook gave you no control over which version of Ruby would be installed. We are now in the middle of an awkward period where you are equally likely to want 1.8 or 1.9. You may even want both. This is now catered for. To install specific versions side-by-side, use the 1.8, 1.9 or 1.9.1 recipes. The ruby recipe will install the version specified by +languages[:ruby][:default_version]+. If you want to do something other than install these packages, the +ruby_packages+ definition is provided as a wrapper around the package resource. Just specify the version number.\n\nFor example, to use the default recipe in a role named \"base\", use 'ruby' in the run list and set the +languages[:ruby][:default_version]+ attribute:\n\n {\n \"name\": \"base\",\n \"description\": \"Base role is applied to all systems\",\n \"json_class\": \"Chef::Role\",\n \"default_attributes\": {\n },\n \"override_attributes\": {\n \"languages\": {\n \"ruby\": {\n \"default_version\": \"1.8\"\n }\n }\n },\n \"chef_type\": \"role\",\n \"run_list\": [\n \"recipe[ruby]\"\n ]\n }\n\nMany scripts, including those provided by Rails, don't ask for a particular version of Ruby such as \"ruby1.8\" and simply look for \"ruby\" instead. Sometimes a symlink is provided and sometimes the executable is simply called \"ruby\" in the first place but generally speaking, it is difficult to predict this behaviour, especially when Ruby Gems is thrown into the mix. The symlinks recipe seeks to relieve you of this headache by creating symlinks for the common executables pointing to the Ruby version specified by +languages[:ruby][:default_version]+. This is also available as a definition called +ruby_symlinks+, which is a wrapper around the link resource. As before, just specify the version number. Non-symlinks will not be overwritten unless you set force to true. You can also set a path other than /usr/bin if necessary.\n\n*IMPORTANT!* Only Ubuntu, Debian and Gentoo support installing a specific Ruby version at all. yum-based distributions install 1.8 by default but require you to give the full package version otherwise. Maybe some magic could be added to Chef? Arch installs 1.9.2 by default but 1.8 is only available from AUR. Additionally, Ubuntu and Debian group 1.9.2 with 1.9.1 while Gentoo lumps all 1.9 releases together.\n\n= LICENSE and AUTHOR:\n\nAuthor:: Joshua Timberman (), James Le Cuirot ()\n\nCopyright:: 2009-2010, Opscode, Inc; 2010, FindsYou Limited\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n", 5 | "maintainer": "Opscode, Inc.", 6 | "maintainer_email": "cookbooks@opscode.com", 7 | "license": "Apache 2.0", 8 | "platforms": { 9 | "centos": [ 10 | 11 | ], 12 | "redhat": [ 13 | 14 | ], 15 | "fedora": [ 16 | 17 | ], 18 | "ubuntu": [ 19 | 20 | ], 21 | "debian": [ 22 | 23 | ], 24 | "arch": [ 25 | 26 | ], 27 | "gentoo": [ 28 | 29 | ] 30 | }, 31 | "dependencies": { 32 | }, 33 | "recommendations": { 34 | }, 35 | "suggestions": { 36 | }, 37 | "conflicting": { 38 | }, 39 | "providing": { 40 | }, 41 | "replacing": { 42 | }, 43 | "attributes": { 44 | "languages/ruby/default_version": { 45 | "display_name": "Default Ruby version", 46 | "recipes": [ 47 | "ruby", 48 | "symlinks" 49 | ], 50 | "choice": [ 51 | "1.8", 52 | "1.9", 53 | "1.9.1" 54 | ], 55 | "default": "1.8", 56 | "description": "The Ruby version to install with the ruby recipe and create symlinks for with the symlinks recipe. Unfortunately this setting only works fully on Ubuntu, Debian and Gentoo.", 57 | "calculated": false, 58 | "type": "string", 59 | "required": "optional" 60 | } 61 | }, 62 | "groupings": { 63 | }, 64 | "recipes": { 65 | "ruby": "Installs Ruby and related packages", 66 | "1.8": "Installs Ruby 1.8 and related packages", 67 | "1.9": "Installs Ruby 1.9 and related packages", 68 | "1.9.1": "Installs Ruby 1.9.1 and related packages", 69 | "symlinks": "Installs symlinks for the default Ruby version" 70 | }, 71 | "version": "0.9.0" 72 | } -------------------------------------------------------------------------------- /cookbooks/ruby/metadata.rb: -------------------------------------------------------------------------------- 1 | maintainer "Opscode, Inc." 2 | maintainer_email "cookbooks@opscode.com" 3 | license "Apache 2.0" 4 | description "Installs Ruby and related packages" 5 | long_description IO.read(File.join(File.dirname(__FILE__), 'README.rdoc')) 6 | version "0.9.0" 7 | 8 | recipe "ruby", "Installs Ruby and related packages" 9 | recipe "1.8", "Installs Ruby 1.8 and related packages" 10 | recipe "1.9", "Installs Ruby 1.9 and related packages" 11 | recipe "1.9.1", "Installs Ruby 1.9.1 and related packages" 12 | recipe "symlinks", "Installs symlinks for the default Ruby version" 13 | 14 | attribute "languages/ruby/default_version", 15 | :display_name => "Default Ruby version", 16 | :recipes => [ "ruby", "symlinks" ], 17 | :choice => [ "1.8", "1.9", "1.9.1" ], 18 | :default => "1.8", 19 | :description => "The Ruby version to install with the ruby recipe and create symlinks for with the symlinks recipe. Unfortunately this setting only works fully on Ubuntu, Debian and Gentoo." 20 | 21 | %w{ centos redhat fedora ubuntu debian arch gentoo }.each do |os| 22 | supports os 23 | end 24 | -------------------------------------------------------------------------------- /cookbooks/ruby/recipes/1.8.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: ruby 3 | # Recipe:: 1.8 4 | # 5 | # Copyright 2010, FindsYou Limited 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | 20 | ruby_packages "1.8" 21 | -------------------------------------------------------------------------------- /cookbooks/ruby/recipes/1.9.1.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: ruby 3 | # Recipe:: 1.9.1 4 | # 5 | # Copyright 2010, FindsYou Limited 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | 20 | ruby_packages "1.9.1" 21 | -------------------------------------------------------------------------------- /cookbooks/ruby/recipes/1.9.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: ruby 3 | # Recipe:: 1.9 4 | # 5 | # Copyright 2010, FindsYou Limited 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | 20 | ruby_packages "1.9" 21 | -------------------------------------------------------------------------------- /cookbooks/ruby/recipes/default.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: ruby 3 | # Recipe:: default 4 | # 5 | # Copyright 2010, FindsYou Limited 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | 20 | ruby_packages node[:languages][:ruby][:default_version] || "1.8" 21 | -------------------------------------------------------------------------------- /cookbooks/ruby/recipes/symlinks.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: ruby 3 | # Recipe:: symlinks 4 | # 5 | # Copyright 2010, FindsYou Limited 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | 20 | ruby_symlinks node[:languages][:ruby][:default_version] || "1.8" 21 | -------------------------------------------------------------------------------- /cookbooks/rubygems/metadata.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": { 3 | }, 4 | "attributes": { 5 | }, 6 | "maintainer": "Opscode, Inc.", 7 | "suggestions": { 8 | }, 9 | "dependencies": { 10 | }, 11 | "maintainer_email": "cookbooks@opscode.com", 12 | "conflicting": { 13 | }, 14 | "platforms": { 15 | }, 16 | "license": "Apache 2.0", 17 | "version": "0.2.1", 18 | "providing": { 19 | }, 20 | "recipes": { 21 | "rubygems": "Configures rubygems.org source" 22 | }, 23 | "replacing": { 24 | }, 25 | "name": "rubygems", 26 | "description": "Opscode rubygems config", 27 | "groupings": { 28 | }, 29 | "long_description": "Configures rubygems sources lists\n" 30 | } -------------------------------------------------------------------------------- /cookbooks/rubygems/metadata.rb: -------------------------------------------------------------------------------- 1 | maintainer "Opscode, Inc." 2 | maintainer_email "cookbooks@opscode.com" 3 | license "Apache 2.0" 4 | description "Opscode rubygems config" 5 | long_description <<-EOH 6 | Configures rubygems sources lists 7 | EOH 8 | version "0.2.1" 9 | recipe "rubygems", "Configures rubygems.org source" 10 | -------------------------------------------------------------------------------- /cookbooks/rubygems/recipes/default.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Author:: Adam Jacob 3 | # Cookbook Name:: rubygems 4 | # Recipe:: default 5 | # 6 | # Copyright 2009-2010, Opscode, Inc. 7 | # 8 | # Licensed under the Apache License, Version 2.0 (the "License"); 9 | # you may not use this file except in compliance with the License. 10 | # You may obtain a copy of the License at 11 | # 12 | # http://www.apache.org/licenses/LICENSE-2.0 13 | # 14 | # Unless required by applicable law or agreed to in writing, software 15 | # distributed under the License is distributed on an "AS IS" BASIS, 16 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | # See the License for the specific language governing permissions and 18 | # limitations under the License. 19 | # 20 | 21 | execute "gem sources --add http://rubygems.org" do 22 | not_if "gem sources --list | grep 'http://rubygems.org'" 23 | end 24 | -------------------------------------------------------------------------------- /cookbooks/sqlite/metadata.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": { 3 | }, 4 | "attributes": { 5 | }, 6 | "maintainer": "Opscode, Inc.", 7 | "suggestions": { 8 | }, 9 | "dependencies": { 10 | }, 11 | "maintainer_email": "cookbooks@opscode.com", 12 | "conflicting": { 13 | }, 14 | "platforms": { 15 | "debian": [ 16 | 17 | ], 18 | "ubuntu": [ 19 | 20 | ] 21 | }, 22 | "license": "Apache 2.0", 23 | "version": "0.7.1", 24 | "providing": { 25 | }, 26 | "recipes": { 27 | "sqlite": "Installs sqlite" 28 | }, 29 | "replacing": { 30 | }, 31 | "name": "sqlite", 32 | "description": "Installs sqlite", 33 | "groupings": { 34 | }, 35 | "long_description": "" 36 | } -------------------------------------------------------------------------------- /cookbooks/sqlite/metadata.rb: -------------------------------------------------------------------------------- 1 | maintainer "Opscode, Inc." 2 | maintainer_email "cookbooks@opscode.com" 3 | license "Apache 2.0" 4 | description "Installs sqlite" 5 | version "0.7.1" 6 | 7 | recipe "sqlite", "Installs sqlite" 8 | 9 | %w{ubuntu debian}.each do |os| 10 | supports os 11 | end 12 | -------------------------------------------------------------------------------- /cookbooks/sqlite/recipes/default.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: sqlite 3 | # Recipe:: default 4 | # 5 | # Copyright 2009, Opscode, Inc. 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | 20 | package "sqlite3" do 21 | action :upgrade 22 | end 23 | 24 | package "sqlite3-devel" do 25 | action :upgrade 26 | end 27 | 28 | package "sqlite3-doc" do 29 | action :upgrade 30 | end 31 | -------------------------------------------------------------------------------- /cookbooks/vagrant_main/recipes/default.rb: -------------------------------------------------------------------------------- 1 | require 'apt' 2 | require 'apache2' 3 | -------------------------------------------------------------------------------- /db/seeds.rb: -------------------------------------------------------------------------------- 1 | # This file should contain all the record creation needed to seed the database with its default values. 2 | # The data can then be loaded with the rake db:seed (or created alongside the db with db:setup). 3 | # 4 | # Examples: 5 | # 6 | # cities = City.create([{ :name => 'Chicago' }, { :name => 'Copenhagen' }]) 7 | # Mayor.create(:name => 'Daley', :city => cities.first) 8 | -------------------------------------------------------------------------------- /doc/README_FOR_APP: -------------------------------------------------------------------------------- 1 | Use this README file to introduce your application and point to useful places in the API for learning more. 2 | Run "rake doc:app" to generate API documentation for your models, controllers, helpers, and libraries. 3 | -------------------------------------------------------------------------------- /lib/tasks/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/drnic/railsapp-vagrant/0255b7173ff5d7f1fc4b4c59861e6c9e85b89b53/lib/tasks/.gitkeep -------------------------------------------------------------------------------- /public/404.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | The page you were looking for doesn't exist (404) 5 | 17 | 18 | 19 | 20 | 21 |
22 |

The page you were looking for doesn't exist.

23 |

You may have mistyped the address or the page may have moved.

24 |
25 | 26 | 27 | -------------------------------------------------------------------------------- /public/422.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | The change you wanted was rejected (422) 5 | 17 | 18 | 19 | 20 | 21 |
22 |

The change you wanted was rejected.

23 |

Maybe you tried to change something you didn't have access to.

24 |
25 | 26 | 27 | -------------------------------------------------------------------------------- /public/500.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | We're sorry, but something went wrong (500) 5 | 17 | 18 | 19 | 20 | 21 |
22 |

We're sorry, but something went wrong.

23 |

We've been notified about this issue and we'll take a look at it shortly.

24 |
25 | 26 | 27 | -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/drnic/railsapp-vagrant/0255b7173ff5d7f1fc4b4c59861e6c9e85b89b53/public/favicon.ico -------------------------------------------------------------------------------- /public/images/rails.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/drnic/railsapp-vagrant/0255b7173ff5d7f1fc4b4c59861e6c9e85b89b53/public/images/rails.png -------------------------------------------------------------------------------- /public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Ruby on Rails: Welcome aboard 5 | 172 | 185 | 186 | 187 |
188 | 201 | 202 |
203 | 207 | 208 | 212 | 213 |
214 |

Getting started

215 |

Here’s how to get rolling:

216 | 217 |
    218 |
  1. 219 |

    Use rails generate to create your models and controllers

    220 |

    To see all available options, run it without parameters.

    221 |
  2. 222 | 223 |
  3. 224 |

    Set up a default route and remove or rename this file

    225 |

    Routes are set up in config/routes.rb.

    226 |
  4. 227 | 228 |
  5. 229 |

    Create your database

    230 |

    Run rake db:migrate to create your database. If you're not using SQLite (the default), edit config/database.yml with your username and password.

    231 |
  6. 232 |
233 |
234 |
235 | 236 | 237 |
238 | 239 | 240 | -------------------------------------------------------------------------------- /public/javascripts/application.js: -------------------------------------------------------------------------------- 1 | // Place your application-specific JavaScript functions and classes here 2 | // This file is automatically included by javascript_include_tag :defaults 3 | -------------------------------------------------------------------------------- /public/javascripts/rails.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | // Technique from Juriy Zaytsev 3 | // http://thinkweb2.com/projects/prototype/detecting-event-support-without-browser-sniffing/ 4 | function isEventSupported(eventName) { 5 | var el = document.createElement('div'); 6 | eventName = 'on' + eventName; 7 | var isSupported = (eventName in el); 8 | if (!isSupported) { 9 | el.setAttribute(eventName, 'return;'); 10 | isSupported = typeof el[eventName] == 'function'; 11 | } 12 | el = null; 13 | return isSupported; 14 | } 15 | 16 | function isForm(element) { 17 | return Object.isElement(element) && element.nodeName.toUpperCase() == 'FORM' 18 | } 19 | 20 | function isInput(element) { 21 | if (Object.isElement(element)) { 22 | var name = element.nodeName.toUpperCase() 23 | return name == 'INPUT' || name == 'SELECT' || name == 'TEXTAREA' 24 | } 25 | else return false 26 | } 27 | 28 | var submitBubbles = isEventSupported('submit'), 29 | changeBubbles = isEventSupported('change') 30 | 31 | if (!submitBubbles || !changeBubbles) { 32 | // augment the Event.Handler class to observe custom events when needed 33 | Event.Handler.prototype.initialize = Event.Handler.prototype.initialize.wrap( 34 | function(init, element, eventName, selector, callback) { 35 | init(element, eventName, selector, callback) 36 | // is the handler being attached to an element that doesn't support this event? 37 | if ( (!submitBubbles && this.eventName == 'submit' && !isForm(this.element)) || 38 | (!changeBubbles && this.eventName == 'change' && !isInput(this.element)) ) { 39 | // "submit" => "emulated:submit" 40 | this.eventName = 'emulated:' + this.eventName 41 | } 42 | } 43 | ) 44 | } 45 | 46 | if (!submitBubbles) { 47 | // discover forms on the page by observing focus events which always bubble 48 | document.on('focusin', 'form', function(focusEvent, form) { 49 | // special handler for the real "submit" event (one-time operation) 50 | if (!form.retrieve('emulated:submit')) { 51 | form.on('submit', function(submitEvent) { 52 | var emulated = form.fire('emulated:submit', submitEvent, true) 53 | // if custom event received preventDefault, cancel the real one too 54 | if (emulated.returnValue === false) submitEvent.preventDefault() 55 | }) 56 | form.store('emulated:submit', true) 57 | } 58 | }) 59 | } 60 | 61 | if (!changeBubbles) { 62 | // discover form inputs on the page 63 | document.on('focusin', 'input, select, texarea', function(focusEvent, input) { 64 | // special handler for real "change" events 65 | if (!input.retrieve('emulated:change')) { 66 | input.on('change', function(changeEvent) { 67 | input.fire('emulated:change', changeEvent, true) 68 | }) 69 | input.store('emulated:change', true) 70 | } 71 | }) 72 | } 73 | 74 | function handleRemote(element) { 75 | var method, url, params; 76 | 77 | var event = element.fire("ajax:before"); 78 | if (event.stopped) return false; 79 | 80 | if (element.tagName.toLowerCase() === 'form') { 81 | method = element.readAttribute('method') || 'post'; 82 | url = element.readAttribute('action'); 83 | params = element.serialize(); 84 | } else { 85 | method = element.readAttribute('data-method') || 'get'; 86 | url = element.readAttribute('href'); 87 | params = {}; 88 | } 89 | 90 | new Ajax.Request(url, { 91 | method: method, 92 | parameters: params, 93 | evalScripts: true, 94 | 95 | onComplete: function(request) { element.fire("ajax:complete", request); }, 96 | onSuccess: function(request) { element.fire("ajax:success", request); }, 97 | onFailure: function(request) { element.fire("ajax:failure", request); } 98 | }); 99 | 100 | element.fire("ajax:after"); 101 | } 102 | 103 | function handleMethod(element) { 104 | var method = element.readAttribute('data-method'), 105 | url = element.readAttribute('href'), 106 | csrf_param = $$('meta[name=csrf-param]')[0], 107 | csrf_token = $$('meta[name=csrf-token]')[0]; 108 | 109 | var form = new Element('form', { method: "POST", action: url, style: "display: none;" }); 110 | element.parentNode.insert(form); 111 | 112 | if (method !== 'post') { 113 | var field = new Element('input', { type: 'hidden', name: '_method', value: method }); 114 | form.insert(field); 115 | } 116 | 117 | if (csrf_param) { 118 | var param = csrf_param.readAttribute('content'), 119 | token = csrf_token.readAttribute('content'), 120 | field = new Element('input', { type: 'hidden', name: param, value: token }); 121 | form.insert(field); 122 | } 123 | 124 | form.submit(); 125 | } 126 | 127 | 128 | document.on("click", "*[data-confirm]", function(event, element) { 129 | var message = element.readAttribute('data-confirm'); 130 | if (!confirm(message)) event.stop(); 131 | }); 132 | 133 | document.on("click", "a[data-remote]", function(event, element) { 134 | if (event.stopped) return; 135 | handleRemote(element); 136 | event.stop(); 137 | }); 138 | 139 | document.on("click", "a[data-method]", function(event, element) { 140 | if (event.stopped) return; 141 | handleMethod(element); 142 | event.stop(); 143 | }); 144 | 145 | document.on("submit", function(event) { 146 | var element = event.findElement(), 147 | message = element.readAttribute('data-confirm'); 148 | if (message && !confirm(message)) { 149 | event.stop(); 150 | return false; 151 | } 152 | 153 | var inputs = element.select("input[type=submit][data-disable-with]"); 154 | inputs.each(function(input) { 155 | input.disabled = true; 156 | input.writeAttribute('data-original-value', input.value); 157 | input.value = input.readAttribute('data-disable-with'); 158 | }); 159 | 160 | var element = event.findElement("form[data-remote]"); 161 | if (element) { 162 | handleRemote(element); 163 | event.stop(); 164 | } 165 | }); 166 | 167 | document.on("ajax:after", "form", function(event, element) { 168 | var inputs = element.select("input[type=submit][disabled=true][data-disable-with]"); 169 | inputs.each(function(input) { 170 | input.value = input.readAttribute('data-original-value'); 171 | input.removeAttribute('data-original-value'); 172 | input.disabled = false; 173 | }); 174 | }); 175 | })(); 176 | -------------------------------------------------------------------------------- /public/robots.txt: -------------------------------------------------------------------------------- 1 | # See http://www.robotstxt.org/wc/norobots.html for documentation on how to use the robots.txt file 2 | # 3 | # To ban all spiders from the entire site uncomment the next two lines: 4 | # User-Agent: * 5 | # Disallow: / 6 | -------------------------------------------------------------------------------- /public/stylesheets/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/drnic/railsapp-vagrant/0255b7173ff5d7f1fc4b4c59861e6c9e85b89b53/public/stylesheets/.gitkeep -------------------------------------------------------------------------------- /script/rails: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application. 3 | 4 | APP_PATH = File.expand_path('../../config/application', __FILE__) 5 | require File.expand_path('../../config/boot', __FILE__) 6 | require 'rails/commands' 7 | -------------------------------------------------------------------------------- /test/performance/browsing_test.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | require 'rails/performance_test_help' 3 | 4 | # Profiling results for each test method are written to tmp/performance. 5 | class BrowsingTest < ActionDispatch::PerformanceTest 6 | def test_homepage 7 | get '/' 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /test/test_helper.rb: -------------------------------------------------------------------------------- 1 | ENV["RAILS_ENV"] = "test" 2 | require File.expand_path('../../config/environment', __FILE__) 3 | require 'rails/test_help' 4 | 5 | class ActiveSupport::TestCase 6 | # Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order. 7 | # 8 | # Note: You'll currently still have to declare fixtures explicitly in integration tests 9 | # -- they do not yet inherit this setting 10 | fixtures :all 11 | 12 | # Add more helper methods to be used by all tests here... 13 | end 14 | -------------------------------------------------------------------------------- /vendor/plugins/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/drnic/railsapp-vagrant/0255b7173ff5d7f1fc4b4c59861e6c9e85b89b53/vendor/plugins/.gitkeep --------------------------------------------------------------------------------