├── .gitignore ├── cookbooks ├── apt │ ├── .gitignore │ ├── Gemfile │ ├── templates │ │ └── default │ │ │ └── 01proxy.erb │ ├── attributes │ │ └── default.rb │ ├── metadata.rb │ ├── resources │ │ ├── preference.rb │ │ └── repository.rb │ ├── recipes │ │ ├── cacher-ng.rb │ │ ├── cacher-client.rb │ │ └── default.rb │ ├── CONTRIBUTING │ ├── files │ │ └── default │ │ │ └── apt-proxy-v2.conf │ ├── providers │ │ ├── preference.rb │ │ └── repository.rb │ ├── CHANGELOG.md │ ├── metadata.json │ ├── README.md │ └── LICENSE ├── java │ ├── Gemfile │ ├── .gitignore │ ├── templates │ │ └── default │ │ │ └── oracle.jinfo.erb │ ├── metadata.rb │ ├── files │ │ └── default │ │ │ └── tests │ │ │ └── minitest │ │ │ ├── oracle_test.rb │ │ │ └── openjdk_test.rb │ ├── recipes │ │ ├── windows.rb │ │ ├── default.rb │ │ ├── oracle_i386.rb │ │ ├── oracle.rb │ │ └── openjdk.rb │ ├── resources │ │ └── ark.rb │ ├── CHANGELOG.md │ ├── attributes │ │ └── default.rb │ ├── README.md │ ├── metadata.json │ └── providers │ │ └── ark.rb ├── postgresql │ ├── Gemfile │ ├── .gitignore │ ├── recipes │ │ ├── ppa_pitti_postgresql.rb │ │ ├── default.rb │ │ ├── contrib.rb │ │ ├── client.rb │ │ ├── server_debian.rb │ │ ├── server_redhat.rb │ │ ├── yum_pgdg_postgresql.rb │ │ ├── server.rb │ │ └── ruby.rb │ ├── templates │ │ └── default │ │ │ ├── pg_hba.conf.erb │ │ │ └── postgresql.conf.erb │ ├── files │ │ └── default │ │ │ └── tests │ │ │ └── minitest │ │ │ ├── default_test.rb │ │ │ ├── ruby_test.rb │ │ │ ├── support │ │ │ └── helpers.rb │ │ │ ├── ppa_pitti_postgresql_test.rb │ │ │ └── server_test.rb │ ├── metadata.rb │ ├── CHANGELOG.md │ ├── README.md │ └── metadata.json ├── git │ ├── templates │ │ └── default │ │ │ ├── sv-git-daemon-log-run.erb │ │ │ └── sv-git-daemon-run.erb │ ├── metadata.rb │ ├── recipes │ │ ├── default.rb │ │ └── server.rb │ └── README.rdoc ├── memcached │ ├── templates │ │ └── default │ │ │ ├── sv-memcached-log-run.erb │ │ │ ├── memcached.default.erb │ │ │ ├── sv-memcached-run.erb │ │ │ └── memcached.conf.erb │ ├── attributes │ │ └── default.rb │ ├── definitions │ │ └── memcached_instance.rb │ ├── metadata.rb │ ├── recipes │ │ └── default.rb │ └── README.rdoc ├── vagrant_main │ ├── recipes │ │ ├── packages.rb │ │ └── default.rb │ ├── files │ │ └── default │ │ │ └── rails_mysql_user_grants.sql │ └── attributes │ │ └── default.rb ├── mysql │ ├── templates │ │ └── default │ │ │ ├── port_mysql.erb │ │ │ ├── debian.cnf.erb │ │ │ ├── mysql-server.seed.erb │ │ │ ├── grants.sql.erb │ │ │ └── my.cnf.erb │ ├── libraries │ │ ├── database.rb │ │ └── helpers.rb │ ├── recipes │ │ ├── default.rb │ │ ├── server_ec2.rb │ │ ├── client.rb │ │ └── server.rb │ ├── resources │ │ └── database.rb │ ├── providers │ │ └── database.rb │ ├── attributes │ │ └── server.rb │ ├── metadata.rb │ └── README.md ├── sqlite │ ├── metadata.rb │ └── recipes │ │ └── default.rb ├── build-essential │ ├── metadata.rb │ ├── README.md │ └── recipes │ │ └── default.rb └── openssl │ ├── metadata.rb │ ├── recipes │ └── default.rb │ ├── libraries │ └── secure_password.rb │ └── README.md ├── .gitmodules ├── README.md └── Vagrantfile /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .vagrant 3 | *.rbc 4 | -------------------------------------------------------------------------------- /cookbooks/apt/.gitignore: -------------------------------------------------------------------------------- 1 | .bundle 2 | .cache 3 | .kitchen 4 | bin 5 | -------------------------------------------------------------------------------- /cookbooks/apt/Gemfile: -------------------------------------------------------------------------------- 1 | source :rubygems 2 | 3 | gem 'test-kitchen', '< 1.0' 4 | -------------------------------------------------------------------------------- /cookbooks/java/Gemfile: -------------------------------------------------------------------------------- 1 | source :rubygems 2 | 3 | gem 'test-kitchen', '< 1.0' 4 | -------------------------------------------------------------------------------- /cookbooks/postgresql/Gemfile: -------------------------------------------------------------------------------- 1 | source :rubygems 2 | 3 | gem 'test-kitchen', '<= 1.0' 4 | -------------------------------------------------------------------------------- /cookbooks/java/.gitignore: -------------------------------------------------------------------------------- 1 | .bundle 2 | .cache 3 | .kitchen 4 | bin 5 | #*# 6 | *~ 7 | .#*# 8 | -------------------------------------------------------------------------------- /cookbooks/postgresql/.gitignore: -------------------------------------------------------------------------------- 1 | .bundle 2 | .cache 3 | .kitchen 4 | bin 5 | Gemfile.lock 6 | -------------------------------------------------------------------------------- /cookbooks/git/templates/default/sv-git-daemon-log-run.erb: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | exec svlogd -tt ./main 3 | -------------------------------------------------------------------------------- /cookbooks/memcached/templates/default/sv-memcached-log-run.erb: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | exec svlogd -tt ./main 3 | -------------------------------------------------------------------------------- /cookbooks/vagrant_main/recipes/packages.rb: -------------------------------------------------------------------------------- 1 | # pg gem dependency 2 | package "libpq-dev" 3 | # rbx 4 | package "libyaml-dev" -------------------------------------------------------------------------------- /cookbooks/memcached/templates/default/memcached.default.erb: -------------------------------------------------------------------------------- 1 | # Set this to yes to enable memcached. 2 | ENABLE_MEMCACHED=yes 3 | -------------------------------------------------------------------------------- /cookbooks/apt/templates/default/01proxy.erb: -------------------------------------------------------------------------------- 1 | Acquire::http::Proxy "http://<%= @proxy %>:<%= @port %>"; 2 | Acquire::https::Proxy "DIRECT"; 3 | -------------------------------------------------------------------------------- /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/apt/attributes/default.rb: -------------------------------------------------------------------------------- 1 | default['apt']['cacher-client']['restrict_environment'] = false 2 | default['apt']['cacher_port'] = 3142 3 | default['apt']['key_proxy'] = '' 4 | -------------------------------------------------------------------------------- /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/memcached/templates/default/sv-memcached-run.erb: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | exec 2>&1 3 | exec chpst -u <%= @options[:user] %> /usr/bin/memcached -v -m <%= @options[:memory] %> -p <%= @options[:port] %> 4 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "rails"] 2 | path = rails 3 | url = git://github.com/rails/rails.git 4 | [submodule "cookbooks/rvm"] 5 | path = cookbooks/rvm 6 | url = git://github.com/fnichol/chef-rvm.git 7 | -------------------------------------------------------------------------------- /cookbooks/memcached/attributes/default.rb: -------------------------------------------------------------------------------- 1 | default[:memcached][:memory] = 64 2 | default[:memcached][:port] = 11211 3 | default[:memcached][:user] = "nobody" 4 | default[:memcached][:listen] = "0.0.0.0" 5 | -------------------------------------------------------------------------------- /cookbooks/java/templates/default/oracle.jinfo.erb: -------------------------------------------------------------------------------- 1 | name=<%= @name %> 2 | priority=<%= @priority %> 3 | section=main 4 | 5 | <% @bin_cmds.each do |cmd| -%>jdk <%= cmd %> <%= @app_dir %>/bin/<%= cmd %> 6 | <% end -%> 7 | -------------------------------------------------------------------------------- /cookbooks/vagrant_main/files/default/rails_mysql_user_grants.sql: -------------------------------------------------------------------------------- 1 | CREATE USER 'rails'@'localhost'; 2 | GRANT ALL PRIVILEGES ON activerecord_unittest.* to 'rails'@'localhost'; 3 | GRANT ALL PRIVILEGES ON activerecord_unittest2.* to 'rails'@'localhost'; -------------------------------------------------------------------------------- /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/postgresql/recipes/ppa_pitti_postgresql.rb: -------------------------------------------------------------------------------- 1 | include_recipe 'apt' 2 | 3 | apt_repository 'pitti-postgresql-ppa' do 4 | uri 'http://ppa.launchpad.net/pitti/postgresql/ubuntu' 5 | distribution node['lsb']['codename'] 6 | components %w(main) 7 | keyserver 'keyserver.ubuntu.com' 8 | key '8683D8A2' 9 | action :add 10 | end 11 | -------------------------------------------------------------------------------- /cookbooks/build-essential/metadata.rb: -------------------------------------------------------------------------------- 1 | maintainer "Opscode, Inc." 2 | maintainer_email "cookbooks@opscode.com" 3 | license "Apache 2.0" 4 | description "Installs C compiler / build tools" 5 | version "1.0.0" 6 | recipe "build-essential", "Installs C compiler and build tools on Linux" 7 | 8 | %w{ fedora redhat centos ubuntu debian }.each do |os| 9 | supports os 10 | end 11 | -------------------------------------------------------------------------------- /cookbooks/openssl/metadata.rb: -------------------------------------------------------------------------------- 1 | maintainer "Opscode, Inc." 2 | maintainer_email "cookbooks@opscode.com" 3 | license "Apache 2.0" 4 | description "Provides a library with a method for generating secure random passwords." 5 | long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) 6 | version "1.0.0" 7 | 8 | recipe "openssl", "Empty, this cookbook provides a library, see README.md" 9 | -------------------------------------------------------------------------------- /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 = <%= node['mysql']['socket'] %> 6 | 7 | [mysql_upgrade] 8 | host = localhost 9 | user = debian-sys-maint 10 | password = <%= node['mysql']['server_debian_password'] %> 11 | socket = <%= node['mysql']['socket'] %> 12 | basedir = /usr 13 | -------------------------------------------------------------------------------- /cookbooks/mysql/libraries/database.rb: -------------------------------------------------------------------------------- 1 | begin 2 | require 'mysql' 3 | rescue LoadError 4 | Chef::Log.info("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 | def close 14 | @db.close rescue nil 15 | @db = nil 16 | end 17 | end 18 | end 19 | end 20 | -------------------------------------------------------------------------------- /cookbooks/postgresql/templates/default/pg_hba.conf.erb: -------------------------------------------------------------------------------- 1 | # PostgreSQL Client Authentication Configuration File 2 | # This file was automatically generated and dropped off by Chef! 3 | # Please refer to the PostgreSQL documentation for details on 4 | # configuration settings. 5 | 6 | # TYPE DATABASE USER CIDR-ADDRESS METHOD 7 | <% node['postgresql']['pg_hba'].each do |auth| -%> 8 | <%= auth[:type] %> <%= auth[:db] %> <%= auth[:user] %> <%= auth[:addr] %> <%= auth[:method] %> 9 | <% end -%> 10 | 11 | -------------------------------------------------------------------------------- /cookbooks/postgresql/templates/default/postgresql.conf.erb: -------------------------------------------------------------------------------- 1 | # PostgreSQL configuration file 2 | # This file was automatically generated and dropped off by chef! 3 | # Please refer to the PostgreSQL documentation for details on 4 | # configuration settings. 5 | 6 | <% node['postgresql']['config'].sort.each do |key, value| %> 7 | <% next if value.nil? -%> 8 | <%= key %> = <%= 9 | case value 10 | when String 11 | "'#{value}'" 12 | when TrueClass 13 | 'on' 14 | when FalseClass 15 | 'off' 16 | else 17 | value 18 | end 19 | %> 20 | <% end %> 21 | -------------------------------------------------------------------------------- /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/vagrant_main/attributes/default.rb: -------------------------------------------------------------------------------- 1 | set['rvm']['rubies'] = ['ruby-2.0.0-p0', 'ruby-1.9.3-p392', 'jruby-1.7.3', 'rbx'] 2 | set['rvm']['default_ruby'] = 'ruby-2.0.0-p0' 3 | set['rvm']['upgrade'] = "stable" 4 | set['rvm']['global_gems'] = [ 5 | { 'name' => 'bundler' } 6 | ] 7 | 8 | set['mysql']['server_root_password'] = "" 9 | 10 | # https://github.com/opscode-cookbooks/postgresql#chef-solo-note 11 | # set to md5 of empty string 12 | set['postgresql']['password']['postgres'] = 'd41d8cd98f00b204e9800998ecf8427e' 13 | 14 | set['postgresql']['pg_hba'] = [ 15 | {:type => 'local', :db => 'all', :user => 'all', :addr => '', :method => 'trust'} 16 | ] -------------------------------------------------------------------------------- /cookbooks/apt/metadata.rb: -------------------------------------------------------------------------------- 1 | name "apt" 2 | maintainer "Opscode, Inc." 3 | maintainer_email "cookbooks@opscode.com" 4 | license "Apache 2.0" 5 | description "Configures apt and apt services and LWRPs for managing apt repositories and preferences" 6 | long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) 7 | version "1.9.0" 8 | recipe "apt", "Runs apt-get update during compile phase and sets up preseed directories" 9 | recipe "apt::cacher-ng", "Set up an apt-cacher-ng caching proxy" 10 | recipe "apt::cacher-client", "Client for the apt::cacher-ng caching proxy" 11 | 12 | %w{ ubuntu debian }.each do |os| 13 | supports os 14 | end 15 | -------------------------------------------------------------------------------- /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/java/metadata.rb: -------------------------------------------------------------------------------- 1 | name "java" 2 | maintainer "Opscode, Inc." 3 | maintainer_email "cookbooks@opscode.com" 4 | license "Apache 2.0" 5 | description "Installs Java runtime." 6 | long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) 7 | version "1.9.6" 8 | 9 | recipe "java", "Installs Java runtime" 10 | recipe "java::openjdk", "Installs the OpenJDK flavor of Java" 11 | recipe "java::oracle", "Installs the Oracle flavor of Java" 12 | recipe "java::oracle_i386", "Installs the 32-bit jvm without setting it as the default" 13 | 14 | 15 | %w{ debian ubuntu centos redhat scientific fedora amazon arch oracle freebsd windows }.each do |os| 16 | supports os 17 | end 18 | 19 | depends "windows" 20 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Introduction 2 | ------------ 3 | Vagrant box configured with necessary chef cookbooks to run rails test suites with ruby 2.0.0, ruby 1.9.3, jruby, and rbx. 4 | 5 | Usage 6 | ----- 7 | 8 | * Install VirtualBox and Vagrant http://vagrantup.com/docs/getting-started/index.html 9 | * Add a base box. Run `vagrant box add precise64 http://files.vagrantup.com/precise64.box` 10 | * git clone git://github.com/zhengjia/vagrant-rails-test.git 11 | * cd vagrant-rails-test 12 | * vagrant up 13 | * vagrant ssh 14 | * cd /vagrant/rails 15 | * bundle install 16 | * bundle exec rake test 17 | 18 | Issues: 19 | * rbenv has a compatibility issue with rbx, so rbenv isn't used: https://github.com/sstephenson/rbenv/issues/178 20 | * RBX is 1.8 by default. Use `RBXOPT=-X19` environment variable for 1.9. -------------------------------------------------------------------------------- /cookbooks/java/files/default/tests/minitest/oracle_test.rb: -------------------------------------------------------------------------------- 1 | require 'minitest/spec' 2 | require 'open3' 3 | 4 | describe_recipe 'java::oracle' do 5 | 6 | 7 | include MiniTest::Chef::Assertions 8 | include MiniTest::Chef::Context 9 | include MiniTest::Chef::Resources 10 | 11 | it "installs the correct version of the jdk" do 12 | stdin,stdout,stderr = Open3.popen3( "java -version" ) 13 | version_line = stderr.readline 14 | jdk_version = version_line.scan(/\.([678])\./)[0][0] 15 | assert_equal node['java']['jdk_version'], jdk_version 16 | end 17 | 18 | it "properly sets JAVA_HOME environment variable" do 19 | stdin,stdout,stderr = Open3.popen3( "echo $JAVA_HOME" ) 20 | java_home = stdout.readline.rstrip 21 | assert_equal node['java']['java_home'], java_home 22 | end 23 | 24 | end 25 | -------------------------------------------------------------------------------- /cookbooks/java/files/default/tests/minitest/openjdk_test.rb: -------------------------------------------------------------------------------- 1 | require 'minitest/spec' 2 | require 'open3' 3 | 4 | describe_recipe 'java::openjdk' do 5 | 6 | 7 | include MiniTest::Chef::Assertions 8 | include MiniTest::Chef::Context 9 | include MiniTest::Chef::Resources 10 | 11 | it "installs the correct version of the jdk" do 12 | stdin,stdout,stderr = Open3.popen3( "java -version" ) 13 | version_line = stderr.readline 14 | jdk_version = version_line.scan(/\.([678])\./)[0][0] 15 | assert_equal node['java']['jdk_version'], jdk_version 16 | end 17 | 18 | it "properly sets JAVA_HOME environment variable" do 19 | stdin,stdout,stderr = Open3.popen3( "echo $JAVA_HOME" ) 20 | java_home = stdout.readline.rstrip 21 | assert_equal node['java']['java_home'], java_home 22 | end 23 | 24 | end 25 | 26 | -------------------------------------------------------------------------------- /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/postgresql/recipes/contrib.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: postgresql 3 | # Recipe:: contrib 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | 18 | include_recipe "postgresql::server" 19 | 20 | node['postgresql']['contrib']['packages'].each do |pg_pack| 21 | 22 | package pg_pack 23 | 24 | end 25 | -------------------------------------------------------------------------------- /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-doc" do 25 | action :upgrade 26 | end 27 | -------------------------------------------------------------------------------- /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/build-essential/README.md: -------------------------------------------------------------------------------- 1 | DESCRIPTION 2 | =========== 3 | 4 | Installs packages required for compiling C software from source. 5 | 6 | LICENSE AND AUTHOR 7 | ================== 8 | 9 | Author:: Joshua Timberman () 10 | Author:: Seth Chisamore () 11 | 12 | Copyright 2009-2011, Opscode, Inc. 13 | 14 | Licensed under the Apache License, Version 2.0 (the "License"); 15 | you may not use this file except in compliance with the License. 16 | You may obtain a copy of the License at 17 | 18 | http://www.apache.org/licenses/LICENSE-2.0 19 | 20 | Unless required by applicable law or agreed to in writing, software 21 | distributed under the License is distributed on an "AS IS" BASIS, 22 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 23 | See the License for the specific language governing permissions and 24 | limitations under the License. 25 | -------------------------------------------------------------------------------- /cookbooks/postgresql/files/default/tests/minitest/default_test.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2012, Opscode, Inc. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | 17 | require File.expand_path('../support/helpers', __FILE__) 18 | 19 | describe 'postgresql::default' do 20 | include Helpers::Postgresql 21 | 22 | it 'installs the postgresql client packages' do 23 | node['postgresql']['client']['packages'].each do |pkg| 24 | package(pkg).must_be_installed 25 | end 26 | end 27 | end 28 | -------------------------------------------------------------------------------- /cookbooks/apt/resources/preference.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: apt 3 | # Resource:: preference 4 | # 5 | # Copyright 2010-2011, 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 | actions :add, :remove 21 | 22 | def initialize(*args) 23 | super 24 | @action = :add 25 | end 26 | 27 | attribute :package_name, :kind_of => String, :name_attribute => true 28 | attribute :glob, :kind_of => String 29 | attribute :pin, :kind_of => String 30 | attribute :pin_priority, :kind_of => String 31 | -------------------------------------------------------------------------------- /cookbooks/postgresql/files/default/tests/minitest/ruby_test.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: postgresql_test 3 | # Recipe:: default 4 | # 5 | # Copyright 2012, 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 | require File.expand_path('../support/helpers', __FILE__) 21 | 22 | describe 'postgresql::ruby' do 23 | include Helpers::Postgresql 24 | 25 | it 'installs the pg gem in Chefs ruby environment' do 26 | assert Gem::Specification.all_names.grep("pg-.*") 27 | end 28 | end 29 | -------------------------------------------------------------------------------- /cookbooks/postgresql/files/default/tests/minitest/support/helpers.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: postgresql_test 3 | # Recipe:: default 4 | # 5 | # Copyright 2012, 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 | module Helpers 21 | module Postgresql 22 | require 'chef/mixin/shell_out' 23 | include Chef::Mixin::ShellOut 24 | include MiniTest::Chef::Assertions 25 | include MiniTest::Chef::Context 26 | include MiniTest::Chef::Resources 27 | 28 | end 29 | end 30 | -------------------------------------------------------------------------------- /cookbooks/java/recipes/windows.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Author:: Kendrick Martin () 3 | # Cookbook Name:: java 4 | # Recipe:: windows 5 | # 6 | # Copyright 2008-2012 Webtrends, 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 | Chef::Log.warn("No download url set for java installer.") unless node['java']['windows']['url'] 22 | 23 | windows_package node['java']['windows']['package_name'] do 24 | source node['java']['windows']['url'] 25 | action :install 26 | installer_type :custom 27 | options "/s" 28 | end -------------------------------------------------------------------------------- /cookbooks/mysql/templates/default/grants.sql.erb: -------------------------------------------------------------------------------- 1 | # Generated by Chef for <%= node['hostname'] %>. 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 | <% if node['mysql']['allow_remote_root'] -%> 13 | GRANT ALL ON *.* TO 'root'@'%' IDENTIFIED BY '<%= node['mysql']['server_root_password'] %>' WITH GRANT OPTION; 14 | <% end -%> 15 | SET PASSWORD FOR 'root'@'localhost' = PASSWORD('<%= node['mysql']['server_root_password'] %>'); 16 | -------------------------------------------------------------------------------- /cookbooks/mysql/resources/database.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: mysql 3 | # Resource:: database 4 | # 5 | # Copyright:: 2008-2011, 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 | actions :flush_tables_with_read_lock, :unflush_tables, :create_db, :query 21 | 22 | attribute :host, :kind_of => String 23 | attribute :username, :kind_of => String 24 | attribute :password, :kind_of => String 25 | attribute :database, :kind_of => String 26 | attribute :sql, :kind_of => String 27 | attribute :exists, :default => false 28 | -------------------------------------------------------------------------------- /cookbooks/postgresql/metadata.rb: -------------------------------------------------------------------------------- 1 | name "postgresql" 2 | maintainer "Opscode, Inc." 3 | maintainer_email "cookbooks@opscode.com" 4 | license "Apache 2.0" 5 | description "Installs and configures postgresql for clients or servers" 6 | long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) 7 | version "2.2.2" 8 | recipe "postgresql", "Includes postgresql::client" 9 | recipe "postgresql::ruby", "Installs pg gem for Ruby bindings" 10 | recipe "postgresql::client", "Installs postgresql client package(s)" 11 | recipe "postgresql::server", "Installs postgresql server packages, templates" 12 | recipe "postgresql::server_redhat", "Installs postgresql server packages, redhat family style" 13 | recipe "postgresql::server_debian", "Installs postgresql server packages, debian family style" 14 | 15 | %w{ubuntu debian fedora suse amazon}.each do |os| 16 | supports os 17 | end 18 | 19 | %w{redhat centos scientific oracle}.each do |el| 20 | supports el, ">= 6.0" 21 | end 22 | 23 | depends "openssl" 24 | -------------------------------------------------------------------------------- /cookbooks/mysql/libraries/helpers.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Author:: Seth Chisamore () 3 | # Copyright:: Copyright (c) 2011 Opscode, Inc. 4 | # License:: Apache License, Version 2.0 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | module Opscode 20 | module Mysql 21 | module Helpers 22 | 23 | def debian_before_squeeze? 24 | platform?("debian") && (node.platform_version.to_f < 6.0) 25 | end 26 | 27 | def ubuntu_before_lucid? 28 | platform?("ubuntu") && (node.platform_version.to_f < 10.0) 29 | end 30 | 31 | end 32 | end 33 | end -------------------------------------------------------------------------------- /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/memcached/definitions/memcached_instance.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: memcached 3 | # Definition:: memcached_instance 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 | define :memcached_instance do 21 | include_recipe "memcached" 22 | 23 | runit_service "memcached-#{params[:name]}" do 24 | template_name "memcached" 25 | cookbook "memcached" 26 | options({ 27 | :memory => node[:memcached][:memory], 28 | :port => node[:memcached][:port], 29 | :user => node[:memcached][:user]}.merge(params) 30 | ) 31 | end 32 | end 33 | -------------------------------------------------------------------------------- /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/postgresql/recipes/client.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: postgresql 3 | # Recipe:: client 4 | # 5 | # Author:: Joshua Timberman () 6 | # Author:: Lamont Granquist () 7 | # Copyright 2009-2011 Opscode, Inc. 8 | # 9 | # Licensed under the Apache License, Version 2.0 (the "License"); 10 | # you may not use this file except in compliance with the License. 11 | # You may obtain a copy of the License at 12 | # 13 | # http://www.apache.org/licenses/LICENSE-2.0 14 | # 15 | # Unless required by applicable law or agreed to in writing, software 16 | # distributed under the License is distributed on an "AS IS" BASIS, 17 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | # See the License for the specific language governing permissions and 19 | # limitations under the License. 20 | # 21 | 22 | if(node['postgresql']['enable_pitti_ppa']) 23 | include_recipe 'postgresql::ppa_pitti_postgresql' 24 | end 25 | 26 | if(node['postgresql']['enable_pgdg_yum']) 27 | include_recipe 'postgresql::yum_pgdg_postgresql' 28 | end 29 | 30 | node['postgresql']['client']['packages'].each do |pg_pack| 31 | 32 | package pg_pack 33 | 34 | end 35 | -------------------------------------------------------------------------------- /cookbooks/openssl/README.md: -------------------------------------------------------------------------------- 1 | Description 2 | ==== 3 | 4 | Provide a library method to generate secure random passwords in recipes. 5 | 6 | Requirements 7 | ==== 8 | 9 | Works on any platform with OpenSSL Ruby bindings installed, which are a requirement for Chef anyway. 10 | 11 | Usage 12 | ==== 13 | 14 | Most often this will be used to generate a secure password for an attribute. 15 | 16 | include Opscode::OpenSSL::Password 17 | 18 | set_unless[:my_password] = secure_password 19 | 20 | License and Author 21 | ==== 22 | 23 | Author:: Joshua Timberman () 24 | 25 | Copyright:: 2009-2011, 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. 38 | -------------------------------------------------------------------------------- /cookbooks/memcached/metadata.rb: -------------------------------------------------------------------------------- 1 | maintainer "Opscode, Inc." 2 | maintainer_email "cookbooks@opscode.com" 3 | license "Apache 2.0" 4 | description "Installs memcached and provides a define to set up an instance of memcache via runit" 5 | long_description IO.read(File.join(File.dirname(__FILE__), 'README.rdoc')) 6 | version "0.10.4" 7 | depends "runit" 8 | 9 | recipe "memcached", "Installs and configures memcached" 10 | 11 | %w{ ubuntu debian }.each do |os| 12 | supports os 13 | end 14 | 15 | attribute "memcached/memory", 16 | :display_name => "Memcached Memory", 17 | :description => "Memory allocated for memcached instance", 18 | :default => "64" 19 | 20 | attribute "memcached/port", 21 | :display_name => "Memcached Port", 22 | :description => "Port to use for memcached instance", 23 | :default => "11211" 24 | 25 | attribute "memcached/user", 26 | :display_name => "Memcached User", 27 | :description => "User to run memcached instance as", 28 | :default => "nobody" 29 | 30 | attribute "memcached/listen", 31 | :display_name => "Memcached IP Address", 32 | :description => "IP address to use for memcached instance", 33 | :default => "0.0.0.0" 34 | -------------------------------------------------------------------------------- /cookbooks/postgresql/recipes/server_debian.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: postgresql 3 | # Recipe:: server 4 | # 5 | # Author:: Joshua Timberman () 6 | # Author:: Lamont Granquist ()# 7 | # Copyright 2009-2011, Opscode, Inc. 8 | # 9 | # Licensed under the Apache License, Version 2.0 (the "License"); 10 | # you may not use this file except in compliance with the License. 11 | # You may obtain a copy of the License at 12 | # 13 | # http://www.apache.org/licenses/LICENSE-2.0 14 | # 15 | # Unless required by applicable law or agreed to in writing, software 16 | # distributed under the License is distributed on an "AS IS" BASIS, 17 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | # See the License for the specific language governing permissions and 19 | # limitations under the License. 20 | # 21 | 22 | include_recipe "postgresql::client" 23 | 24 | node['postgresql']['server']['packages'].each do |pg_pack| 25 | 26 | package pg_pack 27 | 28 | end 29 | 30 | service "postgresql" do 31 | service_name node['postgresql']['server']['service_name'] 32 | supports :restart => true, :status => true, :reload => true 33 | action [:enable, :start] 34 | end 35 | -------------------------------------------------------------------------------- /cookbooks/java/recipes/default.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Author:: Seth Chisamore () 3 | # Cookbook Name:: java 4 | # Recipe:: default 5 | # 6 | # Copyright 2008-2011, 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 | if node['platform_family'] == "windows" 22 | include_recipe "java::windows" 23 | else 24 | include_recipe "java::#{node['java']['install_flavor']}" 25 | end 26 | 27 | # Purge the deprecated Sun Java packages if remove_deprecated_packages is true 28 | %w[sun-java6-jdk sun-java6-bin sun-java6-jre].each do |pkg| 29 | package pkg do 30 | action :purge 31 | only_if { node['java']['remove_deprecated_packages'] } 32 | end 33 | end 34 | -------------------------------------------------------------------------------- /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/build-essential/recipes/default.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: build-essential 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 | case node['platform'] 21 | when "ubuntu","debian" 22 | %w{build-essential binutils-doc}.each do |pkg| 23 | package pkg do 24 | action :install 25 | end 26 | end 27 | when "centos","redhat","fedora" 28 | %w{gcc gcc-c++ kernel-devel make}.each do |pkg| 29 | package pkg do 30 | action :install 31 | end 32 | end 33 | end 34 | 35 | package "autoconf" do 36 | action :install 37 | end 38 | 39 | package "flex" do 40 | action :install 41 | end 42 | 43 | package "bison" do 44 | action :install 45 | end 46 | -------------------------------------------------------------------------------- /cookbooks/apt/recipes/cacher-ng.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: apt 3 | # Recipe:: cacher-ng 4 | # 5 | # Copyright 2008-2012, 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 "apt-cacher-ng" do 21 | action :install 22 | end 23 | 24 | service "apt-cacher-ng" do 25 | supports :restart => true, :status => false 26 | action :enable 27 | end 28 | 29 | template "/etc/apt-cacher-ng/acng.conf" do 30 | source "acng.conf.erb" 31 | owner "root" 32 | group "root" 33 | mode 00644 34 | notifies :restart, "service[apt-cacher-ng]" 35 | end 36 | 37 | # Reopen resource w/ start in case config issue causes startup to fail 38 | service "apt-cacher-ng" do 39 | action :start 40 | end 41 | 42 | #this will help seed the proxy 43 | include_recipe "apt::cacher-client" 44 | -------------------------------------------------------------------------------- /cookbooks/apt/CONTRIBUTING: -------------------------------------------------------------------------------- 1 | If you would like to contribute, please open a ticket in JIRA: 2 | 3 | * http://tickets.opscode.com 4 | 5 | Create the ticket in the COOK project and use the cookbook name as the 6 | component. 7 | 8 | For all code contributions, we ask that contributors sign a 9 | contributor license agreement (CLA). Instructions may be found here: 10 | 11 | * http://wiki.opscode.com/display/chef/How+to+Contribute 12 | 13 | When contributing changes to individual cookbooks, please do not 14 | modify the version number in the metadata.rb. Also please do not 15 | update the CHANGELOG.md for a new version. Not all changes to a 16 | cookbook may be merged and released in the same versions. Opscode will 17 | handle the version updates during the release process. You are welcome 18 | to correct typos or otherwise make updates to documentation in the 19 | README. 20 | 21 | If a contribution adds new platforms or platform versions, indicate 22 | such in the body of the commit message(s), and update the relevant 23 | COOK ticket. When writing commit messages, it is helpful for others if 24 | you indicate the COOK ticket. For example: 25 | 26 | git commit -m '[COOK-1041] Updated pool resource to correctly delete.' 27 | 28 | In the ticket itself, it is also helpful if you include log output of 29 | a successful Chef run, but this is not absolutely required. 30 | -------------------------------------------------------------------------------- /cookbooks/postgresql/files/default/tests/minitest/ppa_pitti_postgresql_test.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2012, Opscode, Inc. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | 17 | require File.expand_path('../support/helpers', __FILE__) 18 | 19 | describe 'postgresql::ppa_pitti_postgresql' do 20 | include Helpers::Postgresql 21 | 22 | it 'creates the Pitti PPA sources.list' do 23 | skip unless %w{debian}.include?(node['platform_family']) 24 | file("/etc/apt/sources.list.d/pitti-postgresql-ppa.list").must_exist 25 | end 26 | 27 | it 'installs postgresql-client-9.2' do 28 | package("postgresql-client-9.2").must_be_installed 29 | end 30 | 31 | it 'makes psql version 9.2 available' do 32 | psql = shell_out("psql --version") 33 | assert psql.stdout.include?("psql (PostgreSQL) 9.2") 34 | end 35 | end 36 | -------------------------------------------------------------------------------- /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/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.attribute?('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']['data_dir']} #{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']['data_dir'] 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/postgresql/files/default/tests/minitest/server_test.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2012, Opscode, Inc. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | 17 | require File.expand_path('../support/helpers', __FILE__) 18 | 19 | describe 'postgresql::server' do 20 | include Helpers::Postgresql 21 | 22 | it 'installs the postgresql server packages' do 23 | node['postgresql']['server']['packages'].each do |pkg| 24 | package(pkg).must_be_installed 25 | end 26 | end 27 | 28 | it 'runs the postgresql service' do 29 | service(node['postgresql']['server']['service_name']).must_be_running 30 | end 31 | 32 | it 'can connect to postgresql' do 33 | require 'pg' 34 | conn = PG::Connection.new( 35 | :host => 'localhost', 36 | :port => '5432', 37 | :password => node['postgresql']['password']['postgres'], 38 | :user => "postgres" 39 | ) 40 | assert_match(/localhost/, conn.host) 41 | end 42 | 43 | end 44 | -------------------------------------------------------------------------------- /cookbooks/java/resources/ark.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Author:: Bryan W. Berry () 3 | # Cookbook Name:: java 4 | # Resource:: ark 5 | # 6 | # Copyright 2011, Bryan w. Berry 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 | actions :install, :remove 21 | 22 | attribute :url, :regex => /^http:\/\/.*(tar.gz|tgz|bin|zip)$/, :default => nil 23 | attribute :mirrorlist, :kind_of => Array, :default => nil 24 | attribute :checksum, :regex => /^[a-zA-Z0-9]{64}$/, :default => nil 25 | attribute :app_home, :kind_of => String, :default => nil 26 | attribute :app_home_mode, :kind_of => Integer, :default => 0755 27 | attribute :bin_cmds, :kind_of => Array, :default => nil 28 | attribute :owner, :default => "root" 29 | attribute :default, :equal_to => [true, false], :default => true 30 | attribute :alternatives_priority, :kind_of => Integer, :default => 1 31 | 32 | # we have to set default for the supports attribute 33 | # in initializer since it is a 'reserved' attribute name 34 | def initialize(*args) 35 | super 36 | @action = :install 37 | @supports = {:report => true, :exception => true} 38 | end 39 | -------------------------------------------------------------------------------- /cookbooks/apt/resources/repository.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: apt 3 | # Resource:: repository 4 | # 5 | # Copyright 2010-2011, 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 | actions :add, :remove 21 | 22 | def initialize(*args) 23 | super 24 | @action = :add 25 | end 26 | 27 | #name of the repo, used for source.list filename 28 | attribute :repo_name, :kind_of => String, :name_attribute => true 29 | attribute :uri, :kind_of => String 30 | attribute :distribution, :kind_of => String 31 | attribute :components, :kind_of => Array, :default => [] 32 | attribute :arch, :kind_of => String, :default => nil 33 | #whether or not to add the repository as a source repo as well 34 | attribute :deb_src, :default => false 35 | attribute :keyserver, :kind_of => String, :default => nil 36 | attribute :key, :kind_of => String, :default => nil 37 | attribute :cookbook, :kind_of => String, :default => nil 38 | #trigger cache rebuild 39 | #If not you can trigger in the recipe itself after checking the status of resource.updated{_by_last_action}? 40 | attribute :cache_rebuild, :kind_of => [TrueClass, FalseClass], :default => true 41 | -------------------------------------------------------------------------------- /cookbooks/memcached/recipes/default.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: memcached 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 "memcached" do 21 | action :upgrade 22 | end 23 | 24 | package "libmemcache-dev" do 25 | action :upgrade 26 | end 27 | 28 | service "memcached" do 29 | action :nothing 30 | supports :status => true, :start => true, :stop => true, :restart => true 31 | end 32 | 33 | template "/etc/memcached.conf" do 34 | source "memcached.conf.erb" 35 | owner "root" 36 | group "root" 37 | mode "0644" 38 | variables( 39 | :listen => node[:memcached][:listen], 40 | :user => node[:memcached][:user], 41 | :port => node[:memcached][:port], 42 | :memory => node[:memcached][:memory] 43 | ) 44 | notifies :restart, resources(:service => "memcached"), :immediately 45 | end 46 | 47 | case node[:lsb][:codename] 48 | when "karmic" 49 | template "/etc/default/memcached" do 50 | source "memcached.default.erb" 51 | owner "root" 52 | group "root" 53 | mode "0644" 54 | notifies :restart, resources(:service => "memcached"), :immediately 55 | end 56 | end 57 | -------------------------------------------------------------------------------- /cookbooks/java/recipes/oracle_i386.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Author:: Bryan W. Berry () 3 | # Cookbook Name:: java 4 | # Recipe:: oracle_i386 5 | # 6 | # Copyright 2010-2011, 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 | java_home = node['java']["java_home"] 21 | 22 | case node['java']['jdk_version'] 23 | when "6" 24 | tarball_url = node['java']['jdk']['6']['i586']['url'] 25 | tarball_checksum = node['java']['jdk']['6']['i586']['checksum'] 26 | bin_cmds = node['java']['jdk']['6']['bin_cmds'] 27 | when "7" 28 | tarball_url = node['java']['jdk']['7']['i586']['url'] 29 | tarball_checksum = node['java']['jdk']['7']['i586']['checksum'] 30 | bin_cmds = node['java']['jdk']['7']['bin_cmds'] 31 | end 32 | 33 | ruby_block "set-env-java-home" do 34 | block do 35 | ENV["JAVA_HOME"] = java_home 36 | end 37 | not_if { ENV["JAVA_HOME"] == java_home } 38 | end 39 | 40 | yum_package "glibc" do 41 | arch "i686" 42 | only_if { platform_family?( "rhel", "fedora" ) } 43 | end 44 | 45 | java_ark "jdk-alt" do 46 | url tarball_url 47 | checksum tarball_checksum 48 | app_home java_home 49 | bin_cmds bin_cmds 50 | action :install 51 | default false 52 | end 53 | -------------------------------------------------------------------------------- /cookbooks/vagrant_main/recipes/default.rb: -------------------------------------------------------------------------------- 1 | ENV['LANGUAGE'] = ENV['LANG'] = ENV['LC_ALL'] = "en_US.UTF-8" 2 | require_recipe 'apt' 3 | require_recipe 'git' 4 | require_recipe 'openssl' 5 | require_recipe "build-essential" 6 | require_recipe "java" 7 | require_recipe "vagrant_main::packages" 8 | require_recipe "rvm::system" 9 | require_recipe "rvm::vagrant" 10 | require_recipe "sqlite" 11 | require_recipe "mysql::server" 12 | require_recipe "postgresql::server" 13 | require_recipe "memcached" 14 | 15 | node['rvm']['rubies'].each do |ruby| 16 | rvm_shell "Bundle for #{ruby}" do 17 | ruby_string ruby 18 | cwd "/vagrant/rails" 19 | if !ruby.include?('rbx') 20 | code "bundle install" 21 | else 22 | code "RBXOPT=-X19 bundle install" 23 | end 24 | end 25 | end 26 | 27 | # modify from https://github.com/jeroenvandijk/rails_test_box 28 | mysql_shell = "/usr/bin/mysql -u root" 29 | cookbook_file "/tmp/rails_mysql_user_grants.sql" 30 | execute "Create Mysql Rails user" do 31 | command "#{mysql_shell} < /tmp/rails_mysql_user_grants.sql" 32 | not_if %[echo "select User from mysql.user" | #{mysql_shell} | grep rails] 33 | end 34 | 35 | rvm_shell "Build mysql databases" do 36 | ruby_string node['rvm']['default_ruby'] 37 | cwd "/vagrant/rails/activerecord" 38 | code "bundle exec rake mysql:build_databases" 39 | not_if %[echo "show databases" | #{mysql_shell} | grep activerecord] 40 | end 41 | 42 | rvm_shell "Build postgresql databases" do 43 | ruby_string node['rvm']['default_ruby'] 44 | user 'postgres' 45 | cwd "/vagrant/rails/activerecord" 46 | code "/usr/local/rvm/bin/rake postgresql:build_databases" 47 | not_if %[echo "select datname from pg_database" | psql | grep activerecord] 48 | end -------------------------------------------------------------------------------- /cookbooks/memcached/templates/default/memcached.conf.erb: -------------------------------------------------------------------------------- 1 | # 2 | # Configured by Chef. Logcal changes will be lost. 3 | # 4 | # memcached default config file 5 | # 2003 - Jay Bonci 6 | # This configuration file is read by the start-memcached script provided as 7 | # part of the Debian GNU/Linux distribution. 8 | 9 | # Run memcached as a daemon. This command is implied, and is not needed for the 10 | # daemon to run. See the README.Debian that comes with this package for more 11 | # information. 12 | -d 13 | 14 | # Log memcached's output to /var/log/memcached 15 | logfile /var/log/memcached.log 16 | 17 | # Be verbose 18 | -v 19 | 20 | # Be even more verbose (print client commands as well) 21 | # -vv 22 | 23 | # Start with a cap of 64 megs of memory. It's reasonable, and the daemon default 24 | # Note that the daemon will grow to this size, but does not start out holding this much 25 | # memory 26 | -m <%= @memory %> 27 | 28 | # Default connection port is 11211 29 | -p <%= @port %> 30 | 31 | # Run the daemon as root. The start-memcached will default to running as root if no 32 | # -u command is present in this config file 33 | -u <%= @user %> 34 | 35 | # Specify which IP address to listen on. The default is to listen on all IP addresses 36 | # This parameter is one of the only security measures that memcached has, so make sure 37 | # it's listening on a firewalled interface. 38 | -l <%= @listen %> 39 | 40 | # Limit the number of simultaneous incoming connections. The daemon default is 1024 41 | # -c 1024 42 | 43 | # Lock down all paged memory. Consult with the README and homepage before you do this 44 | # -k 45 | 46 | # Return error when memory is exhausted (rather than removing items) 47 | # -M 48 | 49 | # Maximize core file limit 50 | # -r 51 | -------------------------------------------------------------------------------- /cookbooks/postgresql/recipes/server_redhat.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: postgresql 3 | # Recipe:: server 4 | # 5 | # Author:: Joshua Timberman () 6 | # Author:: Lamont Granquist () 7 | # Copyright 2009-2011, Opscode, Inc. 8 | # 9 | # Licensed under the Apache License, Version 2.0 (the "License"); 10 | # you may not use this file except in compliance with the License. 11 | # You may obtain a copy of the License at 12 | # 13 | # http://www.apache.org/licenses/LICENSE-2.0 14 | # 15 | # Unless required by applicable law or agreed to in writing, software 16 | # distributed under the License is distributed on an "AS IS" BASIS, 17 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | # See the License for the specific language governing permissions and 19 | # limitations under the License. 20 | # 21 | 22 | include_recipe "postgresql::client" 23 | 24 | # Create a group and user like the package will. 25 | # Otherwise the templates fail. 26 | 27 | group "postgres" do 28 | gid 26 29 | end 30 | 31 | user "postgres" do 32 | shell "/bin/bash" 33 | comment "PostgreSQL Server" 34 | home "/var/lib/pgsql" 35 | gid "postgres" 36 | system true 37 | uid 26 38 | supports :manage_home => false 39 | end 40 | 41 | node['postgresql']['server']['packages'].each do |pg_pack| 42 | 43 | package pg_pack 44 | 45 | end 46 | 47 | execute "/sbin/service #{node['postgresql']['server']['service_name']} initdb" do 48 | not_if { ::FileTest.exist?(File.join(node['postgresql']['dir'], "PG_VERSION")) } 49 | end 50 | 51 | service "postgresql" do 52 | service_name node['postgresql']['server']['service_name'] 53 | supports :restart => true, :status => true, :reload => true 54 | action [:enable, :start] 55 | end 56 | -------------------------------------------------------------------------------- /cookbooks/mysql/recipes/client.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: mysql 3 | # Recipe:: client 4 | # 5 | # Copyright 2008-2011, 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::Resource::Package.send(:include, Opscode::Mysql::Helpers) 21 | 22 | package "mysql-client" do 23 | package_name value_for_platform( 24 | [ "centos", "redhat", "suse", "fedora"] => { "default" => "mysql" }, 25 | "default" => "mysql-client" 26 | ) 27 | action :install 28 | end 29 | 30 | package "mysql-devel" do 31 | package_name begin 32 | if platform?(%w{ centos redhat suse fedora }) 33 | "mysql-devel" 34 | elsif debian_before_squeeze? || ubuntu_before_lucid? 35 | "libmysqlclient15-dev" 36 | else 37 | "libmysqlclient-dev" 38 | end 39 | end 40 | action :install 41 | end 42 | 43 | if platform?(%w{ debian ubuntu redhat centos fedora suse }) 44 | 45 | package "mysql-ruby" do 46 | package_name value_for_platform( 47 | [ "centos", "redhat", "suse", "fedora"] => { "default" => "ruby-mysql" }, 48 | ["debian", "ubuntu"] => { "default" => 'libmysql-ruby' }, 49 | "default" => 'libmysql-ruby' 50 | ) 51 | action :install 52 | end 53 | 54 | else 55 | 56 | gem_package "mysql" do 57 | action :install 58 | end 59 | 60 | end 61 | -------------------------------------------------------------------------------- /cookbooks/memcached/README.rdoc: -------------------------------------------------------------------------------- 1 | = DESCRIPTION: 2 | 3 | Installs memcached and provides a define to set up an instance of memcache via runit. 4 | 5 | = REQUIREMENTS: 6 | 7 | == Platform: 8 | 9 | Tested on Ubuntu 8.10-9.10. Uses the memcached init script by default. A runit service can be set up for instances using the included define. 10 | 11 | == Cookbooks: 12 | 13 | Opscode cookbooks, http://github.com/opscode/cookbooks/tree/master: 14 | 15 | * runit 16 | 17 | = ATTRIBUTES: 18 | 19 | The following are node attributes passed to the template for the runit service. 20 | 21 | * memcached[:memory] - maximum memory for memcached instances. 22 | * memcached[:user] - user to run memcached as. 23 | * memcached[:port] - port for memcached to listen on. 24 | * memcached[:listen] - IP address for memcached to listen on. 25 | 26 | = USAGE: 27 | 28 | Simply set the attributes and it will configure the /etc/memcached.conf file. If you want to use multiple memcached instances, you'll need to modify the recipe to disable the startup script and the template in the default recipe. 29 | 30 | Use the define, memcached_instance, to set up a runit service for the named memcached instance. 31 | 32 | memcached_instance "myproj" 33 | 34 | = LICENSE and AUTHOR: 35 | 36 | Author:: Joshua Timberman () 37 | Author:: Joshua Sierles () 38 | 39 | Copyright:: 2009, Opscode, Inc 40 | Copyright:: 2009, 37signals 41 | 42 | Licensed under the Apache License, Version 2.0 (the "License"); 43 | you may not use this file except in compliance with the License. 44 | You may obtain a copy of the License at 45 | 46 | http://www.apache.org/licenses/LICENSE-2.0 47 | 48 | Unless required by applicable law or agreed to in writing, software 49 | distributed under the License is distributed on an "AS IS" BASIS, 50 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 51 | See the License for the specific language governing permissions and 52 | limitations under the License. 53 | -------------------------------------------------------------------------------- /cookbooks/apt/providers/preference.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: apt 3 | # Provider:: preference 4 | # 5 | # Copyright 2010-2011, 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 | # Build preferences.d file contents 21 | def build_pref(package_name, pin, pin_priority) 22 | preference_content = "Package: #{package_name}\nPin: #{pin}\nPin-Priority: #{pin_priority}\n" 23 | end 24 | 25 | action :add do 26 | new_resource.updated_by_last_action(false) 27 | 28 | preference = build_pref(new_resource.glob || new_resource.package_name, 29 | new_resource.pin, 30 | new_resource.pin_priority) 31 | 32 | preference_dir = directory "/etc/apt/preferences.d" do 33 | owner "root" 34 | group "root" 35 | mode 00755 36 | recursive true 37 | action :nothing 38 | end 39 | 40 | preference_file = file "/etc/apt/preferences.d/#{new_resource.name}" do 41 | owner "root" 42 | group "root" 43 | mode 00644 44 | content preference 45 | action :nothing 46 | end 47 | 48 | preference_dir.run_action(:create) 49 | # write out the preference file, replace it if it already exists 50 | preference_file.run_action(:create) 51 | end 52 | 53 | action :remove do 54 | if ::File.exists?("/etc/apt/preferences.d/#{new_resource.name}") 55 | Chef::Log.info "Un-pinning #{new_resource.name} from /etc/apt/preferences.d/" 56 | file "/etc/apt/preferences.d/#{new_resource.name}" do 57 | action :delete 58 | end 59 | new_resource.updated_by_last_action(true) 60 | end 61 | end 62 | -------------------------------------------------------------------------------- /cookbooks/apt/recipes/cacher-client.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: apt 3 | # Recipe:: cacher-client 4 | # 5 | # Copyright 2011, 2012 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 | #remove Acquire::http::Proxy lines from /etc/apt/apt.conf since we use 01proxy 21 | #these are leftover from preseed installs 22 | execute 'Remove proxy from /etc/apt/apt.conf' do 23 | command "sed --in-place '/^Acquire::http::Proxy/d' /etc/apt/apt.conf" 24 | only_if "grep Acquire::http::Proxy /etc/apt/apt.conf" 25 | end 26 | 27 | servers = [] 28 | if node['apt'] && node['apt']['cacher_ipaddress'] 29 | cacher = Chef::Node.new 30 | cacher.name(node['apt']['cacher_ipaddress']) 31 | cacher.ipaddress(node['apt']['cacher_ipaddress']) 32 | servers << cacher 33 | end 34 | 35 | unless Chef::Config[:solo] 36 | query = 'recipes:apt\:\:cacher-ng' 37 | query += " AND chef_environment:#{node.chef_environment}" if node['apt']['cacher-client']['restrict_environment'] 38 | Chef::Log.debug("apt::cacher-client searching for '#{query}'") 39 | servers += search(:node, query) 40 | end 41 | 42 | if servers.length > 0 43 | Chef::Log.info("apt-cacher-ng server found on #{servers[0]}.") 44 | template '/etc/apt/apt.conf.d/01proxy' do 45 | source '01proxy.erb' 46 | owner 'root' 47 | group 'root' 48 | mode 00644 49 | variables( 50 | :proxy => servers[0]['ipaddress'], 51 | :port => node['apt']['cacher_port'] 52 | ) 53 | end.run_action(:create) 54 | else 55 | Chef::Log.info('No apt-cacher-ng server found.') 56 | file '/etc/apt/apt.conf.d/01proxy' do 57 | action :delete 58 | end 59 | end 60 | -------------------------------------------------------------------------------- /cookbooks/java/recipes/oracle.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Author:: Bryan W. Berry () 3 | # Cookbook Name:: java 4 | # Recipe:: oracle 5 | # 6 | # Copyright 2011, Bryan w. Berry 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 | java_home = node['java']["java_home"] 22 | arch = node['java']['arch'] 23 | jdk_version = node['java']['jdk_version'] 24 | 25 | #convert version number to a string if it isn't already 26 | if jdk_version.instance_of? Fixnum 27 | jdk_version = jdk_version.to_s 28 | end 29 | 30 | case jdk_version 31 | when "6" 32 | tarball_url = node['java']['jdk']['6'][arch]['url'] 33 | tarball_checksum = node['java']['jdk']['6'][arch]['checksum'] 34 | bin_cmds = node['java']['jdk']['6']['bin_cmds'] 35 | when "7" 36 | tarball_url = node['java']['jdk']['7'][arch]['url'] 37 | tarball_checksum = node['java']['jdk']['7'][arch]['checksum'] 38 | bin_cmds = node['java']['jdk']['7']['bin_cmds'] 39 | end 40 | 41 | if tarball_url =~ /example.com/ 42 | Chef::Application.fatal!("You must change the download link to your private repository. You can no longer download java directly from http://download.oracle.com without a web broswer") 43 | end 44 | 45 | ruby_block "set-env-java-home" do 46 | block do 47 | ENV["JAVA_HOME"] = java_home 48 | end 49 | not_if { ENV["JAVA_HOME"] == java_home } 50 | end 51 | 52 | file "/etc/profile.d/jdk.sh" do 53 | content <<-EOS 54 | export JAVA_HOME=#{node['java']['java_home']} 55 | EOS 56 | mode 0755 57 | end 58 | 59 | 60 | java_ark "jdk" do 61 | url tarball_url 62 | checksum tarball_checksum 63 | app_home java_home 64 | bin_cmds bin_cmds 65 | alternatives_priority 1062 66 | action :install 67 | end 68 | 69 | -------------------------------------------------------------------------------- /cookbooks/apt/recipes/default.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: apt 3 | # Recipe:: default 4 | # 5 | # Copyright 2008-2011, Opscode, Inc. 6 | # Copyright 2009, Bryan McLellan 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 | # Run apt-get update to create the stamp file 22 | execute "apt-get-update" do 23 | command "apt-get update" 24 | ignore_failure true 25 | not_if do ::File.exists?('/var/lib/apt/periodic/update-success-stamp') end 26 | end 27 | 28 | # For other recipes to call to force an update 29 | execute "apt-get update" do 30 | command "apt-get update" 31 | ignore_failure true 32 | action :nothing 33 | end 34 | 35 | # Automatically remove packages that are no longer needed for dependencies 36 | execute "apt-get autoremove" do 37 | command "apt-get -y autoremove" 38 | action :nothing 39 | end 40 | 41 | # Automatically remove .deb files for packages no longer on your system 42 | execute "apt-get autoclean" do 43 | command "apt-get -y autoclean" 44 | action :nothing 45 | end 46 | 47 | # provides /var/lib/apt/periodic/update-success-stamp on apt-get update 48 | package "update-notifier-common" do 49 | notifies :run, resources(:execute => "apt-get-update"), :immediately 50 | end 51 | 52 | execute "apt-get-update-periodic" do 53 | command "apt-get update" 54 | ignore_failure true 55 | only_if do 56 | ::File.exists?('/var/lib/apt/periodic/update-success-stamp') && 57 | ::File.mtime('/var/lib/apt/periodic/update-success-stamp') < Time.now - 86400 58 | end 59 | end 60 | 61 | %w{/var/cache/local /var/cache/local/preseeding}.each do |dirname| 62 | directory dirname do 63 | owner "root" 64 | group "root" 65 | mode 00755 66 | action :create 67 | end 68 | end 69 | -------------------------------------------------------------------------------- /cookbooks/mysql/providers/database.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: mysql 3 | # Provider:: database 4 | # 5 | # Copyright:: 2008-2011, 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 Opscode::Mysql::Database 21 | 22 | action :flush_tables_with_read_lock do 23 | if exists? 24 | begin 25 | Chef::Log.info "mysql_database: flushing tables with read lock" 26 | db.query "flush tables with read lock" 27 | new_resource.updated_by_last_action(true) 28 | ensure 29 | db.close 30 | end 31 | end 32 | end 33 | 34 | action :unflush_tables do 35 | if exists? 36 | begin 37 | Chef::Log.info "mysql_database: unlocking tables" 38 | db.query "unlock tables" 39 | new_resource.updated_by_last_action(true) 40 | ensure 41 | db.close 42 | end 43 | end 44 | end 45 | 46 | action :create_db do 47 | unless exists? 48 | begin 49 | Chef::Log.info "mysql_database: Creating database #{new_resource.database}" 50 | db.query("create database #{new_resource.database}") 51 | new_resource.updated_by_last_action(true) 52 | ensure 53 | db.close 54 | end 55 | end 56 | end 57 | 58 | action :query do 59 | if exists? 60 | begin 61 | Chef::Log.info "mysql_database: Performing Query: #{new_resource.sql}" 62 | db.query(new_resource.sql) 63 | new_resource.updated_by_last_action(true) 64 | ensure 65 | db.close 66 | end 67 | end 68 | end 69 | 70 | def load_current_resource 71 | Gem.clear_paths 72 | require 'mysql' 73 | 74 | @mysqldb = Chef::Resource::MysqlDatabase.new(new_resource.name) 75 | @mysqldb.database(new_resource.database) 76 | end 77 | 78 | private 79 | def exists? 80 | db.list_dbs.include?(new_resource.database) 81 | end 82 | -------------------------------------------------------------------------------- /cookbooks/apt/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## v1.9.0: 2 | 3 | * [COOK-2185] - Proxy for apt-key 4 | * [COOK-2338] - Support pinning by glob() or regexp 5 | 6 | ## v1.8.4: 7 | 8 | * [COOK-2171] - Update README to clarify required Chef version: 10.18.0 9 | or higher. 10 | 11 | ## v1.8.2: 12 | 13 | * [COOK-2112] - need [] around "arch" in sources.list entries 14 | * [COOK-2171] - fixes a regression in the notification 15 | 16 | ## v1.8.0: 17 | 18 | * [COOK-2143] - Allow for a custom cacher-ng port 19 | * [COOK-2171] - On `apt_repository.run_action(:add)` the source file 20 | is not created. 21 | * [COOK-2184] - apt::cacher-ng, use `cacher_port` attribute in 22 | acng.conf 23 | 24 | ## v1.7.0: 25 | 26 | * [COOK-2082] - add "arch" parameter to apt_repository LWRP 27 | 28 | ## v1.6.0: 29 | 30 | * [COOK-1893] - `apt_preference` use "`package_name`" resource instead of "name" 31 | * [COOK-1894] - change filename for sources.list.d files 32 | * [COOK-1914] - Wrong dir permissions for /etc/apt/preferences.d/ 33 | * [COOK-1942] - README.md has wrong name for the keyserver attribute 34 | * [COOK-2019] - create 01proxy before any other apt-get updates get executed 35 | 36 | ## v1.5.2: 37 | 38 | * [COOK-1682] - use template instead of file resource in apt::cacher-client 39 | * [COOK-1875] - cacher-client should be Environment-aware 40 | 41 | ## V1.5.0: 42 | 43 | * [COOK-1500] - Avoid triggering apt-get update 44 | * [COOK-1548] - Add execute commands for autoclean and autoremove 45 | * [COOK-1591] - Setting up the apt proxy should leave https 46 | connections direct 47 | * [COOK-1596] - execute[apt-get-update-periodic] never runs 48 | * [COOK-1762] - create /etc/apt/preferences.d directory 49 | * [COOK-1776] - apt key check isn't idempotent 50 | 51 | ## v1.4.8: 52 | 53 | * Adds test-kitchen support 54 | * [COOK-1435] - repository lwrp is not idempotent with http key 55 | 56 | ## v1.4.6: 57 | 58 | * [COOK-1530] - apt_repository isn't aware of update-success-stamp 59 | file (also reverts COOK-1382 patch). 60 | 61 | ## v1.4.4: 62 | 63 | * [COOK-1229] - Allow cacher IP to be set manually in non-Chef Solo 64 | environments 65 | * [COOK-1530] - Immediately update apt-cache when sources.list file is dropped off 66 | 67 | ## v1.4.2: 68 | 69 | * [COOK-1155] - LWRP for apt pinning 70 | 71 | ## v1.4.0: 72 | 73 | * [COOK-889] - overwrite existing repo source files 74 | * [COOK-921] - optionally use cookbook\_file or remote\_file for key 75 | * [COOK-1032] - fixes problem with apt repository key installation 76 | -------------------------------------------------------------------------------- /cookbooks/java/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## v1.9.6: 2 | 3 | * [COOK-2412] - add support for Oracle Linux 4 | 5 | ## v1.9.4: 6 | 7 | * [COOK-2083] - Run set-env-java-home in Java cookbook only if necessary 8 | * [COOK-2332] - ark provider does not allow for *.tgz tarballs to be used 9 | * [COOK-2345] - Java cookbook fails on CentOS6 (update-java-alternatives) 10 | 11 | ## v1.9.2: 12 | 13 | * [COOK-2306] - FoodCritic fixes for java cookbook 14 | 15 | ## v1.9.0: 16 | 17 | * [COOK-2236] - Update the Oracle Java version in the Java cookbook to 18 | release 1.7u11 19 | 20 | ## v1.8.2: 21 | 22 | * [COOK-2205] - Fix for missing /usr/lib/jvm/default-java on Debian 23 | 24 | ## v1.8.0: 25 | 26 | * [COOK-2095] - Add windows support 27 | 28 | ## v1.7.0: 29 | 30 | * [COOK-2001] - improvements for Oracle update-alternatives 31 | - When installing an Oracle JDK it is now registered with a higher 32 | priority than OpenJDK. (Related to COOK-1131.) 33 | - When running both the oracle and oracle_i386 recipes, alternatives 34 | are now created for both JDKs. 35 | - Alternatives are now created for all binaries listed in version 36 | specific attributes. (Related to COOK-1563 and COOK-1635.) 37 | - When installing Oracke JDKs on Ubuntu, create .jinfo files for use 38 | with update-java-alternatives. Commands to set/install 39 | alternatives now only run if needed. 40 | 41 | ## v1.6.4: 42 | 43 | * [COOK-1930] - fixed typo in attribute for java 5 on i586 44 | 45 | ## v1.6.2: 46 | 47 | * whyrun support in `java_ark` LWRP 48 | * CHEF-1804 compatibility 49 | * [COOK-1786]- install Java 6u37 and Java 7u9 50 | * [COOK-1819] -incorrect warning text about 51 | `node['java']['oracle']['accept_oracle_download_terms']` 52 | 53 | ## v1.6.0: 54 | 55 | * [COOK-1218] - Install Oracle JDK from Oracle download directly 56 | * [COOK-1631] - set JAVA_HOME in openjdk recipe 57 | * [COOK-1655] - Install correct architecture on Amazon Linux 58 | 59 | ## v1.5.4: 60 | 61 | * [COOK-885] - update alternatives called on wrong file 62 | * [COOK-1607] - use shellout instead of execute resource to update 63 | alternatives 64 | 65 | ## v1.5.2: 66 | 67 | * [COOK-1200] - remove sun-java6-jre on Ubuntu before installing 68 | Oracle's Java 69 | * [COOK-1260] - fails on Ubuntu 12.04 64bit with openjdk7 70 | * [COOK-1265] - Oracle Java should symlink the jar command 71 | 72 | ## v1.5.0: 73 | 74 | * [COOK-1146] - Oracle now prevents download of JDK via non-browser 75 | * [COOK-1114] - fix File.exists? 76 | 77 | ## v1.4.2: 78 | 79 | * [COOK-1051] - fix attributes typo and platform case switch 80 | consistency 81 | 82 | ## v1.4.0: 83 | 84 | * [COOK-858] - numerous updates: handle jdk6 and 7, switch from sun to 85 | oracle, make openjdk default, add `java_ark` LWRP. 86 | * [COOK-942] - FreeBSD support 87 | * [COOK-520] - ArchLinux support 88 | -------------------------------------------------------------------------------- /cookbooks/postgresql/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## v2.2.2: 2 | 3 | * [COOK-2232] -Provide PGDG yum repo to install postgresql 9.x on 4 | redhat-derived distributions 5 | 6 | ## v2.2.0: 7 | 8 | * [COOK-2230] - Careful about Debian minor version numbers 9 | * [COOK-2231] - Fix support for postgresql 9.x in server_redhat recipe 10 | * [COOK-2238] - Postgresql recipe error in password check 11 | * [COOK-2176] - PostgreSQL cookbook in Solo mode can cause 12 | "NoMethodError: undefined method `[]' for nil:NilClass" 13 | * [COOK-2233] - Provide postgresql::contrib recipe to install useful 14 | server administration tools 15 | 16 | ## v2.1.0: 17 | 18 | * [COOK-1872] - Allow latest PostgreSQL deb packages to be installed 19 | * [COOK-1961] - Postgresql config file changes with every Chef run 20 | * [COOK-2041] - Postgres cookbook no longer installs on OpenSuSE 11.4 21 | 22 | ## v2.0.2: 23 | 24 | * [COOK-1406] - pg gem compile is unable to find libpq under Chef full 25 | stack (omnibus) installation 26 | 27 | ## v2.0.0: 28 | 29 | This version is backwards incompatible with previous versions of the 30 | cookbook due to use of `platform_family`, and the refactored 31 | configuration files using node attributes. See README.md for details 32 | on how to modify configuration of PostgreSQL. 33 | 34 | * [COOK-1508] - fix mixlib shellout error on SUSE 35 | * [COOK-1744] - Add service enable & start 36 | * [COOK-1779] - Don't run apt-get update and others in ruby recipe if pg is installed 37 | * [COOK-1871] - Attribute driven configuration files for PostgreSQL 38 | * [COOK-1900] - don't assume ssl on all postgresql 8.4+ installs 39 | * [COOK-1901] - fail a chef-solo run when the postgres password 40 | attribute is not set 41 | 42 | ## v1.0.0: 43 | 44 | **Important note for this release** 45 | 46 | This version no longer installs Ruby bindings in the client recipe by 47 | default. Use the ruby recipe if you'd like the RubyGem. If you'd like 48 | packages for your distribution, use them in your application's 49 | specific cookbook/recipe, or modify the client packages attribute. 50 | 51 | This resolves the following tickets. 52 | 53 | * COOK-1011 54 | * COOK-1534 55 | 56 | The following issues are also resolved with this release. 57 | 58 | * [COOK-1011] - Don't install postgresql packages during compile 59 | phase and remove pg gem installation 60 | * [COOK-1224] - fix undefined variable on Debian 61 | * [COOK-1462] - Add attribute for specifying listen address 62 | 63 | ## v0.99.4: 64 | 65 | * [COOK-421] - config template is malformed 66 | * [COOK-956] - add make package on ubuntu/debian 67 | 68 | ## v0.99.2: 69 | 70 | * [COOK-916] - use < (with float) for version comparison. 71 | 72 | ## v0.99.0: 73 | 74 | * Better support for Red Hat-family platforms 75 | * Integration with database cookbook 76 | * Make sure the postgres role is updated with a (secure) password 77 | -------------------------------------------------------------------------------- /cookbooks/postgresql/recipes/yum_pgdg_postgresql.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: postgresql 3 | # Recipe::yum_pgdg_postgresql 4 | # 5 | # Copyright 2013, DonorsChoose.org 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 | # The PostgreSQL RPM Building Project built repository RPMs for easy 22 | # access to the PGDG yum repositories. Links to RPMs for installation 23 | # are in an attribute so that new versions/platforms can be more 24 | # easily added. (See attributes/default.rb) 25 | 26 | repo_rpm_url = node['postgresql']['pgdg']['repo_rpm_url']. 27 | fetch(node['postgresql']['version']). # e.g., fetch for "9.1" 28 | fetch(node['platform']). # e.g., fetch for "centos" 29 | fetch(node['platform_version'].to_f.to_i.to_s). # e.g., fetch for "5" (truncated "5.7") 30 | fetch(node['kernel']['machine']) # e.g., fetch for "i386" or "x86_64" 31 | 32 | # Extract the filename portion from the URL for the PGDG repository RPM. 33 | # E.g., repo_rpm_filename = "pgdg-centos92-9.2-6.noarch.rpm" 34 | repo_rpm_filename = File.basename(repo_rpm_url) 35 | 36 | # Extract the package name from the URL for the PGDG repository RPM. 37 | # E.g., repo_rpm_package = "pgdg-centos92" 38 | repo_rpm_package = repo_rpm_filename.split(/-/,3)[0..1].join('-') 39 | 40 | ###################################### 41 | # Install the "PostgreSQL RPM Building Project - Yum Repository" through 42 | # the repo_rpm_url determined above. The /etc/yum.repos.d/pgdg-*.repo 43 | # will provide postgresql9X packages, but you may need to exclude 44 | # postgresql packages from the repository of the distro in order to use 45 | # PGDG repository properly. Conflicts will arise if postgresql9X does 46 | # appear in your distro's repo and you want a more recent patch level. 47 | 48 | # Download the PGDG repository RPM as a local file 49 | remote_file "#{Chef::Config[:file_cache_path]}/#{repo_rpm_filename}" do 50 | source "#{repo_rpm_url}" 51 | mode "0644" 52 | end 53 | 54 | # Install the PGDG repository RPM from the local file 55 | # E.g., /etc/yum.repos.d/pgdg-91-centos.repo 56 | package "#{repo_rpm_package}" do 57 | provider Chef::Provider::Package::Rpm 58 | source "#{Chef::Config[:file_cache_path]}/#{repo_rpm_filename}" 59 | action :install 60 | end 61 | -------------------------------------------------------------------------------- /cookbooks/postgresql/recipes/server.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: postgresql 3 | # Recipe:: server 4 | # 5 | # Author:: Joshua Timberman () 6 | # Author:: Lamont Granquist () 7 | # Copyright 2009-2011, Opscode, Inc. 8 | # 9 | # Licensed under the Apache License, Version 2.0 (the "License"); 10 | # you may not use this file except in compliance with the License. 11 | # You may obtain a copy of the License at 12 | # 13 | # http://www.apache.org/licenses/LICENSE-2.0 14 | # 15 | # Unless required by applicable law or agreed to in writing, software 16 | # distributed under the License is distributed on an "AS IS" BASIS, 17 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | # See the License for the specific language governing permissions and 19 | # limitations under the License. 20 | # 21 | 22 | ::Chef::Recipe.send(:include, Opscode::OpenSSL::Password) 23 | 24 | include_recipe "postgresql::client" 25 | 26 | # randomly generate postgres password, unless using solo - see README 27 | if Chef::Config[:solo] 28 | missing_attrs = %w{ 29 | postgres 30 | }.select do |attr| 31 | node['postgresql']['password'][attr].nil? 32 | end.map { |attr| "node['postgresql']['password']['#{attr}']" } 33 | 34 | if !missing_attrs.empty? 35 | Chef::Application.fatal!([ 36 | "You must set #{missing_attrs.join(', ')} in chef-solo mode.", 37 | "For more information, see https://github.com/opscode-cookbooks/postgresql#chef-solo-note" 38 | ].join(' ')) 39 | end 40 | else 41 | node.set_unless['postgresql']['password']['postgres'] = secure_password 42 | node.save 43 | end 44 | 45 | # Include the right "family" recipe for installing the server 46 | # since they do things slightly differently. 47 | case node['platform_family'] 48 | when "rhel", "fedora", "suse" 49 | include_recipe "postgresql::server_redhat" 50 | when "debian" 51 | include_recipe "postgresql::server_debian" 52 | end 53 | 54 | template "#{node['postgresql']['dir']}/postgresql.conf" do 55 | source "postgresql.conf.erb" 56 | owner "postgres" 57 | group "postgres" 58 | mode 0600 59 | notifies :restart, 'service[postgresql]', :immediately 60 | end 61 | 62 | template "#{node['postgresql']['dir']}/pg_hba.conf" do 63 | source "pg_hba.conf.erb" 64 | owner "postgres" 65 | group "postgres" 66 | mode 00600 67 | notifies :reload, 'service[postgresql]', :immediately 68 | end 69 | 70 | # Default PostgreSQL install has 'ident' checking on unix user 'postgres' 71 | # and 'md5' password checking with connections from 'localhost'. This script 72 | # runs as user 'postgres', so we can execute the 'role' and 'database' resources 73 | # as 'root' later on, passing the below credentials in the PG client. 74 | bash "assign-postgres-password" do 75 | user 'postgres' 76 | code <<-EOH 77 | echo "ALTER ROLE postgres ENCRYPTED PASSWORD '#{node['postgresql']['password']['postgres']}';" | psql 78 | EOH 79 | not_if "echo '\\connect' | PGPASSWORD=#{node['postgresql']['password']['postgres']} psql --username=postgres --no-password -h localhost" 80 | action :run 81 | end 82 | -------------------------------------------------------------------------------- /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 | default['mysql']['bind_address'] = attribute?('cloud') ? cloud['local_ipv4'] : ipaddress 21 | default['mysql']['data_dir'] = "/var/lib/mysql" 22 | 23 | case node["platform"] 24 | when "centos", "redhat", "fedora", "suse" 25 | set['mysql']['conf_dir'] = '/etc' 26 | set['mysql']['socket'] = "/var/lib/mysql/mysql.sock" 27 | set['mysql']['pid_file'] = "/var/run/mysqld/mysqld.pid" 28 | set['mysql']['old_passwords'] = 1 29 | else 30 | set['mysql']['conf_dir'] = '/etc/mysql' 31 | set['mysql']['socket'] = "/var/run/mysqld/mysqld.sock" 32 | set['mysql']['pid_file'] = "/var/run/mysqld/mysqld.pid" 33 | set['mysql']['old_passwords'] = 0 34 | end 35 | 36 | if attribute?('ec2') 37 | default['mysql']['ec2_path'] = "/mnt/mysql" 38 | default['mysql']['ebs_vol_dev'] = "/dev/sdi" 39 | default['mysql']['ebs_vol_size'] = 50 40 | end 41 | 42 | default['mysql']['allow_remote_root'] = false 43 | default['mysql']['tunable']['back_log'] = "128" 44 | default['mysql']['tunable']['key_buffer'] = "256M" 45 | default['mysql']['tunable']['max_allowed_packet'] = "16M" 46 | default['mysql']['tunable']['max_connections'] = "800" 47 | default['mysql']['tunable']['max_heap_table_size'] = "32M" 48 | default['mysql']['tunable']['myisam_recover'] = "BACKUP" 49 | default['mysql']['tunable']['net_read_timeout'] = "30" 50 | default['mysql']['tunable']['net_write_timeout'] = "30" 51 | default['mysql']['tunable']['table_cache'] = "128" 52 | default['mysql']['tunable']['table_open_cache'] = "128" 53 | default['mysql']['tunable']['thread_cache'] = "128" 54 | default['mysql']['tunable']['thread_cache_size'] = 8 55 | default['mysql']['tunable']['thread_concurrency'] = 10 56 | default['mysql']['tunable']['thread_stack'] = "256K" 57 | default['mysql']['tunable']['wait_timeout'] = "180" 58 | 59 | default['mysql']['tunable']['query_cache_limit'] = "1M" 60 | default['mysql']['tunable']['query_cache_size'] = "16M" 61 | 62 | default['mysql']['tunable']['log_slow_queries'] = "/var/log/mysql/slow.log" 63 | default['mysql']['tunable']['long_query_time'] = 2 64 | 65 | default['mysql']['tunable']['expire_logs_days'] = 10 66 | default['mysql']['tunable']['max_binlog_size'] = "100M" 67 | 68 | default['mysql']['tunable']['innodb_buffer_pool_size'] = "256M" 69 | -------------------------------------------------------------------------------- /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.md')) 6 | version "1.0.8" 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/data_dir", 29 | :display_name => "MySQL Data Directory", 30 | :description => "Location of mysql databases", 31 | :default => "/var/lib/mysql" 32 | 33 | attribute "mysql/conf_dir", 34 | :display_name => "MySQL Conf Directory", 35 | :description => "Location of mysql conf files", 36 | :default => "/etc/mysql" 37 | 38 | attribute "mysql/ec2_path", 39 | :display_name => "MySQL EC2 Path", 40 | :description => "Location of mysql directory on EC2 instance EBS volumes", 41 | :default => "/mnt/mysql" 42 | 43 | attribute "mysql/tunable", 44 | :display_name => "MySQL Tunables", 45 | :description => "Hash of MySQL tunable attributes", 46 | :type => "hash" 47 | 48 | attribute "mysql/tunable/key_buffer", 49 | :display_name => "MySQL Tuntable Key Buffer", 50 | :default => "250M" 51 | 52 | attribute "mysql/tunable/max_connections", 53 | :display_name => "MySQL Tunable Max Connections", 54 | :default => "800" 55 | 56 | attribute "mysql/tunable/wait_timeout", 57 | :display_name => "MySQL Tunable Wait Timeout", 58 | :default => "180" 59 | 60 | attribute "mysql/tunable/net_read_timeout", 61 | :display_name => "MySQL Tunable Net Read Timeout", 62 | :default => "30" 63 | 64 | attribute "mysql/tunable/net_write_timeout", 65 | :display_name => "MySQL Tunable Net Write Timeout", 66 | :default => "30" 67 | 68 | attribute "mysql/tunable/back_log", 69 | :display_name => "MySQL Tunable Back Log", 70 | :default => "128" 71 | 72 | attribute "mysql/tunable/table_cache", 73 | :display_name => "MySQL Tunable Table Cache for MySQL < 5.1.3", 74 | :default => "128" 75 | 76 | attribute "mysql/tunable/table_open_cache", 77 | :display_name => "MySQL Tunable Table Cache for MySQL >= 5.1.3", 78 | :default => "128" 79 | 80 | attribute "mysql/tunable/max_heap_table_size", 81 | :display_name => "MySQL Tunable Max Heap Table Size", 82 | :default => "32M" 83 | 84 | attribute "mysql/tunable/expire_logs_days", 85 | :display_name => "MySQL Exipre Log Days", 86 | :default => "10" 87 | 88 | attribute "mysql/tunable/max_binlog_size", 89 | :display_name => "MySQL Max Binlog Size", 90 | :default => "100M" 91 | -------------------------------------------------------------------------------- /cookbooks/postgresql/recipes/ruby.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: postgresql 3 | # Recipe:: ruby 4 | # 5 | # Author:: Joshua Timberman () 6 | # Copyright 2012 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 | begin 22 | require 'pg' 23 | rescue LoadError 24 | execute "apt-get update" do 25 | ignore_failure true 26 | action :nothing 27 | end.run_action(:run) if node['platform_family'] == "debian" 28 | 29 | node.set['build_essential']['compiletime'] = true 30 | include_recipe "build-essential" 31 | include_recipe "postgresql::client" 32 | 33 | node['postgresql']['client']['packages'].each do |pg_pack| 34 | 35 | resources("package[#{pg_pack}]").run_action(:install) 36 | 37 | end 38 | 39 | begin 40 | chef_gem "pg" 41 | rescue Gem::Installer::ExtensionBuildError => e 42 | # Are we an omnibus install? 43 | raise if RbConfig.ruby.scan(%r{(chef|opscode)}).empty? 44 | # Still here, must be omnibus. Lets make this thing install! 45 | Chef::Log.warn 'Failed to properly build pg gem. Forcing properly linking and retrying (omnibus fix)' 46 | gem_dir = e.message.scan(%r{will remain installed in ([^ ]+)}).flatten.first 47 | raise unless gem_dir 48 | gem_name = File.basename(gem_dir) 49 | ext_dir = File.join(gem_dir, 'ext') 50 | gem_exec = File.join(File.dirname(RbConfig.ruby), 'gem') 51 | new_content = <<-EOS 52 | require 'rbconfig' 53 | %w( 54 | configure_args 55 | LIBRUBYARG_SHARED 56 | LIBRUBYARG_STATIC 57 | LIBRUBYARG 58 | LDFLAGS 59 | ).each do |key| 60 | RbConfig::CONFIG[key].gsub!(/-Wl[^ ]+( ?\\/[^ ]+)?/, '') 61 | RbConfig::MAKEFILE_CONFIG[key].gsub!(/-Wl[^ ]+( ?\\/[^ ]+)?/, '') 62 | end 63 | RbConfig::CONFIG['RPATHFLAG'] = '' 64 | RbConfig::MAKEFILE_CONFIG['RPATHFLAG'] = '' 65 | EOS 66 | new_content << File.read(extconf_path = File.join(ext_dir, 'extconf.rb')) 67 | File.open(extconf_path, 'w') do |file| 68 | file.write(new_content) 69 | end 70 | 71 | lib_builder = execute 'generate pg gem Makefile' do 72 | command "#{RbConfig.ruby} extconf.rb" 73 | cwd ext_dir 74 | action :nothing 75 | end 76 | lib_builder.run_action(:run) 77 | 78 | lib_maker = execute 'make pg gem lib' do 79 | command 'make' 80 | cwd ext_dir 81 | action :nothing 82 | end 83 | lib_maker.run_action(:run) 84 | 85 | lib_installer = execute 'install pg gem lib' do 86 | command 'make install' 87 | cwd ext_dir 88 | action :nothing 89 | end 90 | lib_installer.run_action(:run) 91 | 92 | spec_installer = execute 'install pg spec' do 93 | command "#{gem_exec} spec ./cache/#{gem_name}.gem --ruby > ./specifications/#{gem_name}.gemspec" 94 | cwd File.join(gem_dir, '..', '..') 95 | action :nothing 96 | end 97 | spec_installer.run_action(:run) 98 | 99 | Chef::Log.warn 'Installation of pg gem successful!' 100 | end 101 | end 102 | -------------------------------------------------------------------------------- /Vagrantfile: -------------------------------------------------------------------------------- 1 | Vagrant::Config.run do |config| 2 | # All Vagrant configuration is done here. The most common configuration 3 | # options are documented and commented below. For a complete reference, 4 | # please see the online documentation at vagrantup.com. 5 | 6 | # Every Vagrant virtual environment requires a box to build off of. 7 | config.vm.box = "precise64" 8 | 9 | config.vm.customize ["modifyvm", :id, "--memory", 1536, "--name", "Vagrant Rails Test Environment"] 10 | 11 | # The url from where the 'config.vm.box' box will be fetched if it 12 | # doesn't already exist on the user's system. 13 | # config.vm.box_url = "http://domain.com/path/to/above.box" 14 | 15 | # Boot with a GUI so you can see the screen. (Default is headless) 16 | # config.vm.boot_mode = :gui 17 | 18 | # Assign this VM to a host only network IP, allowing you to access it 19 | # via the IP. 20 | # config.vm.network "33.33.33.10" 21 | 22 | # Forward a port from the guest to the host, which allows for outside 23 | # computers to access the VM, whereas host only networking does not. 24 | # config.vm.forward_port "http", 80, 8080 25 | 26 | # Share an additional folder to the guest VM. The first argument is 27 | # an identifier, the second is the path on the guest to mount the 28 | # folder, and the third is the path on the host to the actual folder. 29 | # config.vm.share_folder "v-data", "/vagrant_data", "../data" 30 | 31 | # Enable provisioning with Puppet stand alone. Puppet manifests 32 | # are contained in a directory path relative to this Vagrantfile. 33 | # You will need to create the manifests directory and a manifest in 34 | # the file base.pp in the manifests_path directory. 35 | # 36 | # An example Puppet manifest to provision the message of the day: 37 | # 38 | # # File { owner => 0, group => 0, mode => 0644 } 39 | # # 40 | # # file { '/etc/motd': 41 | # # content => "Welcome to your Vagrant-built virtual machine! 42 | # # Managed by Puppet.\n" 43 | # # } 44 | # 45 | # config.vm.provision :puppet do |puppet| 46 | # puppet.manifests_path = "manifests" 47 | # puppet.manifest_file = "base.pp" 48 | # end 49 | 50 | # Enable provisioning with chef solo, specifying a cookbooks path (relative 51 | # to this Vagrantfile), and adding some recipes and/or roles. 52 | # 53 | config.vm.provision :chef_solo do |chef| 54 | chef.cookbooks_path = "cookbooks" 55 | chef.add_recipe "vagrant_main" 56 | chef.log_level = :debug 57 | # chef.add_recipe "mysql" 58 | # chef.add_role "web" 59 | # 60 | # # You may also specify custom JSON attributes: 61 | # chef.json.merge!({ :mysql_password => "foo" }) 62 | end 63 | 64 | # Enable provisioning with chef server, specifying the chef server URL, 65 | # and the path to the validation key (relative to this Vagrantfile). 66 | # 67 | # The Opscode Platform uses HTTPS. Substitute your organization for 68 | # ORGNAME in the URL and validation key. 69 | # 70 | # If you have your own Chef Server, use the appropriate URL, which may be 71 | # HTTP instead of HTTPS depending on your configuration. Also change the 72 | # validation key to validation.pem. 73 | # 74 | # config.vm.provision :chef_server do |chef| 75 | # chef.chef_server_url = "https://api.opscode.com/organizations/ORGNAME" 76 | # chef.validation_key_path = "ORGNAME-validator.pem" 77 | # end 78 | # 79 | # If you're using the Opscode platform, your validator client is 80 | # ORGNAME-validator, replacing ORGNAME with your organization name. 81 | # 82 | # IF you have your own Chef Server, the default validation client name is 83 | # chef-validator, unless you changed the configuration. 84 | # 85 | # chef.validation_client_name = "ORGNAME-validator" 86 | end -------------------------------------------------------------------------------- /cookbooks/java/recipes/openjdk.rb: -------------------------------------------------------------------------------- 1 | # Author:: Bryan W. Berry () 2 | # Author:: Seth Chisamore () 3 | # Cookbook Name:: java 4 | # Recipe:: openjdk 5 | # 6 | # Copyright 2010-2011, 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 | jdk_version = node['java']['jdk_version'].to_i 21 | java_home = node['java']['java_home'] 22 | java_home_parent = ::File.dirname java_home 23 | jdk_home = "" 24 | 25 | pkgs = value_for_platform( 26 | ["centos","redhat","fedora","scientific","amazon","oracle"] => { 27 | "default" => ["java-1.#{jdk_version}.0-openjdk","java-1.#{jdk_version}.0-openjdk-devel"] 28 | }, 29 | ["debian","ubuntu"] => { 30 | "default" => ["openjdk-#{jdk_version}-jdk","default-jre-headless"] 31 | }, 32 | ["arch","freebsd"] => { 33 | "default" => ["openjdk#{jdk_version}"] 34 | }, 35 | "default" => ["openjdk-#{jdk_version}-jdk"] 36 | ) 37 | 38 | # done by special request for rberger 39 | ruby_block "set-env-java-home" do 40 | block do 41 | ENV["JAVA_HOME"] = java_home 42 | end 43 | not_if { ENV["JAVA_HOME"] == java_home } 44 | end 45 | 46 | file "/etc/profile.d/jdk.sh" do 47 | content <<-EOS 48 | export JAVA_HOME=#{node['java']['java_home']} 49 | EOS 50 | mode 0755 51 | end 52 | 53 | 54 | if platform?("ubuntu","debian","redhat","centos","fedora","scientific","amazon","oracle") 55 | ruby_block "update-java-alternatives" do 56 | block do 57 | arch = node['kernel']['machine'] =~ /x86_64/ ? "x86_64" : "i386" 58 | arch = 'amd64' if arch == 'x86_64' && platform?("ubuntu") && node["platform_version"].to_f >= 12.04 59 | if platform?("ubuntu", "debian") and jdk_version == 6 60 | java_name = if node["platform_version"].to_f >= 11.10 61 | "java-1.6.0-openjdk" 62 | else 63 | "java-6-openjdk" 64 | end 65 | java_name += "-i386" if arch == "i386" && node['platform_version'].to_f >= 12.04 66 | Chef::ShellOut.new("update-java-alternatives","-s", java_name, :returns => [0,2]).run_command 67 | else 68 | # have to do this on ubuntu for version 7 because Ubuntu does 69 | # not currently set jdk 7 as the default jvm on installation 70 | require "fileutils" 71 | Chef::Log.debug("glob is #{java_home_parent}/java*#{jdk_version}*openjdk*#{arch}") 72 | jdk_home = Dir.glob("#{java_home_parent}/java*#{jdk_version}*openjdk*#{arch}").first 73 | Chef::Log.debug("jdk_home is #{jdk_home}") 74 | if jdk_home 75 | FileUtils.rm_f java_home if ::File.exists? java_home 76 | FileUtils.ln_sf jdk_home, java_home 77 | end 78 | 79 | cmd = Chef::ShellOut.new( 80 | %Q[ update-alternatives --install /usr/bin/java java #{java_home}/bin/java 1; 81 | update-alternatives --set java #{java_home}/bin/java ] 82 | ).run_command 83 | unless cmd.exitstatus == 0 or cmd.exitstatus == 2 84 | Chef::Application.fatal!("Failed to update-alternatives for openjdk!") 85 | end 86 | end 87 | end 88 | action :nothing 89 | end 90 | end 91 | 92 | pkgs.each do |pkg| 93 | package pkg do 94 | action :install 95 | notifies :create, "ruby_block[update-java-alternatives]", :immediately if platform?("ubuntu","debian","redhat","centos","fedora","scientific","amazon","oracle") 96 | end 97 | end 98 | -------------------------------------------------------------------------------- /cookbooks/mysql/recipes/server.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: mysql 3 | # Recipe:: default 4 | # 5 | # Copyright 2008-2011, 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::Recipe.send(:include, Opscode::OpenSSL::Password) 21 | 22 | include_recipe "mysql::client" 23 | 24 | # generate all passwords 25 | node.set_unless['mysql']['server_debian_password'] = secure_password 26 | node.set_unless['mysql']['server_root_password'] = secure_password 27 | node.set_unless['mysql']['server_repl_password'] = secure_password 28 | 29 | if platform?(%w{debian ubuntu}) 30 | 31 | directory "/var/cache/local/preseeding" do 32 | owner "root" 33 | group "root" 34 | mode 0755 35 | recursive true 36 | end 37 | 38 | execute "preseed mysql-server" do 39 | command "debconf-set-selections /var/cache/local/preseeding/mysql-server.seed" 40 | action :nothing 41 | end 42 | 43 | template "/var/cache/local/preseeding/mysql-server.seed" do 44 | source "mysql-server.seed.erb" 45 | owner "root" 46 | group "root" 47 | mode "0600" 48 | notifies :run, resources(:execute => "preseed mysql-server"), :immediately 49 | end 50 | 51 | template "#{node['mysql']['conf_dir']}/debian.cnf" do 52 | source "debian.cnf.erb" 53 | owner "root" 54 | group "root" 55 | mode "0600" 56 | end 57 | 58 | end 59 | 60 | package "mysql-server" do 61 | action :install 62 | end 63 | 64 | service "mysql" do 65 | service_name value_for_platform([ "centos", "redhat", "suse", "fedora" ] => {"default" => "mysqld"}, "default" => "mysql") 66 | if (platform?("ubuntu") && node.platform_version.to_f >= 10.04) 67 | restart_command "restart mysql" 68 | stop_command "stop mysql" 69 | start_command "start mysql" 70 | end 71 | supports :status => true, :restart => true, :reload => true 72 | action :nothing 73 | end 74 | 75 | template "#{node['mysql']['conf_dir']}/my.cnf" do 76 | source "my.cnf.erb" 77 | owner "root" 78 | group "root" 79 | mode "0644" 80 | notifies :restart, resources(:service => "mysql"), :immediately 81 | end 82 | 83 | unless Chef::Config[:solo] 84 | ruby_block "save node data" do 85 | block do 86 | node.save 87 | end 88 | action :create 89 | end 90 | end 91 | 92 | # set the root password on platforms 93 | # that don't support pre-seeding 94 | unless platform?(%w{debian ubuntu}) 95 | 96 | execute "assign-root-password" do 97 | command "/usr/bin/mysqladmin -u root password \"#{node['mysql']['server_root_password']}\"" 98 | action :run 99 | only_if "/usr/bin/mysql -u root -e 'show databases;'" 100 | end 101 | 102 | end 103 | 104 | grants_path = "#{node['mysql']['conf_dir']}/mysql_grants.sql" 105 | 106 | begin 107 | t = resources("template[#{grants_path}]") 108 | rescue 109 | Chef::Log.info("Could not find previously defined grants.sql resource") 110 | t = template grants_path do 111 | source "grants.sql.erb" 112 | owner "root" 113 | group "root" 114 | mode "0600" 115 | action :create 116 | end 117 | end 118 | 119 | execute "mysql-install-privileges" do 120 | command "/usr/bin/mysql -u root #{node['mysql']['server_root_password'].empty? ? '' : '-p' }#{node['mysql']['server_root_password']} < #{grants_path}" 121 | action :nothing 122 | subscribes :run, resources("template[#{grants_path}]"), :immediately 123 | end 124 | -------------------------------------------------------------------------------- /cookbooks/java/attributes/default.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Author:: Seth Chisamore () 3 | # Cookbook Name:: java 4 | # Attributes:: default 5 | # 6 | # Copyright 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 | # remove the deprecated Ubuntu jdk packages 21 | default['java']['remove_deprecated_packages'] = false 22 | 23 | # default jdk attributes 24 | default['java']['install_flavor'] = "openjdk" 25 | default['java']['jdk_version'] = '6' 26 | default['java']['arch'] = kernel['machine'] =~ /x86_64/ ? "x86_64" : "i586" 27 | 28 | case platform 29 | when "centos","redhat","fedora","scientific","amazon","oracle" 30 | default['java']['java_home'] = "/usr/lib/jvm/java" 31 | when "freebsd" 32 | default['java']['java_home'] = "/usr/local/openjdk#{java['jdk_version']}" 33 | when "arch" 34 | default['java']['java_home'] = "/usr/lib/jvm/java-#{java['jdk_version']}-openjdk" 35 | when "windows" 36 | default['java']['install_flavor'] = "windows" 37 | default['java']['windows']['url'] = nil 38 | default['java']['windows']['package_name'] = "Java(TM) SE Development Kit 7 (64-bit)" 39 | else 40 | default['java']['java_home'] = "/usr/lib/jvm/default-java" 41 | end 42 | 43 | # if you change this to true, you can download directly from Oracle 44 | default['java']['oracle']['accept_oracle_download_terms'] = false 45 | 46 | # direct download paths for oracle, you have been warned! 47 | 48 | # jdk6 attributes 49 | default['java']['jdk']['6']['bin_cmds'] = [ "appletviewer", "apt", "ControlPanel", "extcheck", "HtmlConverter", "idlj", "jar", "jarsigner", 50 | "java", "javac", "javadoc", "javah", "javap", "javaws", "jconsole", "jcontrol", "jdb", "jhat", 51 | "jinfo", "jmap", "jps", "jrunscript", "jsadebugd", "jstack", "jstat", "jstatd", "jvisualvm", 52 | "keytool", "native2ascii", "orbd", "pack200", "policytool", "rmic", "rmid", "rmiregistry", 53 | "schemagen", "serialver", "servertool", "tnameserv", "unpack200", "wsgen", "wsimport", "xjc" ] 54 | 55 | # x86_64 56 | default['java']['jdk']['6']['x86_64']['url'] = 'http://download.oracle.com/otn-pub/java/jdk/6u38-b05/jdk-6u38-linux-x64.bin' 57 | default['java']['jdk']['6']['x86_64']['checksum'] = '0a14ef5e60a90cf6de38e0b7744045b4c5eaf9513a7174c8e6d93f21358fd799' 58 | 59 | # i586 60 | default['java']['jdk']['6']['i586']['url'] = 'http://download.oracle.com/otn-pub/java/jdk/6u38-b05/jdk-6u38-linux-i586.bin' 61 | default['java']['jdk']['6']['i586']['checksum'] = '34b698c3f27f961c092cd982843a890fccf1ce1f9928c7e53333527dd60a63b0' 62 | 63 | # jdk7 attributes 64 | 65 | default['java']['jdk']['7']['bin_cmds'] = [ "appletviewer", "apt", "ControlPanel", "extcheck", "idlj", "jar", "jarsigner", "java", "javac", 66 | "javadoc", "javafxpackager", "javah", "javap", "javaws", "jcmd", "jconsole", "jcontrol", "jdb", 67 | "jhat", "jinfo", "jmap", "jps", "jrunscript", "jsadebugd", "jstack", "jstat", "jstatd", "jvisualvm", 68 | "keytool", "native2ascii", "orbd", "pack200", "policytool", "rmic", "rmid", "rmiregistry", 69 | "schemagen", "serialver", "servertool", "tnameserv", "unpack200", "wsgen", "wsimport", "xjc" ] 70 | 71 | # x86_64 72 | default['java']['jdk']['7']['x86_64']['url'] = 'http://download.oracle.com/otn-pub/java/jdk/7u11-b21/jdk-7u11-linux-x64.tar.gz' 73 | default['java']['jdk']['7']['x86_64']['checksum'] = '8ae77f5fd43e72dc87135af1c4ee2e294bd6debcec00778509519e0d1f8e5c35' 74 | 75 | # i586 76 | default['java']['jdk']['7']['i586']['url'] = 'http://download.oracle.com/otn-pub/java/jdk/7u11-b21/jdk-7u11-linux-i586.tar.gz' 77 | default['java']['jdk']['7']['i586']['checksum'] = '7f8efcbba7d32236a1a9858660ae4e42e32510a487cebffbcf934999deb53d35' 78 | -------------------------------------------------------------------------------- /cookbooks/apt/providers/repository.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: apt 3 | # Provider:: repository 4 | # 5 | # Copyright 2010-2011, 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 | def whyrun_supported? 21 | true 22 | end 23 | 24 | # install apt key from keyserver 25 | def install_key_from_keyserver(key, keyserver) 26 | execute "install-key #{key}" do 27 | if !node['apt']['key_proxy'].empty? 28 | command "apt-key adv --keyserver-options http-proxy=#{node['apt']['key_proxy']} --keyserver #{keyserver} --recv #{key}" 29 | else 30 | command "apt-key adv --keyserver #{keyserver} --recv #{key}" 31 | end 32 | action :run 33 | not_if "apt-key list | grep #{key}" 34 | end 35 | end 36 | 37 | # run command and extract gpg ids 38 | def extract_gpg_ids_from_cmd(cmd) 39 | so = Mixlib::ShellOut.new(cmd) 40 | so.run_command 41 | so.stdout.split(/\n/).collect do |t| 42 | if z = t.match(/^pub\s+\d+\w\/([0-9A-F]{8})/) 43 | z[1] 44 | end 45 | end.compact 46 | end 47 | 48 | # install apt key from URI 49 | def install_key_from_uri(uri) 50 | key_name = uri.split(/\//).last 51 | cached_keyfile = "#{Chef::Config[:file_cache_path]}/#{key_name}" 52 | if new_resource.key =~ /http/ 53 | remote_file cached_keyfile do 54 | source new_resource.key 55 | mode 00644 56 | action :create 57 | end 58 | else 59 | cookbook_file cached_keyfile do 60 | source new_resource.key 61 | cookbook new_resource.cookbook 62 | mode 00644 63 | action :create 64 | end 65 | end 66 | 67 | execute "install-key #{key_name}" do 68 | command "apt-key add #{cached_keyfile}" 69 | action :run 70 | not_if do 71 | installed_ids = extract_gpg_ids_from_cmd("apt-key finger") 72 | key_ids = extract_gpg_ids_from_cmd("gpg --with-fingerprint #{cached_keyfile}") 73 | (installed_ids & key_ids).sort == key_ids.sort 74 | end 75 | end 76 | end 77 | 78 | # build repo file contents 79 | def build_repo(uri, distribution, components, arch, add_deb_src) 80 | components = components.join(' ') if components.respond_to?(:join) 81 | repo_info = "#{uri} #{distribution} #{components}\n" 82 | repo_info = "[arch=#{arch}] #{repo_info}" if arch 83 | repo = "deb #{repo_info}" 84 | repo << "deb-src #{repo_info}" if add_deb_src 85 | repo 86 | end 87 | 88 | action :add do 89 | new_resource.updated_by_last_action(false) 90 | @repo_file = nil 91 | 92 | recipe_eval do 93 | # add key 94 | if new_resource.keyserver && new_resource.key 95 | install_key_from_keyserver(new_resource.key, new_resource.keyserver) 96 | elsif new_resource.key 97 | install_key_from_uri(new_resource.key) 98 | end 99 | 100 | file "/var/lib/apt/periodic/update-success-stamp" do 101 | action :nothing 102 | end 103 | 104 | execute "apt-get update" do 105 | ignore_failure true 106 | action :nothing 107 | end 108 | 109 | # build repo file 110 | repository = build_repo(new_resource.uri, 111 | new_resource.distribution, 112 | new_resource.components, 113 | new_resource.arch, 114 | new_resource.deb_src) 115 | 116 | @repo_file = file "/etc/apt/sources.list.d/#{new_resource.name}.list" do 117 | owner "root" 118 | group "root" 119 | mode 00644 120 | content repository 121 | action :create 122 | notifies :delete, "file[/var/lib/apt/periodic/update-success-stamp]", :immediately 123 | notifies :run, "execute[apt-get update]", :immediately if new_resource.cache_rebuild 124 | end 125 | end 126 | 127 | raise RuntimeError, "The repository file to create is nil, cannot continue." if @repo_file.nil? 128 | new_resource.updated_by_last_action(@repo_file.updated?) 129 | end 130 | 131 | action :remove do 132 | if ::File.exists?("/etc/apt/sources.list.d/#{new_resource.name}.list") 133 | Chef::Log.info "Removing #{new_resource.name} repository from /etc/apt/sources.list.d/" 134 | file "/etc/apt/sources.list.d/#{new_resource.name}.list" do 135 | action :delete 136 | end 137 | end 138 | end 139 | -------------------------------------------------------------------------------- /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 = <%= node['mysql']['socket'] %> 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 = <%= node['mysql']['socket'] %> 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 = <%= node['mysql']['pid_file'] %> 48 | socket = <%= node['mysql']['socket'] %> 49 | port = 3306 50 | basedir = /usr 51 | datadir = <%= node['mysql']['data_dir'] %> 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 = 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 = <%= node['mysql']['tunable']['query_cache_limit'] %> 83 | query_cache_size = <%= node['mysql']['tunable']['query_cache_size'] %> 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 = <%= node['mysql']['tunable']['log_slow_queries'] %> 95 | long_query_time = <%= node['mysql']['tunable']['long_query_time'] %> 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 = <%= node['mysql']['tunable']['expire_logs_days'] %> 104 | max_binlog_size = <%= node['mysql']['tunable']['max_binlog_size'] %> 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 | innodb_buffer_pool_size = <%= node['mysql']['tunable']['innodb_buffer_pool_size'] %> 115 | 116 | <% case node['platform'] -%> 117 | <% when "centos", "redhat", "fedora", "ubuntu" -%> 118 | # 119 | # * Federated 120 | # 121 | # The FEDERATED storage engine is disabled since 5.0.67 by default in the .cnf files 122 | # shipped with MySQL distributions (my-huge.cnf, my-medium.cnf, and so forth). 123 | # 124 | skip-federated 125 | <% end %> 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 = <%= node['mysql']['tunable']['max_allowed_packet'] %> 142 | 143 | [mysql] 144 | #no-auto-rehash # faster start of mysql but no tab completition 145 | 146 | [isamchk] 147 | key_buffer = <%= node['mysql']['tunable']['max_allowed_packet'] %> 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 | <% case node['platform'] -%> 161 | <% when "centos", "redhat", "fedora", "suse" -%> 162 | # 163 | # * BerkeleyDB 164 | # 165 | # Using BerkeleyDB is now discouraged as its support will cease in 5.1.12. 166 | skip-bdb 167 | # Default to using old password format for compatibility with mysql 3.x 168 | # clients (those using the mysqlclient10 compatibility package). 169 | old_passwords = <%= node['mysql']['old_passwords'] %> 170 | 171 | <% else -%> 172 | # 173 | # * IMPORTANT: Additional settings that can override those from this file! 174 | # The files must end with '.cnf', otherwise they'll be ignored. 175 | # 176 | !includedir /etc/mysql/conf.d/ 177 | <% end -%> 178 | -------------------------------------------------------------------------------- /cookbooks/mysql/README.md: -------------------------------------------------------------------------------- 1 | Description 2 | =========== 3 | 4 | Installs and configures MySQL client or server. 5 | 6 | Requirements 7 | ============ 8 | 9 | Platform 10 | -------- 11 | 12 | * Debian, Ubuntu 13 | * CentOS, Red Hat, Fedora 14 | 15 | Tested on: 16 | 17 | * Debian 5.0 18 | * Ubuntu 10.04 19 | * CentOS 5.5 20 | 21 | Cookbooks 22 | --------- 23 | 24 | Requires Opscode's openssl cookbook for secure password generation. 25 | 26 | 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. 27 | 28 | Resources and Providers 29 | ======================= 30 | 31 | 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: 32 | 33 | * `flush_tables_with_read_lock` - sends the sql command "flush tables with read lock", used for setting up mysql master/slave replication. 34 | * `unflush_tables` - sends the sql command "unflush tables", used for setting up master/slave replication. 35 | * `create_db` - specify a database to be created. 36 | * `query` - send an arbitrary query to the database, this should be used with care. Pass the SQL statement to use with the `sql` resource attribute. 37 | 38 | For example see the USAGE section below. 39 | 40 | Attributes 41 | ========== 42 | 43 | * `mysql['server_root_password']` - Set the server's root password with this, default is a randomly generated password with `OpenSSL::Random.random_bytes`. 44 | * `mysql['server_repl_password']` - Set the replication user 'repl' password with this, default is a randomly generated password with `OpenSSL::Random.random_bytes`. 45 | * `mysql['server_debian_password']` - Set the debian-sys-maint user password with this, default is a randomly generated password with `OpenSSL::Random.random_bytes`. 46 | * `mysql['bind_address']` - Listen address for MySQLd, default is node's ipaddress. 47 | * `mysql['data_dir']` - Location for mysql data directory, default is "/var/lib/mysql" 48 | * `mysql['conf_dir']` - Location for mysql conf directory, default is "/etc/mysql" 49 | * `mysql['ec2_path']` - location of mysql data_dir on EC2 nodes, default "/mnt/mysql" 50 | 51 | Performance tuning attributes, each corresponds to the same-named parameter in my.cnf; default values listed 52 | 53 | * `mysql['tunable']['key_buffer']` = "250M" 54 | * `mysql['tunable']['max_connections']` = "800" 55 | * `mysql['tunable']['wait_timeout']` = "180" 56 | * `mysql['tunable']['net_write_timeout']` = "30" 57 | * `mysql['tunable']['net_write_timeout']` = "30" 58 | * `mysql['tunable']['back_log']` = "128" 59 | * `mysql['tunable']['table_cache']` = "128" 60 | * `mysql['tunable']['max_heap_table_size']` = "32M" 61 | * `mysql['tunable']['expire_logs_days']` = "10" 62 | * `mysql['tunable']['max_binlog_size']` = "100M" 63 | 64 | Usage 65 | ===== 66 | 67 | On client nodes, 68 | 69 | include_recipe "mysql::client" 70 | 71 | 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. On platforms that are known to have a native package (currently Debian, Ubuntu, Red hat, Centos, Fedora and SUSE), the package will be installed. Other platforms will use the RubyGem. 72 | 73 | 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: 74 | 75 | mysql_database "create application_production database" do 76 | host "localhost" 77 | username "root" 78 | password node[:mysql][:server_root_password] 79 | database "application_production" 80 | action :create_db 81 | end 82 | 83 | 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. 84 | 85 | On server nodes, 86 | 87 | include_recipe "mysql::server" 88 | 89 | 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. 90 | 91 | On EC2 nodes, 92 | 93 | include_recipe "mysql::server_ec2" 94 | 95 | When the `ec2_path` doesn't exist we look for a mounted filesystem (eg, EBS) and move the data_dir there. 96 | 97 | The client recipe is already included by server and 'default' recipes. 98 | 99 | For more infromation on the compile vs execution phase of a Chef run: 100 | 101 | * http://wiki.opscode.com/display/chef/Anatomy+of+a+Chef+Run 102 | 103 | Changes/Roadmap 104 | =============== 105 | 106 | ### v1.0.8: 107 | 108 | * [COOK-633] ensure "cloud" attribute is available 109 | 110 | ### v1.0.7: 111 | 112 | * [COOK-614] expose all mysql tunable settings in config 113 | * [COOK-617] bind to private IP if available 114 | 115 | ### v1.0.6: 116 | 117 | * [COOK-605] install mysql-client package on ubuntu/debian 118 | 119 | ### v1.0.5: 120 | 121 | * [COOK-465] allow optional remote root connections to mysql 122 | * [COOK-455] improve platform version handling 123 | * externalize conf_dir attribute for easier cross platform support 124 | * change datadir attribute to data_dir for consistency 125 | 126 | ### v1.0.4: 127 | 128 | * fix regressions on debian platform 129 | * [COOK-578] wrap root password in quotes 130 | * [COOK-562] expose all tunables in my.cnf 131 | 132 | 133 | License and Author 134 | ================== 135 | 136 | Author:: Joshua Timberman () 137 | Author:: AJ Christensen () 138 | Author:: Seth Chisamore () 139 | 140 | Copyright:: 2009-2011 Opscode, Inc 141 | 142 | Licensed under the Apache License, Version 2.0 (the "License"); 143 | you may not use this file except in compliance with the License. 144 | You may obtain a copy of the License at 145 | 146 | http://www.apache.org/licenses/LICENSE-2.0 147 | 148 | Unless required by applicable law or agreed to in writing, software 149 | distributed under the License is distributed on an "AS IS" BASIS, 150 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 151 | See the License for the specific language governing permissions and 152 | limitations under the License. 153 | -------------------------------------------------------------------------------- /cookbooks/java/README.md: -------------------------------------------------------------------------------- 1 | Description 2 | =========== 3 | 4 | Installs a Java. Uses OpenJDK by default but supports installation of Oracle's JDK. 5 | 6 | This cookbook contains the `java_ark` LWPR which has been deprecated 7 | in favor of [ark](https://github.com/opscode-cookbooks/ark). 8 | 9 | **IMPORTANT NOTE** 10 | 11 | As of 26 March 2012 you can no longer directly download 12 | the JDK from Oracle's website without using a special cookie. This cookbook uses 13 | that cookie to download the oracle recipe on your behalf, but . . . 14 | 15 | the java::oracle recipe forces you to set either override 16 | the `node['java']['oracle']['accept_oracle_download_terms']` to true or set up a 17 | private repository accessible by HTTP. 18 | 19 | Example 20 | 21 | ### override the `accept_oracle_download_terms` 22 | 23 | roles/base.rb 24 | This cookbook also provides the `java_ark` LWRP which other java 25 | cookbooks can use to install java-related applications from binary 26 | packages. 27 | 28 | default_attributes( 29 | :java => { 30 | :oracle => { 31 | "accept_oracle_download_terms" => true 32 | } 33 | } 34 | ) 35 | 36 | You are most encouraged to voice your complaints to Oracle and/or 37 | switch to OpenJDK. 38 | 39 | Requirements 40 | ============ 41 | 42 | Platform 43 | -------- 44 | 45 | * Debian, Ubuntu 46 | * CentOS, Red Hat, Fedora, Scientific, Amazon 47 | * ArchLinux 48 | * FreeBSD 49 | * Windows 50 | 51 | Attributes 52 | ========== 53 | 54 | See `attributes/default.rb` for default values. 55 | 56 | * `node["java"]["install_flavor"]` - Flavor of JVM you would like installed (`oracle` or 57 | `openjdk`), default `openjdk`. 58 | * `node['java']['java_home']` - Default location of the "`$JAVA_HOME`". 59 | * `node['java']['tarball']` - Name of the tarball to retrieve from your corporate 60 | repository default `jdk1.6.0_29_i386.tar.gz` 61 | * `node['java']['tarball_checksum']` - Checksum for the tarball, if you use a different 62 | tarball, you also need to create a new sha256 checksum 63 | * `node['java']['jdk']` - Version and architecture specific attributes for setting the 64 | URL on Oracle's site for the JDK, and the checksum of the .tar.gz. 65 | * `node['java']['remove_deprecated_packages']` - Removes the now deprecated Ubuntu JDK 66 | packages from the system, default `false` 67 | * `node['java']['oracle']['accept_oracle_download_terms']` - Indicates that you accept 68 | Oracle's EULA 69 | * `node['java']['windows']['url']` - The internal location of your java install for windows 70 | * `node['java']['windows']['package_name']` - The package name used by windows_package to 71 | check in the registry to determine if the install has already been run 72 | 73 | Recipes 74 | ======= 75 | 76 | default 77 | ------- 78 | 79 | Include the default recipe in a run list, to get `java`. By default 80 | the `openjdk` flavor of Java is installed, but this can be changed by 81 | using the `install_flavor` attribute. If the platform is windows it 82 | will include the windows recipe instead. 83 | 84 | OpenJDK is the default because of licensing changes made upstream by 85 | Oracle. See notes on the `oracle` recipe below. 86 | 87 | openjdk 88 | ------- 89 | 90 | This recipe installs the `openjdk` flavor of Java. 91 | 92 | oracle 93 | ------ 94 | 95 | This recipe installs the `oracle` flavor of Java. This recipe does not 96 | use distribution packages as Oracle changed the licensing terms with 97 | JDK 1.6u27 and prohibited the practice for both the debian and EL worlds. 98 | 99 | For both debian and centos/rhel, this recipe pulls the binary 100 | distribution from the Oracle website, and installs it in the default 101 | JAVA_HOME for each distribution. For debian/ubuntu, this is 102 | /usr/lib/jvm/default-java. For Centos/RHEL, this is /usr/lib/jvm/java 103 | 104 | After putting the binaries in place, the oracle recipe updates 105 | /usr/bin/java to point to the installed JDK using the 106 | `update-alternatives` script 107 | 108 | oracle_i386 109 | ----------- 110 | 111 | This recipe installs the 32-bit Java virtual machine without setting 112 | it as the default. This can be useful if you have applications on the 113 | same machine that require different versions of the JVM. 114 | 115 | windows 116 | ------- 117 | 118 | Because there is no easy way to pull the java msi off oracle's site, 119 | this recipe requires you to host it internally on your own http repo. 120 | 121 | Resources/Providers 122 | =================== 123 | 124 | This cookbook contains the `java_ark` LWPR which has been deprecated 125 | in favor of [ark](https://github.com/opscode-cookbooks/ark). 126 | 127 | By default, the extracted directory is extracted to 128 | `app_root/extracted_dir_name` and symlinked to `app_root/default` 129 | 130 | # Actions 131 | 132 | - `:install`: extracts the tarball and makes necessary symlinks 133 | - `:remove`: removes the tarball and run update-alternatives for all 134 | symlinked `bin_cmds` 135 | 136 | # Attribute Parameters 137 | 138 | - `url`: path to tarball, .tar.gz, .bin (oracle-specific), and .zip 139 | currently supported 140 | - `checksum`: sha256 checksum, not used for security but avoid 141 | redownloading the archive on each chef-client run 142 | - `app_home`: the default for installations of this type of 143 | application, for example, `/usr/lib/tomcat/default`. If your 144 | application is not set to the default, it will be placed at the same 145 | level in the directory hierarchy but the directory name will be 146 | `app_root/extracted_directory_name + "_alt"` 147 | - `app_home_mode`: file mode for app_home, is an integer 148 | - `bin_cmds`: array of binary commands that should be symlinked to 149 | /usr/bin, examples are mvn, java, javac, etc. These cmds must be in 150 | the bin/ subdirectory of the extracted folder. Will be ignored if this 151 | java_ark is not the default 152 | - `owner`: owner of extracted directory, set to "root" by default 153 | - `default`: whether this the default installation of this package, 154 | boolean true or false 155 | 156 | 157 | # Examples 158 | 159 | # install jdk6 from Oracle 160 | java_ark "jdk" do 161 | url 'http://download.oracle.com/otn-pub/java/jdk/6u29-b11/jdk-6u29-linux-x64.bin' 162 | checksum 'a8603fa62045ce2164b26f7c04859cd548ffe0e33bfc979d9fa73df42e3b3365' 163 | app_home '/usr/local/java/default' 164 | bin_cmds ["java", "javac"] 165 | action :install 166 | end 167 | 168 | 169 | Usage 170 | ===== 171 | 172 | Simply include the `java` recipe where ever you would like Java installed. 173 | 174 | To install Oracle flavored Java on Debian or Ubuntu override the `node['java']['install_flavor']` attribute with in role: 175 | 176 | name "java" 177 | description "Install Oracle Java on Ubuntu" 178 | override_attributes( 179 | "java" => { 180 | "install_flavor" => "oracle" 181 | } 182 | ) 183 | run_list( 184 | "recipe[java]" 185 | ) 186 | 187 | Development 188 | =========== 189 | 190 | This cookbook uses 191 | [test-kitchen](https://github.com/opscode/test-kitchen) for 192 | integration tests. Pull requests should pass existing tests in 193 | files/default/tests/minitest-handler. Additional tests are always welcome. 194 | 195 | License and Author 196 | ================== 197 | 198 | Author:: Seth Chisamore () 199 | Author:: Bryan W. Berry () 200 | 201 | Copyright:: 2008-2012, Opscode, Inc 202 | 203 | Licensed under the Apache License, Version 2.0 (the "License"); 204 | you may not use this file except in compliance with the License. 205 | You may obtain a copy of the License at 206 | 207 | http://www.apache.org/licenses/LICENSE-2.0 208 | 209 | Unless required by applicable law or agreed to in writing, software 210 | distributed under the License is distributed on an "AS IS" BASIS, 211 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 212 | See the License for the specific language governing permissions and 213 | limitations under the License. 214 | -------------------------------------------------------------------------------- /cookbooks/java/metadata.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "java", 3 | "description": "Installs Java runtime.", 4 | "long_description": "Description\n===========\n\nInstalls a Java. Uses OpenJDK by default but supports installation of Oracle's JDK.\n\nThis cookbook contains the `java_ark` LWPR which has been deprecated\nin favor of [ark](https://github.com/opscode-cookbooks/ark).\n\n**IMPORTANT NOTE**\n\nAs of 26 March 2012 you can no longer directly download\nthe JDK from Oracle's website without using a special cookie. This cookbook uses\nthat cookie to download the oracle recipe on your behalf, but . . .\n\nthe java::oracle recipe forces you to set either override\nthe `node['java']['oracle']['accept_oracle_download_terms']` to true or set up a\nprivate repository accessible by HTTP.\n\nExample\n\n### override the `accept_oracle_download_terms`\n\nroles/base.rb\nThis cookbook also provides the `java_ark` LWRP which other java\ncookbooks can use to install java-related applications from binary\npackages.\n\n default_attributes(\n :java => {\n :oracle => {\n \"accept_oracle_download_terms\" => true\n }\n }\n )\n\nYou are most encouraged to voice your complaints to Oracle and/or\nswitch to OpenJDK.\n\nRequirements\n============\n\nPlatform\n--------\n\n* Debian, Ubuntu\n* CentOS, Red Hat, Fedora, Scientific, Amazon\n* ArchLinux\n* FreeBSD\n* Windows\n\nAttributes\n==========\n\nSee `attributes/default.rb` for default values.\n\n* `node[\"java\"][\"install_flavor\"]` - Flavor of JVM you would like installed (`oracle` or\n`openjdk`), default `openjdk`.\n* `node['java']['java_home']` - Default location of the \"`$JAVA_HOME`\".\n* `node['java']['tarball']` - Name of the tarball to retrieve from your corporate\nrepository default `jdk1.6.0_29_i386.tar.gz`\n* `node['java']['tarball_checksum']` - Checksum for the tarball, if you use a different\ntarball, you also need to create a new sha256 checksum\n* `node['java']['jdk']` - Version and architecture specific attributes for setting the\nURL on Oracle's site for the JDK, and the checksum of the .tar.gz.\n* `node['java']['remove_deprecated_packages']` - Removes the now deprecated Ubuntu JDK\npackages from the system, default `false`\n* `node['java']['oracle']['accept_oracle_download_terms']` - Indicates that you accept\n Oracle's EULA\n* `node['java']['windows']['url']` - The internal location of your java install for windows\n* `node['java']['windows']['package_name']` - The package name used by windows_package to\n check in the registry to determine if the install has already been run\n\nRecipes\n=======\n\ndefault\n-------\n\nInclude the default recipe in a run list, to get `java`. By default\nthe `openjdk` flavor of Java is installed, but this can be changed by\nusing the `install_flavor` attribute. If the platform is windows it \nwill include the windows recipe instead.\n\nOpenJDK is the default because of licensing changes made upstream by\nOracle. See notes on the `oracle` recipe below.\n\nopenjdk\n-------\n\nThis recipe installs the `openjdk` flavor of Java.\n\noracle\n------\n\nThis recipe installs the `oracle` flavor of Java. This recipe does not\nuse distribution packages as Oracle changed the licensing terms with\nJDK 1.6u27 and prohibited the practice for both the debian and EL worlds.\n\nFor both debian and centos/rhel, this recipe pulls the binary\ndistribution from the Oracle website, and installs it in the default\nJAVA_HOME for each distribution. For debian/ubuntu, this is\n/usr/lib/jvm/default-java. For Centos/RHEL, this is /usr/lib/jvm/java\n\nAfter putting the binaries in place, the oracle recipe updates\n/usr/bin/java to point to the installed JDK using the\n`update-alternatives` script\n\noracle_i386\n-----------\n\nThis recipe installs the 32-bit Java virtual machine without setting\nit as the default. This can be useful if you have applications on the\nsame machine that require different versions of the JVM.\n\nwindows\n-------\n\nBecause there is no easy way to pull the java msi off oracle's site, \nthis recipe requires you to host it internally on your own http repo.\n\nResources/Providers\n===================\n\nThis cookbook contains the `java_ark` LWPR which has been deprecated\nin favor of [ark](https://github.com/opscode-cookbooks/ark).\n\nBy default, the extracted directory is extracted to\n`app_root/extracted_dir_name` and symlinked to `app_root/default`\n\n# Actions\n\n- `:install`: extracts the tarball and makes necessary symlinks\n- `:remove`: removes the tarball and run update-alternatives for all\n symlinked `bin_cmds`\n\n# Attribute Parameters\n\n- `url`: path to tarball, .tar.gz, .bin (oracle-specific), and .zip\n currently supported\n- `checksum`: sha256 checksum, not used for security but avoid\n redownloading the archive on each chef-client run\n- `app_home`: the default for installations of this type of\n application, for example, `/usr/lib/tomcat/default`. If your\n application is not set to the default, it will be placed at the same\n level in the directory hierarchy but the directory name will be\n `app_root/extracted_directory_name + \"_alt\"`\n- `app_home_mode`: file mode for app_home, is an integer\n- `bin_cmds`: array of binary commands that should be symlinked to\n /usr/bin, examples are mvn, java, javac, etc. These cmds must be in\n the bin/ subdirectory of the extracted folder. Will be ignored if this\n java_ark is not the default\n- `owner`: owner of extracted directory, set to \"root\" by default\n- `default`: whether this the default installation of this package,\n boolean true or false\n\n\n# Examples\n\n # install jdk6 from Oracle\n java_ark \"jdk\" do\n url 'http://download.oracle.com/otn-pub/java/jdk/6u29-b11/jdk-6u29-linux-x64.bin'\n checksum 'a8603fa62045ce2164b26f7c04859cd548ffe0e33bfc979d9fa73df42e3b3365'\n app_home '/usr/local/java/default'\n bin_cmds [\"java\", \"javac\"]\n action :install\n end\n\n\nUsage\n=====\n\nSimply include the `java` recipe where ever you would like Java installed.\n\nTo install Oracle flavored Java on Debian or Ubuntu override the `node['java']['install_flavor']` attribute with in role:\n\n name \"java\"\n description \"Install Oracle Java on Ubuntu\"\n override_attributes(\n \"java\" => {\n \"install_flavor\" => \"oracle\"\n }\n )\n run_list(\n \"recipe[java]\"\n )\n\nDevelopment\n===========\n\nThis cookbook uses\n[test-kitchen](https://github.com/opscode/test-kitchen) for\nintegration tests. Pull requests should pass existing tests in\nfiles/default/tests/minitest-handler. Additional tests are always welcome.\n\nLicense and Author\n==================\n\nAuthor:: Seth Chisamore ()\nAuthor:: Bryan W. Berry ()\n\nCopyright:: 2008-2012, 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": ">= 0.0.0", 10 | "ubuntu": ">= 0.0.0", 11 | "centos": ">= 0.0.0", 12 | "redhat": ">= 0.0.0", 13 | "scientific": ">= 0.0.0", 14 | "fedora": ">= 0.0.0", 15 | "amazon": ">= 0.0.0", 16 | "arch": ">= 0.0.0", 17 | "oracle": ">= 0.0.0", 18 | "freebsd": ">= 0.0.0", 19 | "windows": ">= 0.0.0" 20 | }, 21 | "dependencies": { 22 | "windows": ">= 0.0.0" 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 | "java": "Installs Java runtime", 40 | "java::openjdk": "Installs the OpenJDK flavor of Java", 41 | "java::oracle": "Installs the Oracle flavor of Java", 42 | "java::oracle_i386": "Installs the 32-bit jvm without setting it as the default" 43 | }, 44 | "version": "1.9.6" 45 | } -------------------------------------------------------------------------------- /cookbooks/apt/metadata.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "apt", 3 | "description": "Configures apt and apt services and LWRPs for managing apt repositories and preferences", 4 | "long_description": "Description\n===========\n\nThis cookbook includes recipes to execute apt-get update to ensure the\nlocal APT package cache is up to date. There are recipes for managing\nthe apt-cacher-ng caching proxy and proxy clients. It also includes a\nLWRP for managing APT repositories in /etc/apt/sources.list.d as well as\nan LWRP for pinning packages via /etc/apt/preferences.d.\n\nRequirements\n============\n\nVersion 1.8.2+ of this cookbook requires **Chef 10.16.4** or later.\n\nIf your Chef version is earlier than 10.16.4, use version 1.7.0 of\nthis cookbook.\n\nSee [CHEF-3493](http://tickets.opscode.com/browse/CHEF-3493) and\n[this code comment](http://bit.ly/VgvCgf) for more information on this\nrequirement.\n\nPlatform\n--------\n\n* Debian\n* Ubuntu\n\nMay work with or without modification on other Debian derivatives.\n\nRecipes\n=======\n\ndefault\n-------\n\nThis recipe installs the `update-notifier-common` package to provide\nthe timestamp file used to only run `apt-get update` if the cache is\nmore than one day old.\n\nThis recipe should appear first in the run list of Debian or Ubuntu\nnodes to ensure that the package cache is up to date before managing\nany `package` resources with Chef.\n\nThis recipe also sets up a local cache directory for preseeding packages.\n\ncacher-ng\n---------\n\nInstalls the `apt-cacher-ng` package and service so the system can\nprovide APT caching. You can check the usage report at\nhttp://{hostname}:3142/acng-report.html. The `cacher-ng` recipe\nincludes the `cacher-client` recipe, so it helps seed itself.\n\ncacher-client\n-------------\nConfigures the node to use the `apt-cacher-ng` server as a client. If you\nwant to restrict your node to using the `apt-cacher-ng` server in your\nEnvironment, set `['apt']['cacher-client']['restrict_environment']` to `true`.\nTo use a cacher server (or standard proxy server) not available via search\nset the atttribute `['apt']['cacher-ipaddress']` and for a custom port\nset `['apt']['cacher_port']`\n\nResources/Providers\n===================\n\nManaging repositories\n---------------------\n\nThis LWRP provides an easy way to manage additional APT repositories.\nAdding a new repository will notify running the `execute[apt-get-update]`\nresource immediately.\n\n# Actions\n\n- :add: creates a repository file and builds the repository listing\n- :remove: removes the repository file\n\n# Attribute Parameters\n\n- repo_name: name attribute. The name of the channel to discover\n- uri: the base of the Debian distribution\n- distribution: this is usually your release's codename...ie something\n like `karmic`, `lucid` or `maverick`\n- components: package groupings..when it doubt use `main`\n- arch: constrain package to a particular arch like `i386`, `amd64` or\n even `armhf` or `powerpc`. Defaults to nil.\n- deb_src: whether or not to add the repository as a source repo as\n well - value can be `true` or `false`, default `false`.\n- keyserver: the GPG keyserver where the key for the repo should be retrieved\n- key: if a `keyserver` is provided, this is assumed to be the\n fingerprint, otherwise it can be either the URI to the GPG key for\n the repo, or a cookbook_file.\n- key_proxy: if set, pass the specified proxy via `http-proxy=` to GPG.\n- cookbook: if key should be a cookbook_file, specify a cookbook where\n the key is located for files/default. Defaults to nil, so it will\n use the cookbook where the resource is used.\n\n# Examples\n\n # add the Zenoss repo\n apt_repository \"zenoss\" do\n uri \"http://dev.zenoss.org/deb\"\n components [\"main\",\"stable\"]\n end\n\n # add the Nginx PPA; grab key from keyserver\n apt_repository \"nginx-php\" do\n uri \"http://ppa.launchpad.net/nginx/php5/ubuntu\"\n distribution node['lsb']['codename']\n components [\"main\"]\n keyserver \"keyserver.ubuntu.com\"\n key \"C300EE8C\"\n end\n\n # add the Nginx PPA; grab key from keyserver, also add source repo\n apt_repository \"nginx-php\" do\n uri \"http://ppa.launchpad.net/nginx/php5/ubuntu\"\n distribution node['lsb']['codename']\n components [\"main\"]\n keyserver \"keyserver.ubuntu.com\"\n key \"C300EE8C\"\n deb_src true\n end\n\n # add the Cloudkick Repo\n apt_repository \"cloudkick\" do\n uri \"http://packages.cloudkick.com/ubuntu\"\n distribution node['lsb']['codename']\n components [\"main\"]\n key \"http://packages.cloudkick.com/cloudkick.packages.key\"\n end\n\n # add the Cloudkick Repo with the key downloaded in the cookbook\n apt_repository \"cloudkick\" do\n uri \"http://packages.cloudkick.com/ubuntu\"\n distribution node['lsb']['codename']\n components [\"main\"]\n key \"cloudkick.packages.key\"\n end\n\n # add the Cloudera Repo of CDH4 packages for Ubuntu 12.04 on AMD64\n apt_repository \"cloudera\" do\n uri \"http://archive.cloudera.com/cdh4/ubuntu/precise/amd64/cdh\"\n arch \"amd64\"\n distribution \"precise-cdh4\"\n components [\"contrib\"]\n key \"http://archive.cloudera.com/debian/archive.key\"\n end\n\n # remove Zenoss repo\n apt_repository \"zenoss\" do\n action :remove\n end\n\nPinning packages\n----------------\n\nThis LWRP provides an easy way to pin packages in /etc/apt/preferences.d.\nAlthough apt-pinning is quite helpful from time to time please note that Debian\ndoes not encourage its use without thorough consideration.\n\nFurther information regarding apt-pinning is available via\nhttp://wiki.debian.org/AptPreferences.\n\n# Actions\n\n- :add: creates a preferences file under /etc/apt/preferences.d\n- :remove: Removes the file, therefore unpin the package\n\n# Attribute Parameters\n\n- package_name: name attribute. The name of the package\n- glob: Pin by glob() expression or regexp surrounded by /.\n- pin: The package version/repository to pin\n- pin_priority: The pinning priority aka \"the highest package version wins\"\n\n# Examples\n\n # Pin libmysqlclient16 to version 5.1.49-3\n apt_preference \"libmysqlclient16\" do\n pin \"version 5.1.49-3\"\n pin_priority \"700\"\n end\n\n # Unpin libmysqlclient16\n apt_preference \"libmysqlclient16\" do\n action :remove\n end\n\n # Pin all packages from dotdeb.org\n apt_preference \"dotdeb\" do\n glob \"*\"\n pin \"origin packages.dotdeb.org \"\n pin_priority \"700\"\n end\n\nUsage\n=====\n\nPut `recipe[apt]` first in the run list. If you have other recipes\nthat you want to use to configure how apt behaves, like new sources,\nnotify the execute resource to run, e.g.:\n\n template \"/etc/apt/sources.list.d/my_apt_sources.list\" do\n notifies :run, resources(:execute => \"apt-get update\"), :immediately\n end\n\nThe above will run during execution phase since it is a normal\ntemplate resource, and should appear before other package resources\nthat need the sources in the template.\n\nPut `recipe[apt::cacher-ng]` in the run_list for a server to provide\nAPT caching and add `recipe[apt::cacher-client]` on the rest of the\nDebian-based nodes to take advantage of the caching server.\n\nIf you want to cleanup unused packages, there is also the `apt-get autoclean`\nand `apt-get autoremove` resources provided for automated cleanup.\n\nLicense and Author\n==================\n\nAuthor:: Joshua Timberman ()\nAuthor:: Matt Ray ()\nAuthor:: Seth Chisamore ()\n\nCopyright 2009-2012 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 | "ubuntu": ">= 0.0.0", 10 | "debian": ">= 0.0.0" 11 | }, 12 | "dependencies": { 13 | }, 14 | "recommendations": { 15 | }, 16 | "suggestions": { 17 | }, 18 | "conflicting": { 19 | }, 20 | "providing": { 21 | }, 22 | "replacing": { 23 | }, 24 | "attributes": { 25 | }, 26 | "groupings": { 27 | }, 28 | "recipes": { 29 | "apt": "Runs apt-get update during compile phase and sets up preseed directories", 30 | "apt::cacher-ng": "Set up an apt-cacher-ng caching proxy", 31 | "apt::cacher-client": "Client for the apt::cacher-ng caching proxy" 32 | }, 33 | "version": "1.9.0" 34 | } -------------------------------------------------------------------------------- /cookbooks/apt/README.md: -------------------------------------------------------------------------------- 1 | Description 2 | =========== 3 | 4 | This cookbook includes recipes to execute apt-get update to ensure the 5 | local APT package cache is up to date. There are recipes for managing 6 | the apt-cacher-ng caching proxy and proxy clients. It also includes a 7 | LWRP for managing APT repositories in /etc/apt/sources.list.d as well as 8 | an LWRP for pinning packages via /etc/apt/preferences.d. 9 | 10 | Requirements 11 | ============ 12 | 13 | Version 1.8.2+ of this cookbook requires **Chef 10.16.4** or later. 14 | 15 | If your Chef version is earlier than 10.16.4, use version 1.7.0 of 16 | this cookbook. 17 | 18 | See [CHEF-3493](http://tickets.opscode.com/browse/CHEF-3493) and 19 | [this code comment](http://bit.ly/VgvCgf) for more information on this 20 | requirement. 21 | 22 | Platform 23 | -------- 24 | 25 | * Debian 26 | * Ubuntu 27 | 28 | May work with or without modification on other Debian derivatives. 29 | 30 | Recipes 31 | ======= 32 | 33 | default 34 | ------- 35 | 36 | This recipe installs the `update-notifier-common` package to provide 37 | the timestamp file used to only run `apt-get update` if the cache is 38 | more than one day old. 39 | 40 | This recipe should appear first in the run list of Debian or Ubuntu 41 | nodes to ensure that the package cache is up to date before managing 42 | any `package` resources with Chef. 43 | 44 | This recipe also sets up a local cache directory for preseeding packages. 45 | 46 | cacher-ng 47 | --------- 48 | 49 | Installs the `apt-cacher-ng` package and service so the system can 50 | provide APT caching. You can check the usage report at 51 | http://{hostname}:3142/acng-report.html. The `cacher-ng` recipe 52 | includes the `cacher-client` recipe, so it helps seed itself. 53 | 54 | cacher-client 55 | ------------- 56 | Configures the node to use the `apt-cacher-ng` server as a client. If you 57 | want to restrict your node to using the `apt-cacher-ng` server in your 58 | Environment, set `['apt']['cacher-client']['restrict_environment']` to `true`. 59 | To use a cacher server (or standard proxy server) not available via search 60 | set the atttribute `['apt']['cacher-ipaddress']` and for a custom port 61 | set `['apt']['cacher_port']` 62 | 63 | Resources/Providers 64 | =================== 65 | 66 | Managing repositories 67 | --------------------- 68 | 69 | This LWRP provides an easy way to manage additional APT repositories. 70 | Adding a new repository will notify running the `execute[apt-get-update]` 71 | resource immediately. 72 | 73 | # Actions 74 | 75 | - :add: creates a repository file and builds the repository listing 76 | - :remove: removes the repository file 77 | 78 | # Attribute Parameters 79 | 80 | - repo_name: name attribute. The name of the channel to discover 81 | - uri: the base of the Debian distribution 82 | - distribution: this is usually your release's codename...ie something 83 | like `karmic`, `lucid` or `maverick` 84 | - components: package groupings..when it doubt use `main` 85 | - arch: constrain package to a particular arch like `i386`, `amd64` or 86 | even `armhf` or `powerpc`. Defaults to nil. 87 | - deb_src: whether or not to add the repository as a source repo as 88 | well - value can be `true` or `false`, default `false`. 89 | - keyserver: the GPG keyserver where the key for the repo should be retrieved 90 | - key: if a `keyserver` is provided, this is assumed to be the 91 | fingerprint, otherwise it can be either the URI to the GPG key for 92 | the repo, or a cookbook_file. 93 | - key_proxy: if set, pass the specified proxy via `http-proxy=` to GPG. 94 | - cookbook: if key should be a cookbook_file, specify a cookbook where 95 | the key is located for files/default. Defaults to nil, so it will 96 | use the cookbook where the resource is used. 97 | 98 | # Examples 99 | 100 | # add the Zenoss repo 101 | apt_repository "zenoss" do 102 | uri "http://dev.zenoss.org/deb" 103 | components ["main","stable"] 104 | end 105 | 106 | # add the Nginx PPA; grab key from keyserver 107 | apt_repository "nginx-php" do 108 | uri "http://ppa.launchpad.net/nginx/php5/ubuntu" 109 | distribution node['lsb']['codename'] 110 | components ["main"] 111 | keyserver "keyserver.ubuntu.com" 112 | key "C300EE8C" 113 | end 114 | 115 | # add the Nginx PPA; grab key from keyserver, also add source repo 116 | apt_repository "nginx-php" do 117 | uri "http://ppa.launchpad.net/nginx/php5/ubuntu" 118 | distribution node['lsb']['codename'] 119 | components ["main"] 120 | keyserver "keyserver.ubuntu.com" 121 | key "C300EE8C" 122 | deb_src true 123 | end 124 | 125 | # add the Cloudkick Repo 126 | apt_repository "cloudkick" do 127 | uri "http://packages.cloudkick.com/ubuntu" 128 | distribution node['lsb']['codename'] 129 | components ["main"] 130 | key "http://packages.cloudkick.com/cloudkick.packages.key" 131 | end 132 | 133 | # add the Cloudkick Repo with the key downloaded in the cookbook 134 | apt_repository "cloudkick" do 135 | uri "http://packages.cloudkick.com/ubuntu" 136 | distribution node['lsb']['codename'] 137 | components ["main"] 138 | key "cloudkick.packages.key" 139 | end 140 | 141 | # add the Cloudera Repo of CDH4 packages for Ubuntu 12.04 on AMD64 142 | apt_repository "cloudera" do 143 | uri "http://archive.cloudera.com/cdh4/ubuntu/precise/amd64/cdh" 144 | arch "amd64" 145 | distribution "precise-cdh4" 146 | components ["contrib"] 147 | key "http://archive.cloudera.com/debian/archive.key" 148 | end 149 | 150 | # remove Zenoss repo 151 | apt_repository "zenoss" do 152 | action :remove 153 | end 154 | 155 | Pinning packages 156 | ---------------- 157 | 158 | This LWRP provides an easy way to pin packages in /etc/apt/preferences.d. 159 | Although apt-pinning is quite helpful from time to time please note that Debian 160 | does not encourage its use without thorough consideration. 161 | 162 | Further information regarding apt-pinning is available via 163 | http://wiki.debian.org/AptPreferences. 164 | 165 | # Actions 166 | 167 | - :add: creates a preferences file under /etc/apt/preferences.d 168 | - :remove: Removes the file, therefore unpin the package 169 | 170 | # Attribute Parameters 171 | 172 | - package_name: name attribute. The name of the package 173 | - glob: Pin by glob() expression or regexp surrounded by /. 174 | - pin: The package version/repository to pin 175 | - pin_priority: The pinning priority aka "the highest package version wins" 176 | 177 | # Examples 178 | 179 | # Pin libmysqlclient16 to version 5.1.49-3 180 | apt_preference "libmysqlclient16" do 181 | pin "version 5.1.49-3" 182 | pin_priority "700" 183 | end 184 | 185 | # Unpin libmysqlclient16 186 | apt_preference "libmysqlclient16" do 187 | action :remove 188 | end 189 | 190 | # Pin all packages from dotdeb.org 191 | apt_preference "dotdeb" do 192 | glob "*" 193 | pin "origin packages.dotdeb.org " 194 | pin_priority "700" 195 | end 196 | 197 | Usage 198 | ===== 199 | 200 | Put `recipe[apt]` first in the run list. If you have other recipes 201 | that you want to use to configure how apt behaves, like new sources, 202 | notify the execute resource to run, e.g.: 203 | 204 | template "/etc/apt/sources.list.d/my_apt_sources.list" do 205 | notifies :run, resources(:execute => "apt-get update"), :immediately 206 | end 207 | 208 | The above will run during execution phase since it is a normal 209 | template resource, and should appear before other package resources 210 | that need the sources in the template. 211 | 212 | Put `recipe[apt::cacher-ng]` in the run_list for a server to provide 213 | APT caching and add `recipe[apt::cacher-client]` on the rest of the 214 | Debian-based nodes to take advantage of the caching server. 215 | 216 | If you want to cleanup unused packages, there is also the `apt-get autoclean` 217 | and `apt-get autoremove` resources provided for automated cleanup. 218 | 219 | License and Author 220 | ================== 221 | 222 | Author:: Joshua Timberman () 223 | Author:: Matt Ray () 224 | Author:: Seth Chisamore () 225 | 226 | Copyright 2009-2012 Opscode, Inc. 227 | 228 | Licensed under the Apache License, Version 2.0 (the "License"); 229 | you may not use this file except in compliance with the License. 230 | You may obtain a copy of the License at 231 | 232 | http://www.apache.org/licenses/LICENSE-2.0 233 | 234 | Unless required by applicable law or agreed to in writing, software 235 | distributed under the License is distributed on an "AS IS" BASIS, 236 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 237 | See the License for the specific language governing permissions and 238 | limitations under the License. 239 | -------------------------------------------------------------------------------- /cookbooks/java/providers/ark.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Author:: Bryan W. Berry () 3 | # Cookbook Name:: java 4 | # Provider:: ark 5 | # 6 | # Copyright 2011, Bryan w. Berry 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 | def whyrun_supported? 21 | true 22 | end 23 | 24 | def parse_app_dir_name url 25 | file_name = url.split('/')[-1] 26 | # funky logic to parse oracle's non-standard naming convention 27 | # for jdk1.6 28 | if file_name =~ /^(jre|jdk).*$/ 29 | major_num = file_name.scan(/\d/)[0] 30 | update_num = file_name.scan(/\d+/)[1] 31 | # pad a single digit number with a zero 32 | if update_num.length < 2 33 | update_num = "0" + update_num 34 | end 35 | package_name = file_name.scan(/[a-z]+/)[0] 36 | app_dir_name = "#{package_name}1.#{major_num}.0_#{update_num}" 37 | else 38 | app_dir_name = file_name.split(/(.tgz|.tar.gz|.zip)/)[0] 39 | app_dir_name = app_dir_name.split("-bin")[0] 40 | end 41 | [app_dir_name, file_name] 42 | end 43 | 44 | def oracle_downloaded?(download_path, new_resource) 45 | if ::File.exists? download_path 46 | require 'digest' 47 | downloaded_sha = Digest::SHA256.file(download_path).hexdigest 48 | downloaded_sha == new_resource.checksum 49 | else 50 | return false 51 | end 52 | end 53 | 54 | def download_direct_from_oracle(tarball_name, new_resource) 55 | download_path = "#{Chef::Config[:file_cache_path]}/#{tarball_name}" 56 | jdk_id = new_resource.url.scan(/\/([6789]u[0-9][0-9]?-b[0-9][0-9])\//)[0][0] 57 | cookie = "oraclelicensejdk-#{jdk_id}-oth-JPR=accept-securebackup-cookie;gpw_e24=http://edelivery.oracle.com" 58 | if node['java']['oracle']['accept_oracle_download_terms'] 59 | # install the curl package 60 | p = package "curl" do 61 | action :nothing 62 | end 63 | # no converge_by block since the package provider will take care of this run_action 64 | p.run_action(:install) 65 | description = "download oracle tarball straight from the server" 66 | converge_by(description) do 67 | Chef::Log.debug "downloading oracle tarball straight from the source" 68 | cmd = Chef::ShellOut.new( 69 | %Q[ curl -L --cookie "#{cookie}" #{new_resource.url} -o #{download_path} ] 70 | ) 71 | cmd.run_command 72 | cmd.error! 73 | end 74 | else 75 | Chef::Application.fatal!("You must set the attribute node['java']['oracle']['accept_oracle_download_terms'] to true if you want to download directly from the oracle site!") 76 | end 77 | end 78 | 79 | action :install do 80 | app_dir_name, tarball_name = parse_app_dir_name(new_resource.url) 81 | app_root = new_resource.app_home.split('/')[0..-2].join('/') 82 | app_dir = app_root + '/' + app_dir_name 83 | 84 | unless new_resource.default 85 | Chef::Log.debug("processing alternate jdk") 86 | app_dir = app_dir + "_alt" 87 | app_home = new_resource.app_home + "_alt" 88 | else 89 | app_home = new_resource.app_home 90 | end 91 | 92 | unless ::File.exists?(app_dir) 93 | Chef::Log.info "Adding #{new_resource.name} to #{app_dir}" 94 | require 'fileutils' 95 | 96 | unless ::File.exists?(app_root) 97 | description = "create dir #{app_root} and change owner to #{new_resource.owner}" 98 | converge_by(description) do 99 | FileUtils.mkdir app_root, :mode => new_resource.app_home_mode 100 | FileUtils.chown new_resource.owner, new_resource.owner, app_root 101 | end 102 | end 103 | 104 | if new_resource.url =~ /^http:\/\/download.oracle.com.*$/ 105 | download_path = "#{Chef::Config[:file_cache_path]}/#{tarball_name}" 106 | if oracle_downloaded?(download_path, new_resource) 107 | Chef::Log.debug("oracle tarball already downloaded, not downloading again") 108 | else 109 | download_direct_from_oracle tarball_name, new_resource 110 | end 111 | else 112 | Chef::Log.debug("downloading tarball from an unofficial repository") 113 | r = remote_file "#{Chef::Config[:file_cache_path]}/#{tarball_name}" do 114 | source new_resource.url 115 | checksum new_resource.checksum 116 | mode 0755 117 | action :nothing 118 | end 119 | #no converge by on run_action remote_file takes care of it. 120 | r.run_action(:create_if_missing) 121 | end 122 | 123 | require 'tmpdir' 124 | 125 | description = "create tmpdir, extract compressed data into tmpdir, 126 | move extracted data to #{app_dir} and delete tmpdir" 127 | converge_by(description) do 128 | tmpdir = Dir.mktmpdir 129 | case tarball_name 130 | when /^.*\.bin/ 131 | cmd = Chef::ShellOut.new( 132 | %Q[ cd "#{tmpdir}"; 133 | cp "#{Chef::Config[:file_cache_path]}/#{tarball_name}" . ; 134 | bash ./#{tarball_name} -noregister 135 | ] ).run_command 136 | unless cmd.exitstatus == 0 137 | Chef::Application.fatal!("Failed to extract file #{tarball_name}!") 138 | end 139 | when /^.*\.zip/ 140 | cmd = Chef::ShellOut.new( 141 | %Q[ unzip "#{Chef::Config[:file_cache_path]}/#{tarball_name}" -d "#{tmpdir}" ] 142 | ).run_command 143 | unless cmd.exitstatus == 0 144 | Chef::Application.fatal!("Failed to extract file #{tarball_name}!") 145 | end 146 | when /^.*\.(tar.gz|tgz)/ 147 | cmd = Chef::ShellOut.new( 148 | %Q[ tar xvzf "#{Chef::Config[:file_cache_path]}/#{tarball_name}" -C "#{tmpdir}" ] 149 | ).run_command 150 | unless cmd.exitstatus == 0 151 | Chef::Application.fatal!("Failed to extract file #{tarball_name}!") 152 | end 153 | end 154 | 155 | cmd = Chef::ShellOut.new( 156 | %Q[ mv "#{tmpdir}/#{app_dir_name}" "#{app_dir}" ] 157 | ).run_command 158 | unless cmd.exitstatus == 0 159 | Chef::Application.fatal!(%Q[ Command \' mv "#{tmpdir}/#{app_dir_name}" "#{app_dir}" \' failed ]) 160 | end 161 | FileUtils.rm_r tmpdir 162 | end 163 | new_resource.updated_by_last_action(true) 164 | end 165 | 166 | #set up .jinfo file for update-java-alternatives 167 | java_name = app_home.split('/')[-1] 168 | jinfo_file = "#{app_root}/.#{java_name}.jinfo" 169 | if platform_family?("debian") && !::File.exists?(jinfo_file) 170 | description = "Add #{jinfo_file} for debian" 171 | converge_by(description) do 172 | Chef::Log.debug "Adding #{jinfo_file} for debian" 173 | template jinfo_file do 174 | source "oracle.jinfo.erb" 175 | variables( 176 | :priority => new_resource.alternatives_priority, 177 | :bin_cmds => new_resource.bin_cmds, 178 | :name => java_name, 179 | :app_dir => app_home 180 | ) 181 | action :create 182 | end 183 | end 184 | new_resource.updated_by_last_action(true) 185 | end 186 | 187 | #link app_home to app_dir 188 | Chef::Log.debug "app_home is #{app_home} and app_dir is #{app_dir}" 189 | current_link = ::File.symlink?(app_home) ? ::File.readlink(app_home) : nil 190 | if current_link != app_dir 191 | description = "Symlink #{app_dir} to #{app_home}" 192 | converge_by(description) do 193 | Chef::Log.debug "Symlinking #{app_dir} to #{app_home}" 194 | FileUtils.rm_f app_home 195 | FileUtils.ln_sf app_dir, app_home 196 | end 197 | end 198 | 199 | #update-alternatives 200 | if new_resource.bin_cmds 201 | new_resource.bin_cmds.each do |cmd| 202 | 203 | bin_path = "/usr/bin/#{cmd}" 204 | alt_path = "#{app_home}/bin/#{cmd}" 205 | priority = new_resource.alternatives_priority 206 | 207 | # install the alternative if needed 208 | alternative_exists = Chef::ShellOut.new("update-alternatives --display #{cmd} | grep #{alt_path}").run_command.exitstatus == 0 209 | unless alternative_exists 210 | description = "Add alternative for #{cmd}" 211 | converge_by(description) do 212 | Chef::Log.debug "Adding alternative for #{cmd}" 213 | install_cmd = Chef::ShellOut.new("update-alternatives --install #{bin_path} #{cmd} #{alt_path} #{priority}").run_command 214 | unless install_cmd.exitstatus == 0 215 | Chef::Application.fatal!(%Q[ set alternative failed ]) 216 | end 217 | end 218 | new_resource.updated_by_last_action(true) 219 | end 220 | 221 | # set the alternative if default 222 | if new_resource.default 223 | alternative_is_set = Chef::ShellOut.new("update-alternatives --display #{cmd} | grep \"link currently points to #{alt_path}\"").run_command.exitstatus == 0 224 | unless alternative_is_set 225 | description = "Set alternative for #{cmd}" 226 | converge_by(description) do 227 | Chef::Log.debug "Setting alternative for #{cmd}" 228 | set_cmd = Chef::ShellOut.new("update-alternatives --set #{cmd} #{alt_path}").run_command 229 | unless set_cmd.exitstatus == 0 230 | Chef::Application.fatal!(%Q[ set alternative failed ]) 231 | end 232 | end 233 | new_resource.updated_by_last_action(true) 234 | end 235 | end 236 | 237 | end 238 | end 239 | end 240 | 241 | 242 | action :remove do 243 | app_dir_name, tarball_name = parse_app_dir_name(new_resource.url) 244 | app_root = new_resource.app_home.split('/')[0..-2].join('/') 245 | app_dir = app_root + '/' + app_dir_name 246 | 247 | if ::File.exists?(app_dir) 248 | new_resource.bin_cmds.each do |cmd| 249 | cmd = execute "update_alternatives" do 250 | command "update-alternatives --remove #{cmd} #{app_dir} " 251 | returns [0,2] 252 | action :nothing 253 | end 254 | # the execute resource will take care of of the run_action(:run) 255 | cmd.run_action(:run) 256 | end 257 | description = "remove #{new_resource.name} at #{app_dir}" 258 | converge_by(description) do 259 | Chef::Log.info "Removing #{new_resource.name} at #{app_dir}" 260 | FileUtils.rm_rf app_dir 261 | end 262 | new_resource.updated_by_last_action(true) 263 | end 264 | end 265 | -------------------------------------------------------------------------------- /cookbooks/postgresql/README.md: -------------------------------------------------------------------------------- 1 | Description 2 | =========== 3 | 4 | Installs and configures PostgreSQL as a client or a server. 5 | 6 | Requirements 7 | ============ 8 | 9 | ## Platforms 10 | 11 | * Debian, Ubuntu 12 | * Red Hat/CentOS/Scientific (6.0+ required) - "EL6-family" 13 | * Fedora 14 | * SUSE 15 | 16 | Tested on: 17 | 18 | * Ubuntu 10.04, 11.10, 12.04 19 | * Red Hat 6.1, Scientific 6.1, CentOS 6.3 20 | 21 | ## Cookbooks 22 | 23 | Requires Opscode's `openssl` cookbook for secure password generation. 24 | 25 | Requires a C compiler and development headers in order to build the 26 | `pg` RubyGem to provide Ruby bindings in the `ruby` recipe. 27 | 28 | Opscode's `build-essential` cookbook provides this functionality on 29 | Debian, Ubuntu, and EL6-family. 30 | 31 | While not required, Opscode's `database` cookbook contains resources 32 | and providers that can interact with a PostgreSQL database. This 33 | cookbook is a dependency of database. 34 | 35 | Attributes 36 | ========== 37 | 38 | The following attributes are set based on the platform, see the 39 | `attributes/default.rb` file for default values. 40 | 41 | * `node['postgresql']['version']` - version of postgresql to manage 42 | * `node['postgresql']['dir']` - home directory of where postgresql 43 | data and configuration lives. 44 | 45 | * `node['postgresql']['client']['packages']` - An array of package names 46 | that should be installed on "client" systems. 47 | * `node['postgresql']['server']['packages']` - An array of package names 48 | that should be installed on "server" systems. 49 | * `node['postgresql']['contrib']['packages']` - An array of package names 50 | that could be installed on "server" systems for useful sysadmin tools. 51 | 52 | * `node['postgresql']['enable_pitti_ppa']` - Whether to enable the PPA 53 | by Martin Pitti, which contains newer versions of PostgreSQL. See 54 | __Recipes__ "`ppa_pitti_postgresql`" below for more information. 55 | 56 | * `node['postgresql']['enable_pgdg_yum']` - Whether to enable the yum repo 57 | by the PostgreSQL Global Development Group, which contains newer versions 58 | of PostgreSQL. 59 | 60 | The following attributes are generated in 61 | `recipe[postgresql::server]`. 62 | 63 | * `node['postgresql']['password']['postgres']` - randomly generated 64 | password by the `openssl` cookbook's library. 65 | 66 | Configuration 67 | ------------- 68 | 69 | The `postgresql.conf` and `pg_hba.conf` files are dynamically 70 | generated from attributes. Each key in `node['postgresql']['config']` 71 | is a postgresql configuration directive, and will be rendered in the 72 | config file. For example, the attribute: 73 | 74 | node['postgresql']['config']['listen_address'] = 'localhost' 75 | 76 | Will result in the following line in the `postgresql.conf` file: 77 | 78 | listen_address = 'localhost' 79 | 80 | The attributes file contains default values for Debian and RHEL 81 | platform families (per the `node['platform_family']`). These defaults 82 | have disparity between the platforms because they were originally 83 | extracted from the postgresql.conf files in the previous version of 84 | this cookbook, which differed in their default config. The resulting 85 | configuration files will be the same as before, but the content will 86 | be dynamically rendered from the attributes. The helpful commentary 87 | will no longer be present. You should consult the PostgreSQL 88 | documentation for specific configuration details. 89 | 90 | For values that are "on" or "off", they should be specified as literal 91 | `true` or `false`. String values will be used with single quotes. Any 92 | configuration option set to the literal `nil` will be skipped 93 | entirely. All other values (e.g., numeric literals) will be used as 94 | is. So for example: 95 | 96 | node.default['postgresql']['config']['logging_collector'] = true 97 | node.default['postgresql']['config']['datestyle'] = 'iso, mdy' 98 | node.default['postgresql']['config']['ident_file'] = nil 99 | node.default['postgresql']['config']['port] = 5432 100 | 101 | Will result in the following config lines: 102 | 103 | logging_collector = 'on' 104 | datestyle = 'iso,mdy' 105 | port = 5432 106 | 107 | (no line printed for `ident_file` as it is `nil`) 108 | 109 | The `pg_hba.conf` file is dynamically generated from the 110 | `node['postgresql']['pg_hba']` attribute. This attribute must be an 111 | array of hashes, each hash containing the authorization data. As it is 112 | an array, you can append to it in your own recipes. The hash keys in 113 | the array must be symbols. Each hash will be written as a line in 114 | `pg_hba.conf`. For example, this entry from 115 | `node['postgresql']['pg_hba']`: 116 | 117 | {:type => 'local', :db => 'all', :user => 'postgres', :addr => nil, :method => 'ident'} 118 | 119 | Will result in the following line in `pg_hba.conf`: 120 | 121 | local all postgres ident 122 | 123 | Use `nil` if the CIDR-ADDRESS should be empty (as above). 124 | 125 | Recipes 126 | ======= 127 | 128 | default 129 | ------- 130 | 131 | Includes the client recipe. 132 | 133 | client 134 | ------ 135 | 136 | Installs the packages defined in the 137 | `node['postgresql']['client']['packages']` attribute. 138 | 139 | ruby 140 | ---- 141 | 142 | **NOTE** This recipe may not currently work when installing Chef with 143 | the 144 | ["Omnibus" full stack installer](http://opscode.com/chef/install) on 145 | some platforms due to an incompatibility with OpenSSL. See 146 | [COOK-1406](http://tickets.opscode.com/browse/COOK-1406). You can 147 | build from source into the Chef omnibus installation to work around 148 | this issue. 149 | 150 | Install the `pg` gem under Chef's Ruby environment so it can be used 151 | in other recipes. The build-essential packages and postgresql client 152 | packages will be installed during the compile phase, so that the 153 | native extensions of `pg` can be compiled. 154 | 155 | server 156 | ------ 157 | 158 | Includes the `server_debian` or `server_redhat` recipe to get the 159 | appropriate server packages installed and service managed. Also 160 | manages the configuration for the server: 161 | 162 | * generates a strong default password (via `openssl`) for `postgres` 163 | * sets the password for postgres 164 | * manages the `postgresql.conf` file. 165 | * manages the `pg_hba.conf` file. 166 | 167 | server\_debian 168 | -------------- 169 | 170 | Installs the postgresql server packages and sets up the service. You 171 | should include the `postgresql::server` recipe, which will include 172 | this on Debian platforms. 173 | 174 | server\_redhat 175 | -------------- 176 | 177 | Manages the postgres user and group (with UID/GID 26, per RHEL package 178 | conventions), installs the postgresql server packages, initializes the 179 | database, and manages the postgresql service. You should include the 180 | `postgresql::server` recipe, which will include this on RHEL/Fedora 181 | platforms. 182 | 183 | contrib 184 | ------- 185 | 186 | Installs the packages defined in the 187 | `node['postgresql']['contrib']['packages']` attribute. 188 | This is the contrib directory of the PostgreSQL distribution, which 189 | includes porting tools, analysis utilities, and plug-in features that 190 | database engineers often require. Some (like pgbench) are executable. 191 | Others (like pg_buffercache) should be installed into the database. 192 | 193 | ppa\_pitti\_postgresql 194 | ---------------------- 195 | 196 | Enables Martin Pitti's PPA for updated PostgreSQL packages. 197 | Automatically included if the `node['postgresql']['enable_pitti_ppa']` 198 | attribute is true. Also set the 199 | `node['postgresql']['client']['packages']` and 200 | `node['postgresql']['server]['packages']` to the list of packages to 201 | use from this repository, and set the `node['postgresql']['version']` 202 | attribute to the version to use (e.g., "9.2"). 203 | 204 | yum\_pgdg\_postgresql 205 | --------------------- 206 | 207 | Enables the PostgreSQL Global Development Group yum repository 208 | maintained by Devrim Gündüz for updated PostgreSQL packages. 209 | (The PGDG is the groups that develops PostgreSQL.) 210 | Automatically included if the `node['postgresql']['enable_pgdg_yum']` 211 | attribute is true. Also use `override_attributes` to set a number of 212 | values that will need to have embedded version numbers. For example: 213 | 214 | node['postgresql']['enable_pgdg_yum'] = true 215 | node['postgresql']['version'] = "9.2" 216 | node['postgresql']['dir'] = "/var/lib/pgsql/9.2/data" 217 | node['postgresql']['client']['packages'] = ["postgresql92"] 218 | node['postgresql']['server']['packages'] = ["postgresql92-server"] 219 | node['postgresql']['server']['service_name'] = "postgresql-9.2" 220 | node['postgresql']['contrib']['packages'] = ["postgresql92-contrib"] 221 | 222 | You may set `node['postgresql']['pgdg']['repo_rpm_url']` attributes 223 | to pick up recent [PGDG repo packages](http://yum.postgresql.org/repopackages.php). 224 | 225 | Resources/Providers 226 | =================== 227 | 228 | See the [database](http://community.opscode.com/cookbooks/database) 229 | for resources and providers that can be used for managing PostgreSQL 230 | users and databases. 231 | 232 | Usage 233 | ===== 234 | 235 | On systems that need to connect to a PostgreSQL database, add to a run 236 | list `recipe[postgresql]` or `recipe[postgresql::client]`. 237 | 238 | On systems that should be PostgreSQL servers, use 239 | `recipe[postgresql::server]` on a run list. This recipe does set a 240 | password and expect to use it. It performs a node.save when Chef is 241 | not running in `solo` mode. If you're using `chef-solo`, you'll need 242 | to set the attribute `node['postgresql']['password']['postgres']` in 243 | your node's `json_attribs` file or in a role. 244 | 245 | On Debian family systems, SSL will be enabled, as the packages on 246 | Debian/Ubuntu also generate the SSL certificates. If you use another 247 | platform and wish to use SSL in postgresql, then generate your SSL 248 | certificates and distribute them in your own cookbook, and set the 249 | `node['postgresql']['config']['ssl']` attribute to true in your 250 | role/cookboook/node. 251 | 252 | Chef Solo Note 253 | ============== 254 | 255 | The following node attribute is stored on the Chef Server when using 256 | `chef-client`. Because `chef-solo` does not connect to a server or 257 | save the node object at all, to have the password persist across 258 | `chef-solo` runs, you must specify them in the `json_attribs` file 259 | used. For Example: 260 | 261 | { 262 | "postgresql": { 263 | "password": { 264 | "postgres": "iloverandompasswordsbutthiswilldo" 265 | } 266 | }, 267 | "run_list": ["recipe[postgresql::server]"] 268 | } 269 | 270 | License and Author 271 | ================== 272 | 273 | - Author:: Joshua Timberman () 274 | - Author:: Lamont Granquist () 275 | - Author:: Chris Roberts () 276 | 277 | Licensed under the Apache License, Version 2.0 (the "License"); 278 | you may not use this file except in compliance with the License. 279 | You may obtain a copy of the License at 280 | 281 | http://www.apache.org/licenses/LICENSE-2.0 282 | 283 | Unless required by applicable law or agreed to in writing, software 284 | distributed under the License is distributed on an "AS IS" BASIS, 285 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 286 | See the License for the specific language governing permissions and 287 | limitations under the License. 288 | -------------------------------------------------------------------------------- /cookbooks/postgresql/metadata.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "postgresql", 3 | "description": "Installs and configures postgresql for clients or servers", 4 | "long_description": "Description\n===========\n\nInstalls and configures PostgreSQL as a client or a server.\n\nRequirements\n============\n\n## Platforms\n\n* Debian, Ubuntu\n* Red Hat/CentOS/Scientific (6.0+ required) - \"EL6-family\"\n* Fedora\n* SUSE\n\nTested on:\n\n* Ubuntu 10.04, 11.10, 12.04\n* Red Hat 6.1, Scientific 6.1, CentOS 6.3\n\n## Cookbooks\n\nRequires Opscode's `openssl` cookbook for secure password generation.\n\nRequires a C compiler and development headers in order to build the\n`pg` RubyGem to provide Ruby bindings in the `ruby` recipe.\n\nOpscode's `build-essential` cookbook provides this functionality on\nDebian, Ubuntu, and EL6-family.\n\nWhile not required, Opscode's `database` cookbook contains resources\nand providers that can interact with a PostgreSQL database. This\ncookbook is a dependency of database.\n\nAttributes\n==========\n\nThe following attributes are set based on the platform, see the\n`attributes/default.rb` file for default values.\n\n* `node['postgresql']['version']` - version of postgresql to manage\n* `node['postgresql']['dir']` - home directory of where postgresql\n data and configuration lives.\n\n* `node['postgresql']['client']['packages']` - An array of package names\n that should be installed on \"client\" systems.\n* `node['postgresql']['server']['packages']` - An array of package names\n that should be installed on \"server\" systems.\n* `node['postgresql']['contrib']['packages']` - An array of package names\n that could be installed on \"server\" systems for useful sysadmin tools.\n\n* `node['postgresql']['enable_pitti_ppa']` - Whether to enable the PPA\n by Martin Pitti, which contains newer versions of PostgreSQL. See\n __Recipes__ \"`ppa_pitti_postgresql`\" below for more information.\n\n* `node['postgresql']['enable_pgdg_yum']` - Whether to enable the yum repo\n by the PostgreSQL Global Development Group, which contains newer versions\n of PostgreSQL.\n\nThe following attributes are generated in\n`recipe[postgresql::server]`.\n\n* `node['postgresql']['password']['postgres']` - randomly generated\n password by the `openssl` cookbook's library.\n\nConfiguration\n-------------\n\nThe `postgresql.conf` and `pg_hba.conf` files are dynamically\ngenerated from attributes. Each key in `node['postgresql']['config']`\nis a postgresql configuration directive, and will be rendered in the\nconfig file. For example, the attribute:\n\n node['postgresql']['config']['listen_address'] = 'localhost'\n\nWill result in the following line in the `postgresql.conf` file:\n\n listen_address = 'localhost'\n\nThe attributes file contains default values for Debian and RHEL\nplatform families (per the `node['platform_family']`). These defaults\nhave disparity between the platforms because they were originally\nextracted from the postgresql.conf files in the previous version of\nthis cookbook, which differed in their default config. The resulting\nconfiguration files will be the same as before, but the content will\nbe dynamically rendered from the attributes. The helpful commentary\nwill no longer be present. You should consult the PostgreSQL\ndocumentation for specific configuration details.\n\nFor values that are \"on\" or \"off\", they should be specified as literal\n`true` or `false`. String values will be used with single quotes. Any\nconfiguration option set to the literal `nil` will be skipped\nentirely. All other values (e.g., numeric literals) will be used as\nis. So for example:\n\n node.default['postgresql']['config']['logging_collector'] = true\n node.default['postgresql']['config']['datestyle'] = 'iso, mdy'\n node.default['postgresql']['config']['ident_file'] = nil\n node.default['postgresql']['config']['port] = 5432\n\nWill result in the following config lines:\n\n logging_collector = 'on'\n datestyle = 'iso,mdy'\n port = 5432\n\n(no line printed for `ident_file` as it is `nil`)\n\nThe `pg_hba.conf` file is dynamically generated from the\n`node['postgresql']['pg_hba']` attribute. This attribute must be an\narray of hashes, each hash containing the authorization data. As it is\nan array, you can append to it in your own recipes. The hash keys in\nthe array must be symbols. Each hash will be written as a line in\n`pg_hba.conf`. For example, this entry from\n`node['postgresql']['pg_hba']`:\n\n {:type => 'local', :db => 'all', :user => 'postgres', :addr => nil, :method => 'ident'}\n\nWill result in the following line in `pg_hba.conf`:\n\n local all postgres ident\n\nUse `nil` if the CIDR-ADDRESS should be empty (as above).\n\nRecipes\n=======\n\ndefault\n-------\n\nIncludes the client recipe.\n\nclient\n------\n\nInstalls the packages defined in the\n`node['postgresql']['client']['packages']` attribute.\n\nruby\n----\n\n**NOTE** This recipe may not currently work when installing Chef with\n the\n [\"Omnibus\" full stack installer](http://opscode.com/chef/install) on\n some platforms due to an incompatibility with OpenSSL. See\n [COOK-1406](http://tickets.opscode.com/browse/COOK-1406). You can\n build from source into the Chef omnibus installation to work around\n this issue.\n\nInstall the `pg` gem under Chef's Ruby environment so it can be used\nin other recipes. The build-essential packages and postgresql client\npackages will be installed during the compile phase, so that the\nnative extensions of `pg` can be compiled.\n\nserver\n------\n\nIncludes the `server_debian` or `server_redhat` recipe to get the\nappropriate server packages installed and service managed. Also\nmanages the configuration for the server:\n\n* generates a strong default password (via `openssl`) for `postgres`\n* sets the password for postgres\n* manages the `postgresql.conf` file.\n* manages the `pg_hba.conf` file.\n\nserver\\_debian\n--------------\n\nInstalls the postgresql server packages and sets up the service. You\nshould include the `postgresql::server` recipe, which will include\nthis on Debian platforms.\n\nserver\\_redhat\n--------------\n\nManages the postgres user and group (with UID/GID 26, per RHEL package\nconventions), installs the postgresql server packages, initializes the\ndatabase, and manages the postgresql service. You should include the\n`postgresql::server` recipe, which will include this on RHEL/Fedora\nplatforms.\n\ncontrib\n-------\n\nInstalls the packages defined in the\n`node['postgresql']['contrib']['packages']` attribute.\nThis is the contrib directory of the PostgreSQL distribution, which\nincludes porting tools, analysis utilities, and plug-in features that\ndatabase engineers often require. Some (like pgbench) are executable.\nOthers (like pg_buffercache) should be installed into the database.\n\nppa\\_pitti\\_postgresql\n----------------------\n\nEnables Martin Pitti's PPA for updated PostgreSQL packages.\nAutomatically included if the `node['postgresql']['enable_pitti_ppa']`\nattribute is true. Also set the\n`node['postgresql']['client']['packages']` and\n`node['postgresql']['server]['packages']` to the list of packages to\nuse from this repository, and set the `node['postgresql']['version']`\nattribute to the version to use (e.g., \"9.2\").\n\nyum\\_pgdg\\_postgresql\n---------------------\n\nEnables the PostgreSQL Global Development Group yum repository\nmaintained by Devrim Gündüz for updated PostgreSQL packages.\n(The PGDG is the groups that develops PostgreSQL.)\nAutomatically included if the `node['postgresql']['enable_pgdg_yum']`\nattribute is true. Also use `override_attributes` to set a number of\nvalues that will need to have embedded version numbers. For example:\n\n node['postgresql']['enable_pgdg_yum'] = true\n node['postgresql']['version'] = \"9.2\"\n node['postgresql']['dir'] = \"/var/lib/pgsql/9.2/data\"\n node['postgresql']['client']['packages'] = [\"postgresql92\"]\n node['postgresql']['server']['packages'] = [\"postgresql92-server\"]\n node['postgresql']['server']['service_name'] = \"postgresql-9.2\"\n node['postgresql']['contrib']['packages'] = [\"postgresql92-contrib\"]\n\nYou may set `node['postgresql']['pgdg']['repo_rpm_url']` attributes\nto pick up recent [PGDG repo packages](http://yum.postgresql.org/repopackages.php).\n\nResources/Providers\n===================\n\nSee the [database](http://community.opscode.com/cookbooks/database)\nfor resources and providers that can be used for managing PostgreSQL\nusers and databases.\n\nUsage\n=====\n\nOn systems that need to connect to a PostgreSQL database, add to a run\nlist `recipe[postgresql]` or `recipe[postgresql::client]`.\n\nOn systems that should be PostgreSQL servers, use\n`recipe[postgresql::server]` on a run list. This recipe does set a\npassword and expect to use it. It performs a node.save when Chef is\nnot running in `solo` mode. If you're using `chef-solo`, you'll need\nto set the attribute `node['postgresql']['password']['postgres']` in\nyour node's `json_attribs` file or in a role.\n\nOn Debian family systems, SSL will be enabled, as the packages on\nDebian/Ubuntu also generate the SSL certificates. If you use another\nplatform and wish to use SSL in postgresql, then generate your SSL\ncertificates and distribute them in your own cookbook, and set the\n`node['postgresql']['config']['ssl']` attribute to true in your\nrole/cookboook/node.\n\nChef Solo Note\n==============\n\nThe following node attribute is stored on the Chef Server when using\n`chef-client`. Because `chef-solo` does not connect to a server or\nsave the node object at all, to have the password persist across\n`chef-solo` runs, you must specify them in the `json_attribs` file\nused. For Example:\n\n {\n \"postgresql\": {\n \"password\": {\n \"postgres\": \"iloverandompasswordsbutthiswilldo\"\n }\n },\n \"run_list\": [\"recipe[postgresql::server]\"]\n }\n\nLicense and Author\n==================\n\n- Author:: Joshua Timberman ()\n- Author:: Lamont Granquist ()\n- Author:: Chris Roberts ()\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 | "ubuntu": ">= 0.0.0", 10 | "debian": ">= 0.0.0", 11 | "fedora": ">= 0.0.0", 12 | "suse": ">= 0.0.0", 13 | "amazon": ">= 0.0.0", 14 | "redhat": ">= 6.0", 15 | "centos": ">= 6.0", 16 | "scientific": ">= 6.0", 17 | "oracle": ">= 6.0" 18 | }, 19 | "dependencies": { 20 | "openssl": ">= 0.0.0" 21 | }, 22 | "recommendations": { 23 | }, 24 | "suggestions": { 25 | }, 26 | "conflicting": { 27 | }, 28 | "providing": { 29 | }, 30 | "replacing": { 31 | }, 32 | "attributes": { 33 | }, 34 | "groupings": { 35 | }, 36 | "recipes": { 37 | "postgresql": "Includes postgresql::client", 38 | "postgresql::ruby": "Installs pg gem for Ruby bindings", 39 | "postgresql::client": "Installs postgresql client package(s)", 40 | "postgresql::server": "Installs postgresql server packages, templates", 41 | "postgresql::server_redhat": "Installs postgresql server packages, redhat family style", 42 | "postgresql::server_debian": "Installs postgresql server packages, debian family style" 43 | }, 44 | "version": "2.2.2" 45 | } -------------------------------------------------------------------------------- /cookbooks/apt/LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | --------------------------------------------------------------------------------