├── .gitignore ├── cookbooks ├── rs_utils │ ├── templates │ │ └── default │ │ │ ├── id_rsa.erb │ │ │ ├── processes.conf.erb │ │ │ ├── file-stats.conf.erb │ │ │ ├── collectd.config.erb │ │ │ └── syslog.erb │ ├── files │ │ └── default │ │ │ ├── collectd.mysql.conf │ │ │ ├── mail │ │ │ ├── collectd-init-centos-with-monitor │ │ │ ├── file-stats.rb │ │ │ └── karmic_types.db │ ├── recipes │ │ ├── default.rb │ │ ├── install_mysql_collectd_plugin.rb │ │ ├── install_file_stats_collectd_plugin.rb │ │ └── install_utils.rb │ ├── metadata.rb │ ├── attributes │ │ └── system.rb │ └── metadata.json ├── app_php │ ├── README.rdoc │ ├── templates │ │ └── default │ │ │ ├── config_db.php.erb │ │ │ └── php_web_app.conf.erb │ ├── recipes │ │ ├── default.rb │ │ ├── do_db_restore.rb │ │ ├── do_update_code.rb │ │ └── install_php.rb │ ├── attributes │ │ └── php.rb │ ├── metadata.rb │ └── metadata.json ├── app_rails │ ├── README.rdoc │ ├── templates │ │ └── default │ │ │ ├── logrotate.conf.erb │ │ │ ├── database.yaml.erb │ │ │ └── passenger_web_app.conf.erb │ ├── recipes │ │ ├── default.rb │ │ ├── setup_db_config.rb │ │ ├── do_db_restore.rb │ │ ├── do_update_code.rb │ │ └── install_rails.rb │ ├── attributes │ │ └── rails.rb │ ├── metadata.rb │ └── metadata.json ├── db_mysql │ ├── templates │ │ ├── default │ │ │ ├── port_mysql.erb │ │ │ ├── mysql-server.seed.erb │ │ │ ├── init-mysql.erb │ │ │ └── my.cnf.erb │ │ └── centos │ │ │ └── init-mysql.erb │ ├── files │ │ └── default │ │ │ └── debian.cnf │ ├── README.rdoc │ ├── recipes │ │ ├── default.rb │ │ ├── setup_admin_privileges.rb │ │ ├── client.rb │ │ ├── setup_my_cnf.rb │ │ └── install_mysql.rb │ ├── definitions │ │ ├── db_mysql_restore.rb │ │ └── db_mysql_set_privileges.rb │ ├── metadata.rb │ ├── attributes │ │ ├── mysql.rb │ │ └── mysql_tuning.rb │ └── metadata.json ├── repo_git │ ├── metadata.rb │ ├── metadata.json │ └── definitions │ │ └── repo_git_pull.rb └── web_apache │ ├── templates │ └── default │ │ ├── sysconfig_httpd.erb │ │ └── apache2.conf.erb │ ├── metadata.rb │ ├── recipes │ ├── default.rb │ └── install_apache.rb │ ├── attributes │ └── apache.rb │ └── metadata.json ├── LICENSE ├── Rakefile ├── config └── rake.rb └── README.rdoc /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | -------------------------------------------------------------------------------- /cookbooks/rs_utils/templates/default/id_rsa.erb: -------------------------------------------------------------------------------- 1 | <%= @node[:rs_utils][:private_ssh_key] %> 2 | -------------------------------------------------------------------------------- /cookbooks/app_php/README.rdoc: -------------------------------------------------------------------------------- 1 | = DESCRIPTION: 2 | 3 | = REQUIREMENTS: 4 | 5 | = ATTRIBUTES: 6 | 7 | = USAGE: 8 | 9 | -------------------------------------------------------------------------------- /cookbooks/app_rails/README.rdoc: -------------------------------------------------------------------------------- 1 | = DESCRIPTION: 2 | 3 | = REQUIREMENTS: 4 | 5 | = ATTRIBUTES: 6 | 7 | = USAGE: 8 | 9 | -------------------------------------------------------------------------------- /cookbooks/db_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/rs_utils/files/default/collectd.mysql.conf: -------------------------------------------------------------------------------- 1 | LoadPlugin mysql 2 | 3 | Host "localhost" 4 | User "root" 5 | Password "" 6 | 7 | 8 | -------------------------------------------------------------------------------- /cookbooks/rs_utils/files/default/mail: -------------------------------------------------------------------------------- 1 | /var/spool/mail/* { 2 | daily 3 | compress 4 | notifempty 5 | missingok 6 | olddir /var/spool/oldmail 7 | } 8 | 9 | -------------------------------------------------------------------------------- /cookbooks/rs_utils/templates/default/processes.conf.erb: -------------------------------------------------------------------------------- 1 | LoadPlugin Processes 2 | 3 | process "collectd" 4 | <% @node[:rs_utils][:process_list].split.each do |process| %> 5 | process "<%= process %>" 6 | <% end %> 7 | 8 | -------------------------------------------------------------------------------- /cookbooks/app_rails/templates/default/logrotate.conf.erb: -------------------------------------------------------------------------------- 1 | /var/log/<%= @app_name %>/*log { 2 | missingok 3 | notifempty 4 | nocompress 5 | sharedscripts 6 | postrotate 7 | /bin/kill -HUP `cat /var/run/syslogd.pid 2> /dev/null` 2> /dev/null || true 8 | endscript 9 | } -------------------------------------------------------------------------------- /cookbooks/app_php/templates/default/config_db.php.erb: -------------------------------------------------------------------------------- 1 | "; 4 | $database_DB = "<%= @node[:php][:db_schema_name] %>"; 5 | $username_DB = "<%= @node[:php][:db_app_user] %>"; 6 | $password_DB = "<%= @node[:php][:db_app_passwd] %>"; 7 | ?> 8 | -------------------------------------------------------------------------------- /cookbooks/db_mysql/files/default/debian.cnf: -------------------------------------------------------------------------------- 1 | # Automatically overwritten by RightScale 2 | [client] 3 | host = localhost 4 | user = root 5 | password = 6 | socket = /var/run/mysqld/mysqld.sock 7 | [mysql_upgrade] 8 | user = root 9 | password = 10 | socket = /var/run/mysqld/mysqld.sock 11 | basedir = /usr -------------------------------------------------------------------------------- /cookbooks/rs_utils/templates/default/file-stats.conf.erb: -------------------------------------------------------------------------------- 1 | LoadPlugin exec 2 | 3 | # userid plugin executable plugin args 4 | Exec "nobody" "<%= @node[:rs_utils][:collectd_lib] %>/plugins/file-stats.rb" "-h" "<%= @node[:rightscale][:instance_uuid] %>" "-i" "20" "<%= @node[:rs_utils][:mysql_binary_backup_file] %>" 5 | 6 | -------------------------------------------------------------------------------- /cookbooks/app_rails/templates/default/database.yaml.erb: -------------------------------------------------------------------------------- 1 | #File created by chef 2 | 3 | <%= @node[:rails][:env] %>: 4 | adapter: mysql 5 | host: <%= @node[:rails][:db_dns_name] %> 6 | username: <%= @node[:rails][:db_app_user] %> 7 | password: <%= @node[:rails][:db_app_passwd] %> 8 | database: <%= @node[:rails][:db_schema_name] %> 9 | socket: <%= @node[:db_mysql][:socket] %> 10 | -------------------------------------------------------------------------------- /cookbooks/repo_git/metadata.rb: -------------------------------------------------------------------------------- 1 | maintainer "RightScale, Inc." 2 | maintainer_email "support@rightscale.com" 3 | license IO.read(File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'LICENSE'))) 4 | description "Installs the git fast version control system" 5 | version "0.0.1" 6 | 7 | depends "git" 8 | 9 | provides "repo_git_pull(url, branch, dest, cred)" 10 | 11 | -------------------------------------------------------------------------------- /cookbooks/web_apache/templates/default/sysconfig_httpd.erb: -------------------------------------------------------------------------------- 1 | # Configuration file for the httpd service. 2 | 3 | # 4 | # The default processing model (MPM) is the process-based 5 | # 'prefork' model. A thread-based model, 'worker', is also 6 | # available, but does not work with some modules (such as PHP). 7 | # The service must be stopped before changing this variable. 8 | # 9 | #HTTPD=/usr/sbin/httpd.worker 10 | HTTPD=<%= @sysconfig_httpd %> 11 | # 12 | # To pass additional options (for instance, -D definitions) to the 13 | # httpd binary at startup, set OPTIONS here. 14 | # 15 | #OPTIONS= 16 | 17 | # 18 | # By default, the httpd process is started in the C locale; to 19 | # change the locale in which the server runs, the HTTPD_LANG 20 | # variable can be set. 21 | # 22 | #HTTPD_LANG=C -------------------------------------------------------------------------------- /cookbooks/db_mysql/templates/default/mysql-server.seed.erb: -------------------------------------------------------------------------------- 1 | mysql-server-5.0 mysql-server/root_password_again select 2 | mysql-server-5.0 mysql-server/root_password select 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/db_mysql/README.rdoc: -------------------------------------------------------------------------------- 1 | = DESCRIPTION: 2 | 3 | Configures MySQL database servers that act as a Master-DB. Specifically designed for RightScale's Manager for MySQL-EBS. Storage of MySQL data will be done using EBS Volumes. EBS Snapshots are used for database backups. 4 | 5 | = REQUIREMENTS: 6 | 7 | * The Opscode's public cookbooks must be in your cookbook path -- the 'mysql' cookbook is used for client install. 8 | 9 | = ATTRIBUTES: 10 | 11 | See metadata.rb 12 | 13 | = USAGE: 14 | 15 | Designed to be run within a RightScale ServerTemplate with the following run order: 16 | 17 | Boot Scripts 18 | * install_mysql - Performs base server install and configuration. 19 | 20 | Definitions 21 | * db_mysql_restore - Restores database from MySQL dump retrieved from a remote location. 22 | * db_mysql_set_privileges - Configures a user's privileges. Currently only 'administrator' and 'user' settings are supported. 23 | -------------------------------------------------------------------------------- /cookbooks/rs_utils/templates/default/collectd.config.erb: -------------------------------------------------------------------------------- 1 | # 2 | # Config file for collectd, version 4. 3 | # Prepared by RightScale for EC2 instances. 4 | # 5 | Hostname "<%= @node[:rightscale][:instance_uuid] %>" 6 | BaseDir "/var/lib/collectd" 7 | PIDFile "/var/run/collectd.pid" 8 | PluginDir "<%= @node[:rs_utils][:collectd_lib] %>" 9 | TypesDB "<%= @node[:rs_utils][:collectd_lib] %>/types.db" 10 | Interval 10 11 | ReadThreads 5 12 | LoadPlugin network 13 | 14 | Server "<%= @node[:rightscale][:servers][:sketchy][:hostname] %>" "3011" 15 | 16 | LoadPlugin cpu 17 | LoadPlugin df 18 | LoadPlugin disk 19 | LoadPlugin load 20 | LoadPlugin memory 21 | LoadPlugin processes 22 | LoadPlugin swap 23 | LoadPlugin syslog 24 | LoadPlugin users 25 | LoadPlugin interface 26 | 27 | Interface "eth0" 28 | 29 | LoadPlugin ping 30 | 31 | Host "www.rightscale.com" 32 | Host "s3.amazonaws.com" 33 | Host "ec2.amazonaws.com" 34 | 35 | #this is where other configs go (e.g. mysql.conf) 36 | 37 | Include "<%= @node[:rs_utils][:collectd_plugin_dir] %>/*" 38 | 39 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2009 RightScale, Inc. 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | 'Software'), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 18 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 19 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 20 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | # 2 | # Rakefile for Chef Server Repository 3 | # 4 | # Author:: Adam Jacob () 5 | # Copyright:: Copyright (c) 2008 Opscode, Inc. 6 | # License:: Apache License, Version 2.0 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 'rubygems' 22 | require 'chef' 23 | require 'json' 24 | 25 | # Make sure you have loaded constants first 26 | require File.join(File.dirname(__FILE__), 'config', 'rake') 27 | 28 | # And choosen a VCS 29 | if File.directory?(File.join(TOPDIR, ".svn")) 30 | $vcs = :svn 31 | elsif File.directory?(File.join(TOPDIR, ".git")) 32 | $vcs = :git 33 | end 34 | 35 | load 'chef/tasks/chef_repo.rake' 36 | -------------------------------------------------------------------------------- /cookbooks/app_php/recipes/default.rb: -------------------------------------------------------------------------------- 1 | # Cookbook Name:: app_php 2 | # Recipe:: default 3 | # 4 | # Copyright (c) 2009 RightScale Inc 5 | # 6 | # Permission is hereby granted, free of charge, to any person obtaining 7 | # a copy of this software and associated documentation files (the 8 | # "Software"), to deal in the Software without restriction, including 9 | # without limitation the rights to use, copy, modify, merge, publish, 10 | # distribute, sublicense, and/or sell copies of the Software, and to 11 | # permit persons to whom the Software is furnished to do so, subject to 12 | # the following conditions: 13 | # 14 | # The above copyright notice and this permission notice shall be 15 | # included in all copies or substantial portions of the Software. 16 | # 17 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | 25 | include_recipe "app_php::install_php" 26 | -------------------------------------------------------------------------------- /cookbooks/app_rails/recipes/default.rb: -------------------------------------------------------------------------------- 1 | # Cookbook Name:: app_rails 2 | # Recipe:: default 3 | # 4 | # Copyright (c) 2009 RightScale Inc 5 | # 6 | # Permission is hereby granted, free of charge, to any person obtaining 7 | # a copy of this software and associated documentation files (the 8 | # "Software"), to deal in the Software without restriction, including 9 | # without limitation the rights to use, copy, modify, merge, publish, 10 | # distribute, sublicense, and/or sell copies of the Software, and to 11 | # permit persons to whom the Software is furnished to do so, subject to 12 | # the following conditions: 13 | # 14 | # The above copyright notice and this permission notice shall be 15 | # included in all copies or substantial portions of the Software. 16 | # 17 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | 25 | include_recipe "app_rails::install_rails" -------------------------------------------------------------------------------- /cookbooks/rs_utils/recipes/default.rb: -------------------------------------------------------------------------------- 1 | # Cookbook Name:: rs_utils 2 | # Recipe:: install_utils 3 | # 4 | # Copyright (c) 2009 RightScale Inc 5 | # 6 | # Permission is hereby granted, free of charge, to any person obtaining 7 | # a copy of this software and associated documentation files (the 8 | # "Software"), to deal in the Software without restriction, including 9 | # without limitation the rights to use, copy, modify, merge, publish, 10 | # distribute, sublicense, and/or sell copies of the Software, and to 11 | # permit persons to whom the Software is furnished to do so, subject to 12 | # the following conditions: 13 | # 14 | # The above copyright notice and this permission notice shall be 15 | # included in all copies or substantial portions of the Software. 16 | # 17 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | 25 | include_recipe "rs_utils::install_utils" -------------------------------------------------------------------------------- /cookbooks/web_apache/metadata.rb: -------------------------------------------------------------------------------- 1 | maintainer "RightScale, Inc." 2 | maintainer_email "support@rightscale.com" 3 | license IO.read(File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'LICENSE'))) 4 | description "Installs/configures the apache2 webserver" 5 | version "0.0.1" 6 | 7 | depends "apache2" 8 | 9 | attribute "web_apache", 10 | :display_name => "apache hash", 11 | :description => "Apache Web Server", 12 | :type => "hash" 13 | 14 | #attribute "web_apache/contact", 15 | # :display_name => "Contact Email", 16 | # :description => "The email address that Apache uses to send administrative mail (set in /etc/httpd/conf/httpd.conf). By setting it to root@localhost.com emails are saved on the server. You can use your own email address, but your spam filters might block them because reverse DNS lookup will show a mismatch between EC2 and your domain.", 17 | # :default => "root@localhost" 18 | 19 | attribute "web_apache/mpm", 20 | :display_name => "Multi-Processing Module", 21 | :description => "Can be set to 'worker' or 'prefork' and defines the setting in httpd.conf. Use 'worker' for Rails/Tomcat/Standalone frontends and 'prefork' for PHP.", 22 | :recipes => [ "web_apache::install_apache", "web_apache::default" ], 23 | :default => "worker" 24 | 25 | -------------------------------------------------------------------------------- /cookbooks/web_apache/recipes/default.rb: -------------------------------------------------------------------------------- 1 | # Cookbook Name:: web_apache 2 | # Recipe:: default 3 | # 4 | # Copyright (c) 2009 RightScale Inc 5 | # 6 | # Permission is hereby granted, free of charge, to any person obtaining 7 | # a copy of this software and associated documentation files (the 8 | # "Software"), to deal in the Software without restriction, including 9 | # without limitation the rights to use, copy, modify, merge, publish, 10 | # distribute, sublicense, and/or sell copies of the Software, and to 11 | # permit persons to whom the Software is furnished to do so, subject to 12 | # the following conditions: 13 | # 14 | # The above copyright notice and this permission notice shall be 15 | # included in all copies or substantial portions of the Software. 16 | # 17 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | 25 | include_recipe "web_apache::install_apache" -------------------------------------------------------------------------------- /cookbooks/db_mysql/recipes/default.rb: -------------------------------------------------------------------------------- 1 | # Cookbook Name:: db_mysql 2 | # Recipe:: default 3 | # 4 | # Copyright (c) 2009 RightScale Inc 5 | # 6 | # Permission is hereby granted, free of charge, to any person obtaining 7 | # a copy of this software and associated documentation files (the 8 | # "Software"), to deal in the Software without restriction, including 9 | # without limitation the rights to use, copy, modify, merge, publish, 10 | # distribute, sublicense, and/or sell copies of the Software, and to 11 | # permit persons to whom the Software is furnished to do so, subject to 12 | # the following conditions: 13 | # 14 | # The above copyright notice and this permission notice shall be 15 | # included in all copies or substantial portions of the Software. 16 | # 17 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | 25 | include_recipe "db_mysql::install_mysql" 26 | 27 | -------------------------------------------------------------------------------- /cookbooks/app_rails/recipes/setup_db_config.rb: -------------------------------------------------------------------------------- 1 | # Cookbook Name:: app_rails 2 | # Recipe:: setup_db_config 3 | # 4 | # Copyright (c) 2009 RightScale Inc 5 | # 6 | # Permission is hereby granted, free of charge, to any person obtaining 7 | # a copy of this software and associated documentation files (the 8 | # "Software"), to deal in the Software without restriction, including 9 | # without limitation the rights to use, copy, modify, merge, publish, 10 | # distribute, sublicense, and/or sell copies of the Software, and to 11 | # permit persons to whom the Software is furnished to do so, subject to 12 | # the following conditions: 13 | # 14 | # The above copyright notice and this permission notice shall be 15 | # included in all copies or substantial portions of the Software. 16 | # 17 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | 25 | template "#{@node[:rails][:code][:destination]}/config/database.yml" do 26 | source "database.yaml.erb" 27 | end 28 | -------------------------------------------------------------------------------- /cookbooks/db_mysql/recipes/setup_admin_privileges.rb: -------------------------------------------------------------------------------- 1 | # Cookbook Name:: db_mysql 2 | # Recipe:: setup_admin_privileges 3 | # 4 | # Copyright (c) 2009 RightScale Inc 5 | # 6 | # Permission is hereby granted, free of charge, to any person obtaining 7 | # a copy of this software and associated documentation files (the 8 | # "Software"), to deal in the Software without restriction, including 9 | # without limitation the rights to use, copy, modify, merge, publish, 10 | # distribute, sublicense, and/or sell copies of the Software, and to 11 | # permit persons to whom the Software is furnished to do so, subject to 12 | # the following conditions: 13 | # 14 | # The above copyright notice and this permission notice shall be 15 | # included in all copies or substantial portions of the Software. 16 | # 17 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | 25 | 26 | db_mysql_set_privileges "setup admin privileges" do 27 | preset "administrator" 28 | username @node[:db][:admin][:user] 29 | password @node[:db][:admin][:password] 30 | end 31 | -------------------------------------------------------------------------------- /cookbooks/app_php/attributes/php.rb: -------------------------------------------------------------------------------- 1 | # Cookbook Name:: app_php 2 | # 3 | # Copyright 2009, RightScale, Inc. 4 | # 5 | # All rights reserved - Do Not Redistribute 6 | # 7 | 8 | # 9 | # Required attributes 10 | # 11 | set_unless[:php][:code][:url] = "" 12 | set_unless[:php][:code][:credentials] = "" 13 | 14 | set_unless[:php][:db_app_user] = "" 15 | set_unless[:php][:db_app_passwd] = "" 16 | set_unless[:php][:db_schema_name] = "" 17 | set_unless[:php][:db_dns_name] = "" 18 | 19 | set_unless[:php][:db_dumpfile_path] = "" 20 | 21 | # 22 | # Recommended attributes 23 | # 24 | set_unless[:php][:server_name] = "myserver" 25 | set_unless[:php][:application_name] = "myapp" 26 | 27 | # 28 | # Optional attributes 29 | # 30 | set_unless[:php][:code][:branch] = "master" 31 | set_unless[:php][:application_port] = "8000" 32 | set_unless[:php][:modules_list] = [] 33 | set_unless[:php][:db_adapter] = "mysql" 34 | 35 | # 36 | # Calculated attributes 37 | # 38 | set[:php][:code][:destination] = "/home/webapp/#{php[:application_name]}" 39 | 40 | case platform 41 | when "ubuntu", "debian" 42 | set[:php][:package_dependencies] = ["php5", "php5-mysql", "php-pear", "libapache2-mod-php5"] 43 | set[:php][:module_dependencies] = [ "proxy_http", "php5"] 44 | set_unless[:php][:app_user] = "www-data" 45 | when "centos","fedora","suse" 46 | set[:php][:package_dependencies] = ["php", "php-mysql", "php-pear"] 47 | set[:php][:module_dependencies] = [] 48 | set_unless[:php][:app_user] = "apache" 49 | end 50 | 51 | 52 | -------------------------------------------------------------------------------- /cookbooks/app_rails/attributes/rails.rb: -------------------------------------------------------------------------------- 1 | # Cookbook Name:: app_rails 2 | # 3 | # Copyright 2009, RightScale, Inc. 4 | # 5 | # All rights reserved - Do Not Redistribute 6 | # 7 | 8 | # 9 | # Required attributes 10 | # 11 | set_unless[:rails][:code][:url] = "" 12 | set_unless[:rails][:code][:user] = "" 13 | set_unless[:rails][:code][:credentials] = "" 14 | 15 | set_unless[:rails][:db_app_user] = "" 16 | set_unless[:rails][:db_app_passwd] = "" 17 | set_unless[:rails][:db_schema_name] = "" 18 | set_unless[:rails][:db_dns_name] = "" 19 | 20 | set_unless[:rails][:db_dumpfile_path] = "" 21 | 22 | # 23 | # Recommended attributes 24 | # 25 | set_unless[:rails][:server_name] = "myserver" 26 | set_unless[:rails][:application_name] = "myapp" 27 | set_unless[:rails][:env] = "production" 28 | 29 | # 30 | # Optional attributes 31 | # 32 | set_unless[:rails][:code][:branch] = "master" 33 | set_unless[:rails][:application_port] = "8000" 34 | set_unless[:rails][:spawn_method] = "conservative" 35 | set_unless[:rails][:gems_list] = "" 36 | set_unless[:rails][:db_adapter] = "mysql" 37 | 38 | # 39 | # Calculated attributes 40 | # 41 | set[:rails][:code][:destination] = "/home/webapp/#{rails[:application_name]}" 42 | 43 | # 44 | # Platform specific attributes 45 | # 46 | case platform 47 | when "redhat","centos","fedora","suse" 48 | set_unless[:rails][:app_user] = "apache" 49 | when "debian","ubuntu" 50 | set_unless[:rails][:app_user] = "www-data" 51 | else 52 | set_unless[:rails][:app_user] = "www-data" 53 | end 54 | 55 | -------------------------------------------------------------------------------- /cookbooks/db_mysql/recipes/client.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: mysql 3 | # Recipe:: client 4 | # 5 | # Copyright 2008-2009, Opscode, Inc. 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | 20 | p = package "mysql-devel" do 21 | package_name value_for_platform( 22 | [ "centos", "redhat", "suse" ] => { "default" => "mysql-devel" }, 23 | "default" => 'libmysqlclient15-dev' 24 | ) 25 | action :nothing 26 | end 27 | 28 | p.run_action(:install) 29 | 30 | package "mysql-client" do 31 | package_name value_for_platform( 32 | [ "centos", "redhat", "suse" ] => { "default" => "mysql" }, 33 | "default" => "mysql-client" 34 | ) 35 | action :install 36 | end 37 | 38 | r = execute "install mysql gem" do 39 | command "/opt/rightscale/sandbox/bin/gem install mysql --no-rdoc --no-ri -v 2.7 -- --build-flags --with-mysql-config" 40 | end 41 | r.run_action(:run) 42 | 43 | Gem.clear_paths 44 | Chef::Log.info("gem reload forced with Gem.clear_paths") 45 | 46 | # ready for mysql operations inside recipes and providers 47 | -------------------------------------------------------------------------------- /cookbooks/rs_utils/files/default/collectd-init-centos-with-monitor: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # collectd Startup script for the Collectd statistics gathering daemon 4 | # chkconfig: - 86 15 5 | # description: Collectd is a statistics gathering daemon used to collect \ 6 | # system information ie. cpu, memory, disk, network 7 | # processname: collectd 8 | # config: /etc/collectd.conf 9 | # config: /etc/sysconfig/collectd 10 | # pidfile: /var/run/collectd.pid 11 | 12 | # Source function library. 13 | . /etc/init.d/functions 14 | 15 | RETVAL=0 16 | ARGS="" 17 | prog="collectd" 18 | CONFIG=/etc/collectd.conf 19 | 20 | if [ -r /etc/default/$prog ]; then 21 | . /etc/default/$prog 22 | fi 23 | 24 | start () { 25 | echo -n $"Starting $prog: " 26 | if [ -r "$CONFIG" ] 27 | then 28 | daemon collectdmon -c /usr/sbin/collectd -P /var/run/collectdmon.pid -- -C "$CONFIG" 29 | RETVAL=$? 30 | echo 31 | [ $RETVAL -eq 0 ] && touch /var/lock/subsys/$prog 32 | fi 33 | } 34 | stop () { 35 | echo -n $"Stopping $prog: " 36 | killproc collectdmon 37 | RETVAL=$? 38 | echo 39 | [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$prog 40 | } 41 | # See how we were called. 42 | case "$1" in 43 | start) 44 | start 45 | ;; 46 | stop) 47 | stop 48 | ;; 49 | status) 50 | status $prog 51 | ;; 52 | restart|reload) 53 | stop 54 | start 55 | ;; 56 | condrestart) 57 | [ -f /var/lock/subsys/$prog ] && restart || : 58 | ;; 59 | *) 60 | echo $"Usage: $0 {start|stop|status|restart|reload|condrestart}" 61 | exit 1 62 | esac 63 | 64 | exit $? 65 | 66 | # vim:syntax=sh 67 | -------------------------------------------------------------------------------- /cookbooks/db_mysql/recipes/setup_my_cnf.rb: -------------------------------------------------------------------------------- 1 | # Cookbook Name:: db_mysql 2 | # Recipe:: setup_my_cnf 3 | # 4 | # Copyright (c) 2009 RightScale Inc 5 | # 6 | # Permission is hereby granted, free of charge, to any person obtaining 7 | # a copy of this software and associated documentation files (the 8 | # "Software"), to deal in the Software without restriction, including 9 | # without limitation the rights to use, copy, modify, merge, publish, 10 | # distribute, sublicense, and/or sell copies of the Software, and to 11 | # permit persons to whom the Software is furnished to do so, subject to 12 | # the following conditions: 13 | # 14 | # The above copyright notice and this permission notice shall be 15 | # included in all copies or substantial portions of the Software. 16 | # 17 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | 25 | # 26 | # Note! This does NOT restart mysql, only update the my.cnf 27 | # 28 | 29 | template value_for_platform([ "centos", "redhat", "suse" ] => {"default" => "/etc/my.cnf"}, "default" => "/etc/mysql/my.cnf") do 30 | source "my.cnf.erb" 31 | owner "root" 32 | group "root" 33 | mode "0644" 34 | variables( 35 | :server_id => @node[:db_mysql][:server_id] 36 | ) 37 | end 38 | 39 | -------------------------------------------------------------------------------- /cookbooks/rs_utils/files/default/file-stats.rb: -------------------------------------------------------------------------------- 1 | #! /usr/bin/ruby 2 | # Arguments: first the hostname to use to report the stats (instance ID if in EC2) 3 | # followed by a list of filenames to report 4 | 5 | require 'getoptlong' 6 | 7 | def usage 8 | puts("#{$0} -h [-i ] ...") 9 | puts(" -h: The hostname of the machine. When using EC2 use the instance ID") 10 | puts(" -i: The sample interval of the file check (in seconds). Default: 20 seconds") 11 | exit 12 | end 13 | 14 | opts = GetoptLong.new( 15 | [ '--hostname', '-h', GetoptLong::REQUIRED_ARGUMENT ], 16 | [ '--sample-interval', '-i', GetoptLong::OPTIONAL_ARGUMENT ] 17 | ) 18 | 19 | # default values 20 | hostname = nil 21 | sample_interval = 20 22 | 23 | opts.each do |opt, arg| 24 | case opt 25 | when '--hostname' 26 | hostname = arg 27 | when '--sample-interval' 28 | sample_interval = arg.to_i 29 | end 30 | arg.inspect 31 | end 32 | 33 | # Remaining arguments should be files to monitor 34 | files = ARGV 35 | 36 | # ensure we have all the needed params to run, show usage if we don't 37 | usage if !hostname 38 | usage if files.length == 0 39 | 40 | loop do 41 | files.each do |f| 42 | if File.exist? f 43 | size = File.size(f) 44 | now = Time.now 45 | age = (now - File.mtime(f)).to_i 46 | base = File.basename(f, '.*').gsub(/-/, '_') 47 | print "PUTVAL #{hostname}/file-#{base}/gauge-size interval=#{sample_interval} #{now.to_i}:#{size}\n" 48 | print "PUTVAL #{hostname}/file-#{base}/gauge-age interval=#{sample_interval} #{now.to_i}:#{age}\n" 49 | end 50 | end 51 | 52 | STDOUT.flush 53 | sleep sample_interval 54 | end 55 | 56 | -------------------------------------------------------------------------------- /cookbooks/repo_git/metadata.json: -------------------------------------------------------------------------------- 1 | { 2 | "providing": { 3 | "repo_git_pull(url, branch, dest, cred)": [ 4 | 5 | ] 6 | }, 7 | "long_description": "", 8 | "dependencies": { 9 | "git": [ 10 | 11 | ] 12 | }, 13 | "replacing": { 14 | 15 | }, 16 | "description": "Installs the git fast version control system", 17 | "maintainer": "RightScale, Inc.", 18 | "name": "repo_git", 19 | "recommendations": { 20 | 21 | }, 22 | "maintainer_email": "support@rightscale.com", 23 | "suggestions": { 24 | 25 | }, 26 | "platforms": { 27 | 28 | }, 29 | "version": "0.0.1", 30 | "recipes": { 31 | 32 | }, 33 | "attributes": { 34 | 35 | }, 36 | "conflicting": { 37 | 38 | }, 39 | "license": "Copyright (c) 2009 RightScale, Inc.\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n'Software'), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and\/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n" 40 | } -------------------------------------------------------------------------------- /cookbooks/app_php/recipes/do_db_restore.rb: -------------------------------------------------------------------------------- 1 | # Cookbook Name:: app_php 2 | # Recipe:: do_db_restore 3 | # 4 | # Copyright (c) 2009 RightScale Inc 5 | # 6 | # Permission is hereby granted, free of charge, to any person obtaining 7 | # a copy of this software and associated documentation files (the 8 | # "Software"), to deal in the Software without restriction, including 9 | # without limitation the rights to use, copy, modify, merge, publish, 10 | # distribute, sublicense, and/or sell copies of the Software, and to 11 | # permit persons to whom the Software is furnished to do so, subject to 12 | # the following conditions: 13 | # 14 | # The above copyright notice and this permission notice shall be 15 | # included in all copies or substantial portions of the Software. 16 | # 17 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | 25 | 26 | # restore application database schema from remote location 27 | db_mysql_restore "do database restore" do 28 | url @node[:php][:code][:url] 29 | branch @node[:php][:code][:branch] 30 | credentials @node[:php][:code][:credentials] 31 | file_path @node[:php][:db_mysqldump_file_path] 32 | schema_name @node[:php][:db_schema_name] 33 | end 34 | 35 | db_mysql_set_privileges "setup user privileges" do 36 | preset 'user' 37 | username @node[:php][:db_app_user] 38 | password @node[:php][:db_app_passwd] 39 | end 40 | -------------------------------------------------------------------------------- /cookbooks/app_rails/recipes/do_db_restore.rb: -------------------------------------------------------------------------------- 1 | # Cookbook Name:: app_rails 2 | # Recipe:: do_db_restore 3 | # 4 | # Copyright (c) 2009 RightScale Inc 5 | # 6 | # Permission is hereby granted, free of charge, to any person obtaining 7 | # a copy of this software and associated documentation files (the 8 | # "Software"), to deal in the Software without restriction, including 9 | # without limitation the rights to use, copy, modify, merge, publish, 10 | # distribute, sublicense, and/or sell copies of the Software, and to 11 | # permit persons to whom the Software is furnished to do so, subject to 12 | # the following conditions: 13 | # 14 | # The above copyright notice and this permission notice shall be 15 | # included in all copies or substantial portions of the Software. 16 | # 17 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | 25 | 26 | # restore application database schema from remote location 27 | db_mysql_restore "do database restore" do 28 | url @node[:rails][:code][:url] 29 | branch @node[:rails][:code][:branch] 30 | credentials @node[:rails][:code][:credentials] 31 | file_path @node[:rails][:db_mysqldump_file_path] 32 | schema_name @node[:rails][:db_schema_name] 33 | end 34 | 35 | db_mysql_set_privileges "setup user privileges" do 36 | preset 'user' 37 | username @node[:rails][:db_app_user] 38 | password @node[:rails][:db_app_passwd] 39 | end 40 | -------------------------------------------------------------------------------- /cookbooks/web_apache/attributes/apache.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: web_apache 3 | # Attributes:: apache 4 | # 5 | # Copyright (c) 2009 RightScale Inc 6 | # 7 | # Permission is hereby granted, free of charge, to any person obtaining 8 | # a copy of this software and associated documentation files (the 9 | # "Software"), to deal in the Software without restriction, including 10 | # without limitation the rights to use, copy, modify, merge, publish, 11 | # distribute, sublicense, and/or sell copies of the Software, and to 12 | # permit persons to whom the Software is furnished to do so, subject to 13 | # the following conditions: 14 | # 15 | # The above copyright notice and this permission notice shall be 16 | # included in all copies or substantial portions of the Software. 17 | # 18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 19 | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 21 | # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 22 | # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 23 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 24 | # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 25 | 26 | # 27 | # Recommended attributes 28 | # 29 | set_unless[:apache][:contact] = "root@localhost" 30 | 31 | # 32 | # Optional attributes 33 | # 34 | # Turning off Keepalive to prevent conflicting HAproxy 35 | set_unless[:apache][:keepalive] = "Off" 36 | # Turn on generation of "full" apache status 37 | set_unless[:apache][:extended_status] = "On" 38 | # worker = multithreaded 39 | # prefork = single-threaded (use for php) 40 | set_unless[:apache][:mpm] = "prefork" 41 | # Security: Configuring Server Signature 42 | set_unless[:apache][:serversignature] = "Off " 43 | 44 | 45 | -------------------------------------------------------------------------------- /cookbooks/rs_utils/recipes/install_mysql_collectd_plugin.rb: -------------------------------------------------------------------------------- 1 | 2 | # Cookbook Name:: rs_utils 3 | # Recipe:: install_mysql_collectd_plugin 4 | # 5 | # Copyright (c) 2009 RightScale Inc 6 | # 7 | # Permission is hereby granted, free of charge, to any person obtaining 8 | # a copy of this software and associated documentation files (the 9 | # "Software"), to deal in the Software without restriction, including 10 | # without limitation the rights to use, copy, modify, merge, publish, 11 | # distribute, sublicense, and/or sell copies of the Software, and to 12 | # permit persons to whom the Software is furnished to do so, subject to 13 | # the following conditions: 14 | # 15 | # The above copyright notice and this permission notice shall be 16 | # included in all copies or substantial portions of the Software. 17 | # 18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 19 | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 21 | # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 22 | # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 23 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 24 | # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 25 | 26 | Chef::Log.info "Installing MySQL collectd plugin" 27 | 28 | package "collectd-mysql" do 29 | only_if { @node[:platform] == "centos" } 30 | end 31 | 32 | remote_file "#{@node[:rs_utils][:collectd_plugin_dir]}/mysql.conf" do 33 | source "collectd.mysql.conf" 34 | notifies :restart, resources(:service => "collectd") 35 | end 36 | 37 | node[:rs_utils][:process_list] += " mysqld" 38 | template File.join(@node[:rs_utils][:collectd_plugin_dir], 'processes.conf') do 39 | source "processes.conf.erb" 40 | notifies :restart, resources(:service => "collectd") 41 | end 42 | -------------------------------------------------------------------------------- /config/rake.rb: -------------------------------------------------------------------------------- 1 | ### 2 | # Company and SSL Details 3 | ### 4 | 5 | # The company name - used for SSL certificates, and in srvious other places 6 | COMPANY_NAME = "RightScale, Inc." 7 | 8 | # The Country Name to use for SSL Certificates 9 | SSL_COUNTRY_NAME = "US" 10 | 11 | # The State Name to use for SSL Certificates 12 | SSL_STATE_NAME = "CA" 13 | 14 | # The Locality Name for SSL - typically, the city 15 | SSL_LOCALITY_NAME = "Santa Barbara" 16 | 17 | # What department? 18 | SSL_ORGANIZATIONAL_UNIT_NAME = "Support" 19 | 20 | # The SSL contact email address 21 | SSL_EMAIL_ADDRESS = "support@rightscale.com" 22 | 23 | # License for new Cookbooks 24 | # Can be :apachev2 or :none 25 | NEW_COOKBOOK_LICENSE = :none 26 | 27 | ########################## 28 | # Chef Repository Layout # 29 | ########################## 30 | 31 | # Where to install upstream cookbooks for serving 32 | COOKBOOK_PATH = "/srv/chef/cookbooks" 33 | 34 | # Where to install site-local modifications to upstream cookbooks 35 | SITE_COOKBOOK_PATH = "/srv/chef/site-cookbooks" 36 | 37 | # Where to install roles 38 | ROLE_PATH = "/srv/chef/roles" 39 | 40 | # Chef Config Path 41 | CHEF_CONFIG_PATH = "/etc/chef" 42 | 43 | # The location of the Chef Server Config file (on the server) 44 | CHEF_SERVER_CONFIG = File.join(CHEF_CONFIG_PATH, "server.rb") 45 | 46 | # The location of the Chef Client Config file (on the client) 47 | CHEF_CLIENT_CONFIG = File.join(CHEF_CONFIG_PATH, "client.rb") 48 | 49 | ### 50 | # Useful Extras (which you probably don't need to change) 51 | ### 52 | 53 | # The top of the repository checkout 54 | TOPDIR = File.expand_path(File.join(File.dirname(__FILE__), "..")) 55 | 56 | # Where to store certificates generated with ssl_cert 57 | CADIR = File.expand_path(File.join(TOPDIR, "certificates")) 58 | 59 | # Where to store the mtime cache for the recipe/template syntax check 60 | TEST_CACHE = File.expand_path(File.join(TOPDIR, ".rake_test_cache")) -------------------------------------------------------------------------------- /cookbooks/app_php/templates/default/php_web_app.conf.erb: -------------------------------------------------------------------------------- 1 | > 2 | ServerName <%= @params[:server_name] %> 3 | DocumentRoot <%= @params[:docroot] %> 4 | 5 | Deny from all 6 | 7 | 8 | > 9 | Options FollowSymLinks 10 | AllowOverride None 11 | Order allow,deny 12 | Allow from all 13 | 14 | 15 | RewriteEngine On 16 | # Uncomment for rewrite debugging 17 | #RewriteLog <%= @node[:apache][:log_dir] %>/http_rewrite_log 18 | #RewriteLogLevel 9 19 | 20 | # Enable status page for monitoring purposes 21 | RewriteCond %{REMOTE_ADDR} ^(127.0.0.1) 22 | RewriteRule ^(/server-status) $1 [H=server-status,L] 23 | 24 | # Redirects to a maintenance page if the specified file below exists 25 | # ...but it still allows images to be served 26 | RewriteCond %{DOCUMENT_ROOT}/system/maintenance.html -f 27 | RewriteCond %{SCRIPT_FILENAME} !/system/maintenance.html 28 | RewriteCond %{SCRIPT_FILENAME} !^(.+).(gif|png|jpg|css|js|swf)$ 29 | RewriteRule ^.*$ /system/maintenance.html [L] 30 | 31 | # Setup the logs in the appropriate directory 32 | CustomLog <%= @node[:apache][:log_dir] %>/access_log combined 33 | ErrorLog <%= @node[:apache][:log_dir] %>/error_log 34 | 35 | #Remote logging -- handle by syslog 36 | ErrorLog "|logger -p local3.info -t httperror" 37 | CustomLog "|logger -p local3.info -t http" combined 38 | 39 | LogLevel warn 40 | 41 | # Deflate 42 | AddOutputFilterByType DEFLATE text/html text/plain text/xml application/xml application/xhtml+xml text/javascript text/css application/x-javascript 43 | BrowserMatch ^Mozilla/4 gzip-only-text/html 44 | BrowserMatch ^Mozilla/4.0[678] no-gzip 45 | BrowserMatch bMSIE !no-gzip !gzip-only-text/html 46 | 47 | SetEnvIf User-Agent ".*MSIE.*" nokeepalive ssl-unclean-shutdown downgrade-1.0 48 | 49 | 50 | -------------------------------------------------------------------------------- /README.rdoc: -------------------------------------------------------------------------------- 1 | = RightScale Public Cookbooks 2 | 3 | = DESCRIPTION 4 | 5 | == Synopsis 6 | 7 | RightScale now supports server configuration using the open source integration 8 | framework called Chef[1]. 9 | 10 | Refer to the wiki (https://github.com/rightscale/cookbooks_public/wikis) for up-to-date 11 | documentation. 12 | 13 | Also use the built-in issues tracker (https://github.com/rightscale/cookbooks_public/issues) 14 | to report issues. 15 | 16 | == Supported Configuration 17 | 18 | These cookbooks have been tested on EC2 and Rackspace clouds using the RightScale 19 | platform ServerTemplates. 20 | 21 | == Work in Progress 22 | 23 | RightScale cookbooks are a work in progress, expect more documentation and examples in the near 24 | future. 25 | 26 | = ADDITIONAL RESOURCES 27 | 28 | * [1] Chef is http://wiki.opscode.com/display/chef/Home 29 | 30 | = LICENSE 31 | 32 | RightScale Public Cookbooks 33 | 34 | Copyright:: Copyright (c) 2009 RightScale, Inc. 35 | 36 | Permission is hereby granted, free of charge, to any person obtaining 37 | a copy of this software and associated documentation files (the 38 | 'Software'), to deal in the Software without restriction, including 39 | without limitation the rights to use, copy, modify, merge, publish, 40 | distribute, sublicense, and/or sell copies of the Software, and to 41 | permit persons to whom the Software is furnished to do so, subject to 42 | the following conditions: 43 | 44 | The above copyright notice and this permission notice shall be 45 | included in all copies or substantial portions of the Software. 46 | 47 | THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, 48 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 49 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 50 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 51 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 52 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 53 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 54 | -------------------------------------------------------------------------------- /cookbooks/rs_utils/metadata.rb: -------------------------------------------------------------------------------- 1 | maintainer "RightScale, Inc." 2 | maintainer_email "support@rightscale.com" 3 | license IO.read(File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'LICENSE'))) 4 | description "Installs common utilities used by RightScale instances." 5 | version "0.0.1" 6 | 7 | recipe "rs_utils::install_mysql_collectd_plugin", "Install mysql collectd plugin" 8 | recipe "rs_utils::install_utils", "Install utilities" 9 | recipe "rs_utils::install_file_stats_collectd_plugin", "Install file-stats.rb collectd plugin. This is used for mysql binary backup alerting." 10 | # 11 | # optional 12 | # 13 | attribute "rs_utils/timezone", 14 | :display_name => "Timezone", 15 | :description => "Sets the system time to the timezone of the specified input, which must be a valid zoneinfo/tz database entry. If the input is 'unset' the timezone will use the 'localtime' that's defined in your RightScale account under Settings -> User -> Preferences tab. You can find a list of valid examples from the timezone pulldown bar in the Preferences tab. The server will not be updated for daylight savings time. Ex: US/Pacific, US/Eastern", 16 | :required => false, 17 | :default => "UTC", 18 | :recipes => [ "rs_utils::install_utils", "rs_utils::default" ] 19 | 20 | attribute "rs_utils/process_list", 21 | :display_name => "Process List", 22 | :description => "A optional list of additional processes to monitor in the RightScale Dashboard. Ex: sshd crond", 23 | :required => false, 24 | :default => "", 25 | :recipes => [ "rs_utils::install_mysql_collectd_plugin", "rs_utils::install_utils", "rs_utils::default" ] 26 | 27 | attribute "rs_utils/private_ssh_key", 28 | :display_name => "Private SSH Key", 29 | :description => "The private SSH key of another instance that gets installed on this instance. It allows this instance to SSH into another instance to update the configuration files. Select input type 'key' from the dropdown and then select an SSH key that is installed on the other instance.", 30 | :required => false, 31 | :default => "", 32 | :recipes => [ "rs_utils::install_utils", "rs_utils::default" ] 33 | -------------------------------------------------------------------------------- /cookbooks/app_php/recipes/do_update_code.rb: -------------------------------------------------------------------------------- 1 | # Cookbook Name:: app_php 2 | # Recipe:: do_update_code 3 | # 4 | # Copyright (c) 2009 RightScale Inc 5 | # 6 | # Permission is hereby granted, free of charge, to any person obtaining 7 | # a copy of this software and associated documentation files (the 8 | # "Software"), to deal in the Software without restriction, including 9 | # without limitation the rights to use, copy, modify, merge, publish, 10 | # distribute, sublicense, and/or sell copies of the Software, and to 11 | # permit persons to whom the Software is furnished to do so, subject to 12 | # the following conditions: 13 | # 14 | # The above copyright notice and this permission notice shall be 15 | # included in all copies or substantial portions of the Software. 16 | # 17 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | 25 | 26 | # Check that we have the required attributes set 27 | raise "You must provide a URL to your application code repository" if ("#{@node[:php][:code][:url]}" == "") 28 | raise "You must provide a destination for your application code." if ("#{@node[:php][:code][:destination]}" == "") 29 | 30 | # Warn about missing optional attributes 31 | Chef::Log.warn("WARNING: You did not provide credentials for your code repository -- assuming public repository.") if ("#{@node[:php][:code][:credentials]}" == "") 32 | Chef::Log.info("You did not provide branch informaiton -- setting to default.") if ("#{@node[:php][:code][:branch]}" == "") 33 | 34 | # grab application source from remote repository 35 | repo_git_pull "Get Repository" do 36 | url @node[:php][:code][:url] 37 | branch @node[:php][:code][:branch] 38 | dest @node[:php][:code][:destination] 39 | cred @node[:php][:code][:credentials] 40 | end 41 | -------------------------------------------------------------------------------- /cookbooks/app_rails/templates/default/passenger_web_app.conf.erb: -------------------------------------------------------------------------------- 1 | 2 | > 3 | ServerName <%= @params[:server_name] %> 4 | DocumentRoot <%= @params[:docroot] %>/public 5 | 6 | Deny from all 7 | 8 | 9 | RailsBaseURI / 10 | RailsEnv <%= @params[:rails_env] %> 11 | 12 | RailsSpawnMethod <%= @node[:rails][:spawn_method] %> 13 | PassengerMaxPoolSize <%= @node[:rails][:max_pool_size] %> 14 | 15 | /public > 16 | Options FollowSymLinks 17 | AllowOverride None 18 | Order allow,deny 19 | Allow from all 20 | 21 | 22 | RewriteEngine On 23 | # Uncomment for rewrite debugging 24 | #RewriteLog <%= @node[:apache][:log_dir] %>/http_rewrite_log 25 | #RewriteLogLevel 9 26 | 27 | # Enable status page for monitoring purposes 28 | RewriteCond %{REMOTE_ADDR} ^(127.0.0.1) 29 | RewriteRule ^(/server-status) $1 [H=server-status,L] 30 | 31 | # Redirects to a maintenance page if the specified file below exists 32 | # ...but it still allows images to be served 33 | RewriteCond %{DOCUMENT_ROOT}/system/maintenance.html -f 34 | RewriteCond %{SCRIPT_FILENAME} !/system/maintenance.html 35 | RewriteCond %{SCRIPT_FILENAME} !^(.+).(gif|png|jpg|css|js|swf)$ 36 | RewriteRule ^.*$ /system/maintenance.html [L] 37 | 38 | # Setup the logs in the appropriate directory 39 | CustomLog <%= @node[:apache][:log_dir] %>/access.log combined 40 | ErrorLog <%= @node[:apache][:log_dir] %>/error.log 41 | 42 | # #Remote logging -- handle by syslog 43 | # ErrorLog "|logger -p local3.info -t httperror" 44 | # CustomLog "|logger -p local3.info -t http" combined 45 | 46 | LogLevel warn 47 | 48 | # Deflate 49 | AddOutputFilterByType DEFLATE text/html text/plain text/xml application/xml application/xhtml+xml text/javascript text/css application/x-javascript 50 | BrowserMatch ^Mozilla/4 gzip-only-text/html 51 | BrowserMatch ^Mozilla/4.0[678] no-gzip 52 | BrowserMatch bMSIE !no-gzip !gzip-only-text/html 53 | 54 | SetEnvIf User-Agent ".*MSIE.*" nokeepalive ssl-unclean-shutdown downgrade-1.0 55 | 56 | 57 | -------------------------------------------------------------------------------- /cookbooks/app_rails/recipes/do_update_code.rb: -------------------------------------------------------------------------------- 1 | # Cookbook Name:: app_rails 2 | # Recipe:: do_update_code 3 | # 4 | # Copyright (c) 2009 RightScale Inc 5 | # 6 | # Permission is hereby granted, free of charge, to any person obtaining 7 | # a copy of this software and associated documentation files (the 8 | # "Software"), to deal in the Software without restriction, including 9 | # without limitation the rights to use, copy, modify, merge, publish, 10 | # distribute, sublicense, and/or sell copies of the Software, and to 11 | # permit persons to whom the Software is furnished to do so, subject to 12 | # the following conditions: 13 | # 14 | # The above copyright notice and this permission notice shall be 15 | # included in all copies or substantial portions of the Software. 16 | # 17 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | 25 | 26 | # Check that we have the required attributes set 27 | raise "You must provide a URL to your application code repository" if ("#{@node[:rails][:code][:url]}" == "") 28 | raise "You must provide a destination for your application code." if ("#{@node[:rails][:code][:destination]}" == "") 29 | 30 | # Warn about missing optional attributes 31 | Chef::Log.warn("WARNING: You did not provide credentials for your code repository -- assuming public repository.") if ("#{@node[:rails][:code][:credentials]}" == "") 32 | Chef::Log.info("You did not provide branch informaiton -- setting to default.") if ("#{@node[:rails][:code][:branch]}" == "") 33 | 34 | # grab application source from remote repository 35 | repo_git_pull "Get Repository" do 36 | url @node[:rails][:code][:url] 37 | branch @node[:rails][:code][:branch] 38 | dest @node[:rails][:code][:destination] 39 | cred @node[:rails][:code][:credentials] 40 | end 41 | -------------------------------------------------------------------------------- /cookbooks/rs_utils/attributes/system.rb: -------------------------------------------------------------------------------- 1 | # Cookbook Name:: rs_utils 2 | # 3 | # Copyright (c) 2009 RightScale Inc 4 | # 5 | # Permission is hereby granted, free of charge, to any person obtaining 6 | # a copy of this software and associated documentation files (the 7 | # "Software"), to deal in the Software without restriction, including 8 | # without limitation the rights to use, copy, modify, merge, publish, 9 | # distribute, sublicense, and/or sell copies of the Software, and to 10 | # permit persons to whom the Software is furnished to do so, subject to 11 | # the following conditions: 12 | # 13 | # The above copyright notice and this permission notice shall be 14 | # included in all copies or substantial portions of the Software. 15 | # 16 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 20 | # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 21 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 22 | # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | # 25 | # RightScale Enviroment Attributes. 26 | # These are needed by all RightScale Cookbooks. Rs_utils should be included in all server templates 27 | # so these attributes are declared here. 28 | 29 | # 30 | # Optional attributes 31 | # 32 | set_unless[:rs_utils][:timezone] = "UTC" 33 | set_unless[:rs_utils][:process_list] = "" 34 | set_unless[:rs_utils][:hostname] = "" 35 | set_unless[:rs_utils][:private_ssh_key] = "" 36 | 37 | set_unless[:rs_utils][:mysql_binary_backup_file] = "/var/run/mysql-binary-backup" 38 | 39 | # 40 | # Platform specific attributes 41 | # 42 | case platform 43 | when "redhat","centos","fedora","suse" 44 | rs_utils[:logrotate_config] = "/etc/logrotate.d/syslog" 45 | rs_utils[:collectd_config] = "/etc/collectd.conf" 46 | rs_utils[:collectd_plugin_dir] = "/etc/collectd.d" 47 | when "debian","ubuntu" 48 | rs_utils[:logrotate_config] = "/etc/logrotate.d/syslog-ng" 49 | rs_utils[:collectd_config] = "/etc/collectd/collectd.conf" 50 | rs_utils[:collectd_plugin_dir] = "/etc/collectd/conf" 51 | end 52 | 53 | case kernel[:machine] 54 | when "i686" 55 | rs_utils[:collectd_lib] = "/usr/lib/collectd" 56 | else 57 | rs_utils[:collectd_lib] = "/usr/lib64/collectd" 58 | end 59 | -------------------------------------------------------------------------------- /cookbooks/db_mysql/definitions/db_mysql_restore.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: db_mysql 3 | # Definition:: db_mysql_restore 4 | # 5 | # Copyright (c) 2009 RightScale Inc 6 | # 7 | # Permission is hereby granted, free of charge, to any person obtaining 8 | # a copy of this software and associated documentation files (the 9 | # "Software"), to deal in the Software without restriction, including 10 | # without limitation the rights to use, copy, modify, merge, publish, 11 | # distribute, sublicense, and/or sell copies of the Software, and to 12 | # permit persons to whom the Software is furnished to do so, subject to 13 | # the following conditions: 14 | # 15 | # The above copyright notice and this permission notice shall be 16 | # included in all copies or substantial portions of the Software. 17 | # 18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 19 | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 21 | # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 22 | # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 23 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 24 | # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 25 | 26 | define :db_mysql_restore, url => nil, branch => 'master', user => nil, credentials => nil, file_path => nil, schema_name => nil, tmp_dir => '/tmp' do 27 | 28 | repo_params = params # see http://tickets.opscode.com/browse/CHEF-422 29 | 30 | dir = "#{params[:tmp_dir]}/db_mysql_restore" 31 | dumpfile = "#{dir}/#{params[:file_path]}" 32 | schema_name = params[:schema_name] 33 | 34 | # grab mysqldump file from remote repository 35 | repo_git_pull "Get mysqldump from git repository" do 36 | url repo_params[:url] 37 | branch repo_params[:branch] 38 | user repo_params[:user] 39 | dest dir 40 | cred repo_params[:credentials] 41 | end 42 | 43 | bash "unpack mysqldump file: #{dumpfile}" do 44 | not_if "echo \"show databases\" | mysql | grep -q \"^#{schema_name}$\"" 45 | user "root" 46 | cwd dir 47 | code <<-EOH 48 | set -e 49 | if [ ! -f #{dumpfile} ] 50 | then 51 | echo "ERROR: MySQL dumpfile not found! File: '#{dumpfile}'" 52 | exit 1 53 | fi 54 | mysqladmin -u root create #{schema_name} 55 | gunzip < #{dumpfile} | mysql -u root -b #{schema_name} 56 | EOH 57 | end 58 | 59 | end 60 | -------------------------------------------------------------------------------- /cookbooks/web_apache/metadata.json: -------------------------------------------------------------------------------- 1 | { 2 | "providing": { 3 | "web_apache::install_apache": [ 4 | 5 | ], 6 | "web_apache": [ 7 | 8 | ] 9 | }, 10 | "long_description": "", 11 | "dependencies": { 12 | "apache2": [ 13 | 14 | ] 15 | }, 16 | "replacing": { 17 | 18 | }, 19 | "description": "Installs\/configures the apache2 webserver", 20 | "maintainer": "RightScale, Inc.", 21 | "name": "web_apache", 22 | "recommendations": { 23 | 24 | }, 25 | "maintainer_email": "support@rightscale.com", 26 | "suggestions": { 27 | 28 | }, 29 | "platforms": { 30 | 31 | }, 32 | "version": "0.0.1", 33 | "recipes": { 34 | "web_apache::install_apache": "", 35 | "web_apache": "" 36 | }, 37 | "attributes": { 38 | "web_apache\/mpm": { 39 | "default": "worker", 40 | "type": "string", 41 | "multiple_values": false, 42 | "description": "Can be set to 'worker' or 'prefork' and defines the setting in httpd.conf. Use 'worker' for Rails\/Tomcat\/Standalone frontends and 'prefork' for PHP.", 43 | "display_name": "Multi-Processing Module", 44 | "recipes": [ 45 | "web_apache::install_apache", 46 | "web_apache::default" 47 | ], 48 | "required": false 49 | }, 50 | "web_apache": { 51 | "type": "hash", 52 | "multiple_values": false, 53 | "description": "Apache Web Server", 54 | "display_name": "apache hash", 55 | "recipes": [ 56 | 57 | ], 58 | "required": false 59 | } 60 | }, 61 | "conflicting": { 62 | 63 | }, 64 | "license": "Copyright (c) 2009 RightScale, Inc.\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n'Software'), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and\/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n" 65 | } -------------------------------------------------------------------------------- /cookbooks/db_mysql/definitions/db_mysql_set_privileges.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: db_mysql 3 | # Definition:: db_mysql_set_privileges 4 | # 5 | # Copyright (c) 2009 RightScale Inc 6 | # 7 | # Permission is hereby granted, free of charge, to any person obtaining 8 | # a copy of this software and associated documentation files (the 9 | # "Software"), to deal in the Software without restriction, including 10 | # without limitation the rights to use, copy, modify, merge, publish, 11 | # distribute, sublicense, and/or sell copies of the Software, and to 12 | # permit persons to whom the Software is furnished to do so, subject to 13 | # the following conditions: 14 | # 15 | # The above copyright notice and this permission notice shall be 16 | # included in all copies or substantial portions of the Software. 17 | # 18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 19 | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 21 | # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 22 | # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 23 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 24 | # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 25 | 26 | define :db_mysql_set_privileges, preset => "administrator", username => nil, password => nil do 27 | 28 | priv_preset = params[:preset] 29 | username = params[:username] 30 | password = params[:password] 31 | 32 | ruby_block "set admin credentials" do 33 | block do 34 | require 'rubygems' 35 | require 'mysql' 36 | 37 | con = Mysql.new("", "root",nil,nil,nil,"#{@node[:db_mysql][:socket]}") 38 | 39 | case priv_preset 40 | when 'administrator' 41 | con.query("GRANT ALL PRIVILEGES on *.* TO '#{username}'@'%' IDENTIFIED BY '#{password}' WITH GRANT OPTION") 42 | con.query("GRANT ALL PRIVILEGES on *.* TO '#{username}'@'localhost' IDENTIFIED BY '#{password}' WITH GRANT OPTION") 43 | when 'user' 44 | con.query("GRANT ALL PRIVILEGES on *.* TO '#{username}'@'%' IDENTIFIED BY '#{password}'") 45 | con.query("GRANT ALL PRIVILEGES on *.* TO '#{username}'@'localhost' IDENTIFIED BY '#{password}'") 46 | con.query("REVOKE SUPER on *.* FROM '#{username}'@'%' IDENTIFIED BY '#{password}'") 47 | con.query("REVOKE SUPER on *.* FROM '#{username}'@'localhost' IDENTIFIED BY '#{password}'") 48 | else 49 | raise "only 'administrator' and 'user' type presets are supported!" 50 | end 51 | 52 | con.query("FLUSH PRIVILEGES") 53 | con.close 54 | end 55 | end 56 | 57 | end 58 | -------------------------------------------------------------------------------- /cookbooks/rs_utils/recipes/install_file_stats_collectd_plugin.rb: -------------------------------------------------------------------------------- 1 | 2 | # Cookbook Name:: rs_utils 3 | # Recipe:: install_file_stats_collectd_plugin 4 | # 5 | # Copyright (c) 2009 RightScale Inc 6 | # 7 | # Permission is hereby granted, free of charge, to any person obtaining 8 | # a copy of this software and associated documentation files (the 9 | # "Software"), to deal in the Software without restriction, including 10 | # without limitation the rights to use, copy, modify, merge, publish, 11 | # distribute, sublicense, and/or sell copies of the Software, and to 12 | # permit persons to whom the Software is furnished to do so, subject to 13 | # the following conditions: 14 | # 15 | # The above copyright notice and this permission notice shall be 16 | # included in all copies or substantial portions of the Software. 17 | # 18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 19 | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 21 | # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 22 | # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 23 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 24 | # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 25 | 26 | require 'fileutils' 27 | 28 | Chef::Log.info "Installing file_stats collectd plugin.." 29 | 30 | template(::File.join(node[:rs_utils][:collectd_plugin_dir], "file-stats.conf")) do 31 | source "file-stats.conf.erb" 32 | notifies :restart, resources(:service => "collectd") 33 | end 34 | 35 | directory ::File.join(node[:rs_utils][:collectd_lib], "plugins") do 36 | action :create 37 | recursive true 38 | end 39 | 40 | remote_file(::File.join(node[:rs_utils][:collectd_lib], "plugins", 'file-stats.rb')) do 41 | source "file-stats.rb" 42 | mode "0755" 43 | notifies :restart, resources(:service => "collectd") 44 | end 45 | 46 | # used in db_mysql::do_backup in cookbooks_premium for backups 47 | file node[:rs_utils][:mysql_binary_backup_file] do 48 | action :touch 49 | owner "nobody" 50 | group value_for_platform([ "centos", "redhat", "suse" ] => {"default" => "nobody"}, "default" => "nogroup") 51 | end 52 | 53 | ruby_block "add_collectd_gauges" do 54 | block do 55 | types_file = ::File.join(node[:rs_utils][:collectd_lib], 'types.db') 56 | typesdb = IO.read(types_file) 57 | unless typesdb.include?('gague-age') && typesdb.include?('gague-size') 58 | typesdb += "\ngauge-age seconds:GAUGE:0:200000000\ngauge-size bytes:GAUGE:0:200000000\n" 59 | File.open(types_file, "w") { |f| f.write(typesdb) } 60 | end 61 | end 62 | end 63 | 64 | Chef::Log.info "Installed collectd file_stats plugin." 65 | -------------------------------------------------------------------------------- /cookbooks/app_php/recipes/install_php.rb: -------------------------------------------------------------------------------- 1 | # Cookbook Name:: app_php 2 | # Recipe:: install_php 3 | # 4 | # Copyright (c) 2009 RightScale Inc 5 | # 6 | # Permission is hereby granted, free of charge, to any person obtaining 7 | # a copy of this software and associated documentation files (the 8 | # "Software"), to deal in the Software without restriction, including 9 | # without limitation the rights to use, copy, modify, merge, publish, 10 | # distribute, sublicense, and/or sell copies of the Software, and to 11 | # permit persons to whom the Software is furnished to do so, subject to 12 | # the following conditions: 13 | # 14 | # The above copyright notice and this permission notice shall be 15 | # included in all copies or substantial portions of the Software. 16 | # 17 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | 25 | include_recipe "web_apache" 26 | 27 | [ @node[:php][:package_dependencies] | @node[:php][:modules_list] ].flatten.each do |p| 28 | package p 29 | end 30 | 31 | @node[:php][:module_dependencies].each do |mod| 32 | apache_module mod 33 | end 34 | 35 | # grab application source from remote repository 36 | include_recipe "app_php::do_update_code" 37 | 38 | php_port = @node[:php][:application_port] 39 | 40 | # if port 80, disable default vhost 41 | if php_port == "80" 42 | apache_site "000-default" do 43 | enable false 44 | end 45 | end 46 | 47 | ports = @node[:apache][:listen_ports].include?(php_port) \ 48 | ? @node[:apache][:listen_ports] \ 49 | : [@node[:apache][:listen_ports], php_port].flatten 50 | 51 | template "#{@node[:apache][:dir]}/ports.conf" do 52 | cookbook "apache2" 53 | source "ports.conf.erb" 54 | variables :apache_listen_ports => ports 55 | notifies :restart, resources(:service => "apache2") 56 | end 57 | 58 | web_app @node[:php][:application_name] do 59 | template "php_web_app.conf.erb" 60 | docroot @node[:php][:code][:destination] 61 | vhost_port @node[:php][:application_port] 62 | server_name @node[:php][:server_name] 63 | end 64 | 65 | directory File.join(@node[:php][:code][:destination], "config") do 66 | recursive true 67 | end 68 | 69 | template File.join(@node[:php][:code][:destination], "config", "db.php") do 70 | source "config_db.php.erb" 71 | variables({ 72 | :db_handle => "#{@node[:php][:db_dns_name]}:#{@node[:db_mysql][:socket]}" 73 | }) 74 | end 75 | 76 | bash "chown_home" do 77 | code <<-EOH 78 | chown -R #{@node[:php][:app_user]}:#{@node[:php][:app_user]} #{@node[:php][:code][:destination]} 79 | EOH 80 | end 81 | -------------------------------------------------------------------------------- /cookbooks/db_mysql/metadata.rb: -------------------------------------------------------------------------------- 1 | maintainer "RightScale, Inc." 2 | maintainer_email "support@rightscale.com" 3 | license IO.read(File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'LICENSE'))) 4 | description "Installs/configures a MySQL database server with automated backups." 5 | long_description IO.read(File.join(File.dirname(__FILE__), 'README.rdoc')) 6 | version "0.0.1" 7 | 8 | depends "mysql", "= 0.9" 9 | 10 | provides "db_mysql_restore(url, branch, user, credentials, file_path, schema_name, tmp_dir)" 11 | provides "db_mysql_set_privileges(type, username, password)" 12 | 13 | recipe "db_mysql::default", "Runs the 'install_mysql' recipes." 14 | recipe "db_mysql::install_mysql", "Installs packages required for MySQL servers without manual intervention." 15 | recipe "db_mysql::setup_admin_privileges", "Add username and password for superuser privileges." 16 | 17 | # 18 | # required attributes 19 | # 20 | attribute "db_mysql", 21 | :display_name => "General Database Options", 22 | :type => "hash" 23 | 24 | attribute "db/admin/user", 25 | :display_name => "Database Admin Username", 26 | :description => "The username of the database user that has 'admin' privileges.", 27 | :required => true, 28 | :recipes => [ "db_mysql::setup_admin_privileges" ] 29 | 30 | attribute "db/admin/password", 31 | :display_name => "Database Admin Password", 32 | :description => "The password of the database user that has 'admin' privileges.", 33 | :required => true, 34 | :recipes => [ "db_mysql::setup_admin_privileges" ] 35 | 36 | # 37 | # recommended attributes 38 | # 39 | attribute "db_mysql/server_usage", 40 | :display_name => "Server Usage", 41 | :description => "* dedicated (where the mysql config file allocates all existing resources of the machine)\n* shared (where the MySQL config file is configured to use less resources so that it can be run concurrently with other apps like Apache and Rails for example)", 42 | :recipes => [ "db_mysql::install_mysql", "db_mysql::default" ], 43 | :default => "dedicated" 44 | 45 | # 46 | # optional attributes 47 | # 48 | #attribute "db_mysql/log_bin", 49 | # :display_name => "MySQL Binlog Destination", 50 | # :description => "Defines the filename and location of your MySQL stored binlog files. This sets the log-bin variable in the MySQL config file. If you do not specify an absolute path, it will be relative to the data directory.", 51 | # :recipes => [ "db_mysql::install_mysql", "db_mysql::default" ], 52 | # :default => "/mnt/mysql-binlogs/mysql-bin" 53 | 54 | #attribute "db_mysql/datadir_relocate", 55 | # :display_name => "MySQL Data-Directory Destination", 56 | # :description => "Sets the final destination of the MySQL data directory. (i.e. an LVM or EBS volume)", 57 | # :default => "/mnt/mysql" 58 | 59 | #attribute "db_mysql/tmpdir", 60 | # :display_name => "MySQL Tmp Directory", 61 | # :description => "Sets the tmp variable in the MySQL config file.", 62 | # :default => "/tmp" 63 | 64 | -------------------------------------------------------------------------------- /cookbooks/repo_git/definitions/repo_git_pull.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: repo_git 3 | # Definition:: repo_git_pull 4 | # 5 | # Copyright (c) 2009 RightScale Inc 6 | # 7 | # Permission is hereby granted, free of charge, to any person obtaining 8 | # a copy of this software and associated documentation files (the 9 | # "Software"), to deal in the Software without restriction, including 10 | # without limitation the rights to use, copy, modify, merge, publish, 11 | # distribute, sublicense, and/or sell copies of the Software, and to 12 | # permit persons to whom the Software is furnished to do so, subject to 13 | # the following conditions: 14 | # 15 | # The above copyright notice and this permission notice shall be 16 | # included in all copies or substantial portions of the Software. 17 | # 18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 19 | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 21 | # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 22 | # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 23 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 24 | # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 25 | 26 | require 'uri' 27 | 28 | define :repo_git_pull, url => "", branch => "master", dest => "", cred => "" do 29 | 30 | # include the public recipe to install git 31 | include_recipe "git" 32 | 33 | # add repository credentials 34 | keyfile = nil 35 | if "#{params[:cred]}" != "" 36 | keyfile = "/tmp/gitkey" 37 | bash 'create_temp_git_ssh_key' do 38 | code <<-EOH 39 | echo -n '#{params[:cred]}' > #{keyfile} 40 | chmod 700 #{keyfile} 41 | echo 'exec ssh -oStrictHostKeyChecking=no -i #{keyfile} "$@"' > #{keyfile}.sh 42 | chmod +x #{keyfile}.sh 43 | EOH 44 | end 45 | end 46 | 47 | # pull repo (if exist) 48 | ruby "pull-exsiting-local-repo" do 49 | cwd params[:dest] 50 | only_if do File.directory?(params[:dest]) end 51 | code <<-EOH 52 | puts "Updateing existing repo at #{params[:dest]}" 53 | ENV["GIT_SSH"] = "#{keyfile}.sh" unless ("#{keyfile}" == "") 54 | puts `git pull` 55 | EOH 56 | end 57 | 58 | # clone repo (if not exist) 59 | ruby "create-new-local-repo" do 60 | not_if do File.directory?(params[:dest]) end 61 | code <<-EOH 62 | puts "Creating new repo at #{params[:dest]}" 63 | ENV["GIT_SSH"] = "#{keyfile}.sh" unless ("#{keyfile}" == "") 64 | puts `git clone #{params[:url]} -- #{params[:dest]}` 65 | 66 | if "#{params[:branch]}" != "master" 67 | dir = "#{params[:dest]}" 68 | Dir.chdir(dir) 69 | puts `git checkout --track -b #{params[:branch]} origin/#{params[:branch]}` 70 | end 71 | EOH 72 | end 73 | 74 | # delete SSH key & clear GIT_SSH 75 | if params[:cred] != nil 76 | bash 'delete_temp_git_ssh_key' do 77 | code <<-EOH 78 | rm -f #{keyfile} 79 | rm -f #{keyfile}.sh 80 | EOH 81 | end 82 | end 83 | 84 | end 85 | -------------------------------------------------------------------------------- /cookbooks/db_mysql/attributes/mysql.rb: -------------------------------------------------------------------------------- 1 | # Cookbook Name:: db_mysql 2 | # 3 | # Copyright (c) 2009 RightScale Inc 4 | # 5 | # Permission is hereby granted, free of charge, to any person obtaining 6 | # a copy of this software and associated documentation files (the 7 | # "Software"), to deal in the Software without restriction, including 8 | # without limitation the rights to use, copy, modify, merge, publish, 9 | # distribute, sublicense, and/or sell copies of the Software, and to 10 | # permit persons to whom the Software is furnished to do so, subject to 11 | # the following conditions: 12 | # 13 | # The above copyright notice and this permission notice shall be 14 | # included in all copies or substantial portions of the Software. 15 | # 16 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 20 | # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 21 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 22 | # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | # 25 | # Required attributes 26 | # 27 | set_unless[:db_mysql][:admin_user] = nil 28 | set_unless[:db_mysql][:admin_password] = nil 29 | set_unless[:db_mysql][:server_id] = Time.now.to_i 30 | 31 | # 32 | # Recommended attributes 33 | # 34 | set_unless[:db_mysql][:server_usage] = "dedicated" # or "shared" 35 | 36 | # 37 | # Optional attributes 38 | # 39 | set_unless[:db_mysql][:datadir_relocate] = "/mnt/mysql" 40 | set_unless[:db_mysql][:log_bin_enabled] = true 41 | set_unless[:db_mysql][:log_bin] = "/mnt/mysql-binlogs/mysql-bin" 42 | set_unless[:db_mysql][:tmpdir] = "/tmp" 43 | set_unless[:db_mysql][:datadir] = "/var/lib/mysql" 44 | set_unless[:db_mysql][:bind_address] = ipaddress 45 | 46 | # 47 | # Platform specific attributes 48 | 49 | set_unless[:db_mysql][:kill_bug_mysqld_safe] = true 50 | 51 | case platform 52 | when "redhat","centos","fedora","suse" 53 | set_unless[:db_mysql][:socket] = "/var/lib/mysql/mysql.sock" 54 | set_unless[:db_mysql][:basedir] = "/usr" 55 | set_unless[:db_mysql][:packages_uninstall] = "" 56 | set_unless[:db_mysql][:packages_install] = [ 57 | "perl-DBD-MySQL", "mysql-server", "mysql-devel", "mysql-connector-odbc", 58 | # not available on CentOS 5.4? 59 | # "mysqlclient14-devel", "mysqlclient14", "mysqlclient10-devel", "mysqlclient10", 60 | "krb5-libs" 61 | ] 62 | set_unless[:db_mysql][:log] = "" 63 | set_unless[:db_mysql][:log_error] = "" 64 | when "debian","ubuntu" 65 | set_unless[:db_mysql][:socket] = "/var/run/mysqld/mysqld.sock" 66 | set_unless[:db_mysql][:basedir] = "/usr" 67 | set_unless[:db_mysql][:packages_uninstall] = "apparmor" 68 | set_unless[:db_mysql][:packages_install] = ["mysql-server-5.0", "tofrodos"] 69 | set_unless[:db_mysql][:log] = "log = /var/log/mysql.log" 70 | set_unless[:db_mysql][:log_error] = "log_error = /var/log/mysql.err" 71 | else 72 | set_unless[:db_mysql][:socket] = "/var/run/mysqld/mysqld.sock" 73 | set_unless[:db_mysql][:basedir] = "/usr" 74 | set_unless[:db_mysql][:packages_uninstall] = "" 75 | set_unless[:db_mysql][:packages_install] = ["mysql-server-5.0"] 76 | set_unless[:db_mysql][:log] = "log = /var/log/mysql.log" 77 | set_unless[:db_mysql][:log_error] = "log_error = /var/log/mysql.err" 78 | end 79 | -------------------------------------------------------------------------------- /cookbooks/web_apache/recipes/install_apache.rb: -------------------------------------------------------------------------------- 1 | # Cookbook Name:: web_apache 2 | # Recipe:: install_apache 3 | # 4 | # Copyright (c) 2009 RightScale Inc 5 | # 6 | # Permission is hereby granted, free of charge, to any person obtaining 7 | # a copy of this software and associated documentation files (the 8 | # "Software"), to deal in the Software without restriction, including 9 | # without limitation the rights to use, copy, modify, merge, publish, 10 | # distribute, sublicense, and/or sell copies of the Software, and to 11 | # permit persons to whom the Software is furnished to do so, subject to 12 | # the following conditions: 13 | # 14 | # The above copyright notice and this permission notice shall be 15 | # included in all copies or substantial portions of the Software. 16 | # 17 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | 25 | package "apache2" do 26 | case node[:platform] 27 | when "centos","redhat","fedora","suse" 28 | package_name "httpd" 29 | when "debian","ubuntu" 30 | package_name "apache2" 31 | end 32 | action :install 33 | end 34 | 35 | service "apache2" do 36 | # If restarted/reloaded too quickly apache has a habit of failing 37 | # This may happen with multiple recipes notifying apache to restart - like 38 | # during the initial bootstrap. 39 | case node[:platform] 40 | when "centos","redhat","fedora","suse" 41 | service_name "httpd" 42 | restart_command "/sbin/service httpd restart && sleep 1" 43 | reload_command "/sbin/service httpd reload && sleep 1" 44 | when "debian","ubuntu" 45 | service_name "apache2" 46 | restart_command "service apache2 restart && sleep 1" 47 | reload_command "service apache2 reload && sleep 1" 48 | end 49 | action :nothing 50 | end 51 | 52 | # include the public recipe for basic installation 53 | include_recipe "apache2" 54 | 55 | ## Move Apache 56 | content_dir = '/mnt/www' 57 | ruby 'move_apache' do 58 | not_if do File.directory?(content_dir) end 59 | code <<-EOH 60 | `mkdir -p #{content_dir}` 61 | `cp -rf /var/www/. #{content_dir}` 62 | `rm -rf /var/www` 63 | `ln -nsf #{content_dir} /var/www` 64 | EOH 65 | end 66 | 67 | ## Move Apache Logs 68 | apache_name = @node[:apache][:dir].split("/").last 69 | ruby 'move_apache_logs' do 70 | not_if do File.symlink?(@node[:apache][:log_dir]) end 71 | code <<-EOH 72 | `rm -rf #{@node[:apache][:log_dir]}` 73 | `mkdir -p /mnt/log/#{apache_name}` 74 | `ln -s /mnt/log/#{apache_name} #{@node[:apache][:log_dir]}` 75 | EOH 76 | end 77 | 78 | # Configuring Apache Multi-Processing Module 79 | case node[:platform] 80 | when "centos","redhat","fedora","suse" 81 | 82 | binary_to_use = @node[:apache][:binary] 83 | if @node[:apache][:mpm] != 'prefork' 84 | binary_to_use << ".worker" 85 | end 86 | 87 | template "/etc/sysconfig/httpd" do 88 | source "sysconfig_httpd.erb" 89 | mode "0644" 90 | variables( 91 | :sysconfig_httpd => binary_to_use 92 | ) 93 | notifies :reload, resources(:service => "apache2") 94 | end 95 | when "debian","ubuntu" 96 | package "apache2-mpm-#{node[:apache][:mpm]}" 97 | end 98 | 99 | # Log resource submitted to opscode. http://tickets.opscode.com/browse/CHEF-923 100 | log "Started the apache server." 101 | 102 | -------------------------------------------------------------------------------- /cookbooks/app_rails/recipes/install_rails.rb: -------------------------------------------------------------------------------- 1 | # Cookbook Name:: app_rails 2 | # Recipe:: install_rails 3 | # 4 | # Copyright (c) 2009 RightScale Inc 5 | # 6 | # Permission is hereby granted, free of charge, to any person obtaining 7 | # a copy of this software and associated documentation files (the 8 | # "Software"), to deal in the Software without restriction, including 9 | # without limitation the rights to use, copy, modify, merge, publish, 10 | # distribute, sublicense, and/or sell copies of the Software, and to 11 | # permit persons to whom the Software is furnished to do so, subject to 12 | # the following conditions: 13 | # 14 | # The above copyright notice and this permission notice shall be 15 | # included in all copies or substantial portions of the Software. 16 | # 17 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | 25 | 26 | include_recipe "web_apache" 27 | include_recipe "rails" 28 | include_recipe "passenger_apache2::mod_rails" 29 | include_recipe "mysql::client" 30 | 31 | # install optional gems required for the application 32 | @node[:rails][:gems_list].each { |gem| gem_package gem } unless "#{@node[:rails][:gems_list]}" == "" 33 | 34 | # grab application source from remote repository 35 | include_recipe "app_rails::do_update_code" 36 | 37 | # reconfigure existing database.yml, or create from scratch 38 | include_recipe "app_rails::setup_db_config" 39 | 40 | # this should work but chef breaks -- https://tickets.opscode.com/browse/CHEF-205 41 | #directory @node[:rails][:code][:destination] do 42 | #owner 'www-data' 43 | #group 'www-data' 44 | #mode 0755 45 | #recursive true 46 | #end 47 | 48 | #we'll just do this for now... 49 | 50 | #chown application directory 51 | bash "chown_home" do 52 | code <<-EOH 53 | echo "chown -R #{@node[:rails][:app_user]}:#{@node[:rails][:app_user]} #{@node[:rails][:code][:destination]}" >> /tmp/bash 54 | chown -R #{@node[:rails][:app_user]}:#{@node[:rails][:app_user]} #{@node[:rails][:code][:destination]} 55 | EOH 56 | end 57 | 58 | passenger_port = @node[:rails][:application_port] 59 | 60 | # if port 80, disable default vhost 61 | if passenger_port == "80" 62 | apache_site "000-default" do 63 | enable false 64 | end 65 | end 66 | 67 | ports = @node[:apache][:listen_ports].include?(passenger_port) \ 68 | ? @node[:apache][:listen_ports] \ 69 | : [@node[:apache][:listen_ports], passenger_port].flatten 70 | 71 | template "#{@node[:apache][:dir]}/ports.conf" do 72 | cookbook "apache2" 73 | source "ports.conf.erb" 74 | variables :apache_listen_ports => ports 75 | notifies :restart, resources(:service => "apache2") 76 | end 77 | 78 | # setup the passenger vhost 79 | web_app @node[:rails][:application_name] do 80 | template "passenger_web_app.conf.erb" 81 | docroot @node[:rails][:code][:destination] 82 | vhost_port @node[:rails][:application_port] 83 | server_name @node[:rails][:server_name] 84 | rails_env @node[:rails][:env] 85 | end 86 | 87 | # Move rails logs to /mnt (TODO:create move definition in rs_tools?) 88 | rails_log = '/mnt/log/rails' 89 | ruby 'move_rails_log' do 90 | not_if do File.symlink?('/var/log/rails') end 91 | code <<-EOH 92 | `rm -rf /var/log/rails` 93 | `mkdir -p #{rails_log}` 94 | `ln -s #{rails_log} /var/log/rails` 95 | EOH 96 | end 97 | 98 | # configure logrotate for rails (TODO: create logrotate definition) 99 | template "/etc/logrotate.d/rails" do 100 | source "logrotate.conf.erb" 101 | variables( 102 | :app_name => "rails" 103 | ) 104 | end 105 | 106 | -------------------------------------------------------------------------------- /cookbooks/rs_utils/metadata.json: -------------------------------------------------------------------------------- 1 | { 2 | "providing": { 3 | "rs_utils::install_file_stats_collectd_plugin": [ 4 | 5 | ], 6 | "rs_utils::install_utils": [ 7 | 8 | ], 9 | "rs_utils": [ 10 | 11 | ], 12 | "rs_utils::install_mysql_collectd_plugin": [ 13 | 14 | ] 15 | }, 16 | "long_description": "", 17 | "dependencies": { 18 | 19 | }, 20 | "replacing": { 21 | 22 | }, 23 | "description": "Installs common utilities used by RightScale instances.", 24 | "maintainer": "RightScale, Inc.", 25 | "name": "rs_utils", 26 | "recommendations": { 27 | 28 | }, 29 | "maintainer_email": "support@rightscale.com", 30 | "suggestions": { 31 | 32 | }, 33 | "platforms": { 34 | 35 | }, 36 | "version": "0.0.1", 37 | "recipes": { 38 | "rs_utils::install_file_stats_collectd_plugin": "Install file-stats.rb collectd plugin. This is used for mysql binary backup alerting.", 39 | "rs_utils::install_utils": "Install utilities", 40 | "rs_utils": "", 41 | "rs_utils::install_mysql_collectd_plugin": "Install mysql collectd plugin" 42 | }, 43 | "attributes": { 44 | "rs_utils\/process_list": { 45 | "default": "", 46 | "type": "string", 47 | "multiple_values": false, 48 | "description": "A optional list of additional processes to monitor in the RightScale Dashboard. Ex: sshd crond", 49 | "display_name": "Process List", 50 | "recipes": [ 51 | "rs_utils::install_mysql_collectd_plugin", 52 | "rs_utils::install_utils", 53 | "rs_utils::default" 54 | ], 55 | "required": false 56 | }, 57 | "rs_utils\/private_ssh_key": { 58 | "default": "", 59 | "type": "string", 60 | "multiple_values": false, 61 | "description": "The private SSH key of another instance that gets installed on this instance. It allows this instance to SSH into another instance to update the configuration files. Select input type 'key' from the dropdown and then select an SSH key that is installed on the other instance.", 62 | "display_name": "Private SSH Key", 63 | "recipes": [ 64 | "rs_utils::install_utils", 65 | "rs_utils::default" 66 | ], 67 | "required": false 68 | }, 69 | "rs_utils\/timezone": { 70 | "default": "UTC", 71 | "type": "string", 72 | "multiple_values": false, 73 | "description": "Sets the system time to the timezone of the specified input, which must be a valid zoneinfo\/tz database entry. If the input is 'unset' the timezone will use the 'localtime' that's defined in your RightScale account under Settings -> User -> Preferences tab. You can find a list of valid examples from the timezone pulldown bar in the Preferences tab. The server will not be updated for daylight savings time. Ex: US\/Pacific, US\/Eastern", 74 | "display_name": "Timezone", 75 | "recipes": [ 76 | "rs_utils::install_utils", 77 | "rs_utils::default" 78 | ], 79 | "required": false 80 | } 81 | }, 82 | "conflicting": { 83 | 84 | }, 85 | "license": "Copyright (c) 2009 RightScale, Inc.\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n'Software'), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and\/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n" 86 | } -------------------------------------------------------------------------------- /cookbooks/rs_utils/templates/default/syslog.erb: -------------------------------------------------------------------------------- 1 | # syslog-ng configuration file. 2 | # 3 | # See syslog-ng(8) and syslog-ng.conf(5) for more information. 4 | 5 | options { 6 | sync (0); 7 | time_reopen (10); 8 | log_fifo_size (1000); 9 | long_hostnames (off); 10 | use_dns (no); 11 | use_fqdn (no); 12 | create_dirs (yes); 13 | keep_hostname (yes); 14 | log_msg_size(8192); 15 | }; 16 | 17 | source s_sys { 18 | file ("/proc/kmsg" log_prefix("kernel: ")); 19 | unix-stream ("/dev/log"); 20 | internal(); 21 | udp(ip(127.0.0.1) port(514)); 22 | }; 23 | 24 | destination d_cons { file("/dev/console"); }; 25 | destination d_mesg { file("/var/log/messages"); }; 26 | destination d_auth { file("/var/log/secure"); }; 27 | destination d_mail { file("/var/log/maillog" sync(10)); }; 28 | destination d_spol { file("/var/log/spooler"); }; 29 | destination d_boot { file("/var/log/boot.log"); }; 30 | destination d_cron { file("/var/log/cron"); }; 31 | destination d_mlal { usertty("*"); }; 32 | destination d_rail { file("/var/log/rails/rails.log"); }; 33 | destination d_daem { file("/var/log/rails/daemons.log"); }; 34 | destination d_hpxy { file("/var/log/httpd/haproxy.log"); }; 35 | #destination d_http { file("/var/log/httpd/http.log"); }; 36 | #destination d_https { file("/var/log/httpd/https.log"); }; 37 | destination d_httperror { file("/var/log/httpd/error_log"); }; 38 | destination d_dhcp { pipe("/dev/null.syslog-ng"); }; 39 | destination d_udp { udp("<%= @node[:rightscale][:servers][:lumberjack][:hostname] %>" template("<$PRI>$DATE <%= @node[:rightscale][:servers][:lumberjack][:identifier] %> $MSG")); }; 40 | 41 | # 42 | # fun stuff 43 | # 44 | # Rails is recognized program rails 45 | filter f_rail { facility(local0) or program(rails); }; 46 | log { source(s_sys); filter(f_rail); destination(d_rail); }; 47 | # Application daemons should use facility local1 48 | filter f_daem { facility(local1); }; 49 | log { source(s_sys); filter(f_daem); destination(d_daem); }; 50 | # HAproxy should log to facility local2 51 | filter f_hpxy { facility(local2); }; 52 | log { source(s_sys); filter(f_hpxy); destination(d_hpxy); }; 53 | # Ship (almost) everything to central syslog system 54 | filter f_udp { not facility(authpriv) or (program(dhclient) and match(DHCPREQUEST)); }; 55 | log { source(s_sys); filter(f_udp); destination(d_udp); }; 56 | # Messages -- need to exclude everything else 57 | filter f_mesg { level(info..emerg) and 58 | not (facility(mail,authpriv,cron,local0,local1,local2,local3) or 59 | (program(dhclient) and match(DHCPREQUEST)) or 60 | program(rails)); }; 61 | log { source(s_sys); filter(f_mesg); destination(d_mesg); }; 62 | # Apache 63 | #these are configured in the vhost 64 | #filter f_http { facility(local3) and match(http); }; 65 | #log { source(s_sys); filter(f_http); destination(d_http); }; 66 | #filter f_https { facility(local3) and match(https); }; 67 | #log { source(s_sys); filter(f_https); destination(d_https); }; 68 | filter f_httperror { facility(local3) and match(httperror); }; 69 | log { source(s_sys); filter(f_httperror); destination(d_httperror); }; 70 | # 71 | # std stuff 72 | # 73 | filter f_filter3 { facility(authpriv); }; 74 | log { source(s_sys); filter(f_filter3); destination(d_auth); }; 75 | filter f_filter4 { facility(mail); }; 76 | log { source(s_sys); filter(f_filter4); destination(d_mail); }; 77 | filter f_filter5 { level(emerg); }; 78 | log { source(s_sys); filter(f_filter5); destination(d_mlal); }; 79 | filter f_filter8 { facility(cron); }; 80 | log { source(s_sys); filter(f_filter8); destination(d_cron); }; 81 | filter f_filter11 { program(dhclient) and match(DHCPREQUEST); }; 82 | log { source(s_sys); filter(f_filter11); destination(d_dhcp); }; 83 | 84 | # stuff that is not particularly useful... 85 | #filter f_filter1 { facility(kern); }; 86 | #log { source(s_sys); filter(f_filter1); destination(d_cons); }; 87 | #filter f_filter6 { facility(uucp) or 88 | # (facility(news) and level(crit..emerg)); }; 89 | #log { source(s_sys); filter(f_filter6); destination(d_spol); }; 90 | #filter f_filter7 { facility(local7); }; 91 | #log { source(s_sys); filter(f_filter7); destination(d_boot); }; 92 | -------------------------------------------------------------------------------- /cookbooks/db_mysql/metadata.json: -------------------------------------------------------------------------------- 1 | { 2 | "providing": { 3 | "db_mysql::setup_my_cnf": [ 4 | 5 | ], 6 | "db_mysql::client": [ 7 | 8 | ], 9 | "db_mysql": [ 10 | 11 | ], 12 | "db_mysql_restore(url, branch, user, credentials, file_path, schema_name, tmp_dir)": [ 13 | 14 | ], 15 | "db_mysql_set_privileges(type, username, password)": [ 16 | 17 | ], 18 | "db_mysql::install_mysql": [ 19 | 20 | ], 21 | "db_mysql::setup_admin_privileges": [ 22 | 23 | ] 24 | }, 25 | "long_description": "= DESCRIPTION:\n\nConfigures MySQL database servers that act as a Master-DB. Specifically designed for RightScale's Manager for MySQL-EBS. Storage of MySQL data will be done using EBS Volumes. EBS Snapshots are used for database backups.\n\n= REQUIREMENTS:\n\n* The Opscode's public cookbooks must be in your cookbook path -- the 'mysql' cookbook is used for client install.\n\n= ATTRIBUTES: \n\nSee metadata.rb \n\n= USAGE:\n\nDesigned to be run within a RightScale ServerTemplate with the following run order:\n\nBoot Scripts\n * install_mysql - Performs base server install and configuration.\n\nDefinitions\n * db_mysql_restore - Restores database from MySQL dump retrieved from a remote location.\n * db_mysql_set_privileges - Configures a user's privileges. Currently only 'administrator' and 'user' settings are supported.\n", 26 | "dependencies": { 27 | "mysql": [ 28 | "= 0.9" 29 | ] 30 | }, 31 | "replacing": { 32 | 33 | }, 34 | "description": "Installs\/configures a MySQL database server with automated backups.", 35 | "maintainer": "RightScale, Inc.", 36 | "name": "db_mysql", 37 | "recommendations": { 38 | 39 | }, 40 | "maintainer_email": "support@rightscale.com", 41 | "suggestions": { 42 | 43 | }, 44 | "platforms": { 45 | 46 | }, 47 | "version": "0.0.1", 48 | "recipes": { 49 | "db_mysql::setup_my_cnf": "", 50 | "db_mysql::client": "", 51 | "db_mysql::default": "Runs the 'install_mysql' recipes.", 52 | "db_mysql": "", 53 | "db_mysql::install_mysql": "Installs packages required for MySQL servers without manual intervention.", 54 | "db_mysql::setup_admin_privileges": "Add username and password for superuser privileges." 55 | }, 56 | "attributes": { 57 | "db_mysql\/server_usage": { 58 | "default": "dedicated", 59 | "type": "string", 60 | "multiple_values": false, 61 | "description": "* dedicated (where the mysql config file allocates all existing resources of the machine)\n* shared (where the MySQL config file is configured to use less resources so that it can be run concurrently with other apps like Apache and Rails for example)", 62 | "display_name": "Server Usage", 63 | "recipes": [ 64 | "db_mysql::install_mysql", 65 | "db_mysql::default" 66 | ], 67 | "required": false 68 | }, 69 | "db_mysql": { 70 | "type": "hash", 71 | "multiple_values": false, 72 | "display_name": "General Database Options", 73 | "recipes": [ 74 | 75 | ], 76 | "required": false 77 | }, 78 | "db\/admin\/password": { 79 | "type": "string", 80 | "multiple_values": false, 81 | "description": "The password of the database user that has 'admin' privileges.", 82 | "display_name": "Database Admin Password", 83 | "recipes": [ 84 | "db_mysql::setup_admin_privileges" 85 | ], 86 | "required": true 87 | }, 88 | "db\/admin\/user": { 89 | "type": "string", 90 | "multiple_values": false, 91 | "description": "The username of the database user that has 'admin' privileges.", 92 | "display_name": "Database Admin Username", 93 | "recipes": [ 94 | "db_mysql::setup_admin_privileges" 95 | ], 96 | "required": true 97 | } 98 | }, 99 | "conflicting": { 100 | 101 | }, 102 | "license": "Copyright (c) 2009 RightScale, Inc.\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n'Software'), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and\/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n" 103 | } -------------------------------------------------------------------------------- /cookbooks/rs_utils/recipes/install_utils.rb: -------------------------------------------------------------------------------- 1 | # Cookbook Name:: rs_utils 2 | # Recipe:: install_utils 3 | # 4 | # Copyright (c) 2009 RightScale Inc 5 | # 6 | # Permission is hereby granted, free of charge, to any person obtaining 7 | # a copy of this software and associated documentation files (the 8 | # "Software"), to deal in the Software without restriction, including 9 | # without limitation the rights to use, copy, modify, merge, publish, 10 | # distribute, sublicense, and/or sell copies of the Software, and to 11 | # permit persons to whom the Software is furnished to do so, subject to 12 | # the following conditions: 13 | # 14 | # The above copyright notice and this permission notice shall be 15 | # included in all copies or substantial portions of the Software. 16 | # 17 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | 25 | #TODO: this compat package should no longer be necessary, chef service resource does not 26 | # require this and it was only used for legacy templates afaik. 27 | #install rs_utils command for ubuntu 28 | #package "sysvconfig" do 29 | # only_if { @node[:platform] == "ubuntu" } 30 | #end 31 | 32 | #setup timezone 33 | link "/usr/share/zoneinfo/#{@node[:rs_utils][:timezone]}" do 34 | to "/etc/localtime" 35 | end 36 | 37 | #configure syslog 38 | if "#{@node[:rightscale][:servers][:lumberjack][:hostname]}" != "" 39 | package "syslog-ng" 40 | 41 | execute "ensure_dev_null" do 42 | creates "/dev/null.syslog-ng" 43 | command "mknod /dev/null.syslog-ng c 1 3" 44 | end 45 | 46 | service "syslog-ng" do 47 | supports :start => true, :stop => true, :restart => true 48 | action [ :enable ] 49 | end 50 | 51 | template "/etc/syslog-ng/syslog-ng.conf" do 52 | source "syslog.erb" 53 | notifies :restart, resources(:service => "syslog-ng") 54 | end 55 | 56 | bash "configure_logrotate_for_syslog" do 57 | code <<-EOH 58 | perl -p -i -e 's/weekly/daily/; s/rotate\s+\d+/rotate 7/' /etc/logrotate.conf 59 | [ -z "$(grep -lir "missingok" #{@node[:rs_utils][:logrotate_config]}_file)" ] && sed -i '/sharedscripts/ a\ missingok' #{@node[:rs_utils][:logrotate_config]} 60 | [ -z "$(grep -lir "notifempty" #{@node[:rs_utils][:logrotate_config]}_file)" ] && sed -i '/sharedscripts/ a\ notifempty' #{@node[:rs_utils][:logrotate_config]} 61 | EOH 62 | end 63 | end 64 | 65 | directory "/var/spool/oldmail" do 66 | recursive true 67 | mode "775" 68 | owner "root" 69 | group "mail" 70 | end 71 | 72 | remote_file "/etc/logrotate.d/mail" do 73 | source "mail" 74 | end 75 | 76 | #configure collectd 77 | package "collectd" 78 | 79 | # use collectdmon 80 | if node[:platform] == 'centos' 81 | remote_file "/etc/init.d/collectd" do 82 | source "collectd-init-centos-with-monitor" 83 | mode 0755 84 | end 85 | end 86 | 87 | service "collectd" do 88 | action :enable 89 | end 90 | 91 | # create collectd types.db file unless it already exists 92 | unless ::File.exists?(::File.join(node[:rs_utils][:collectd_lib], 'types.db')) 93 | if node[:platform] == "ubuntu" && node[:platform_version] == "9.10" 94 | remote_file ::File.join(node[:rs_utils][:collectd_lib], 'types.db') do 95 | source "karmic_types.db" 96 | end 97 | end 98 | end 99 | 100 | package "liboping0" do 101 | only_if { @node[:platform] == "ubuntu" } 102 | end 103 | 104 | directory @node[:rs_utils][:collectd_plugin_dir] do 105 | recursive true 106 | end 107 | 108 | template @node[:rs_utils][:collectd_config] do 109 | source "collectd.config.erb" 110 | notifies :restart, resources(:service => "collectd") 111 | end 112 | 113 | # configure process monitoring 114 | template File.join(@node[:rs_utils][:collectd_plugin_dir], 'processes.conf') do 115 | source "processes.conf.erb" 116 | notifies :restart, resources(:service => "collectd") 117 | end 118 | 119 | right_link_tag "rs_monitoring:state=active" 120 | 121 | # TODO: remove, this is legacy 122 | #configure cron 123 | #cron "collectd_restart" do 124 | # day "4" 125 | # command "service collectd restart" 126 | #end 127 | 128 | #install private key 129 | if "#{@node[:rs_utils][:private_ssh_key]}" != "" 130 | directory "/root/.ssh" do 131 | recursive true 132 | end 133 | template "/root/.ssh/id_rsa" do 134 | source "id_rsa.erb" 135 | mode 0600 136 | end 137 | end 138 | 139 | #set hostname 140 | if "#{@node[:rs_utils][:hostname]}" != "" 141 | execute "set_hostname" do 142 | command "hostname #{@node[:rs_utils][:hostname]}" 143 | end 144 | end 145 | -------------------------------------------------------------------------------- /cookbooks/rs_utils/files/default/karmic_types.db: -------------------------------------------------------------------------------- 1 | apache_bytes count:COUNTER:0:134217728 2 | apache_connections count:GAUGE:0:65535 3 | apache_requests count:COUNTER:0:134217728 4 | apache_scoreboard count:GAUGE:0:65535 5 | bitrate value:GAUGE:0:4294967295 6 | bytes value:GAUGE:0:U 7 | cache_result value:COUNTER:0:4294967295 8 | cache_size value:GAUGE:0:4294967295 9 | charge value:GAUGE:0:U 10 | compression_ratio value:GAUGE:0:2 11 | connections value:COUNTER:0:U 12 | counter value:COUNTER:U:U 13 | cpufreq value:GAUGE:0:U 14 | cpu value:COUNTER:0:4294967295 15 | current value:GAUGE:U:U 16 | delay seconds:GAUGE:-1000000:1000000 17 | df used:GAUGE:0:1125899906842623, free:GAUGE:0:1125899906842623 18 | disk_merged read:COUNTER:0:4294967295, write:COUNTER:0:4294967295 19 | disk_octets read:COUNTER:0:17179869183, write:COUNTER:0:17179869183 20 | disk_ops read:COUNTER:0:4294967295, write:COUNTER:0:4294967295 21 | disk_time read:COUNTER:0:1000000, write:COUNTER:0:1000000 22 | dns_answer value:COUNTER:0:65535 23 | dns_notify value:COUNTER:0:65535 24 | dns_octets queries:COUNTER:0:125000000, responses:COUNTER:0:125000000 25 | dns_opcode value:COUNTER:0:65535 26 | dns_qtype value:COUNTER:0:65535 27 | dns_qtype_cached value:GAUGE:0:4294967295 28 | dns_query value:COUNTER:0:65535 29 | dns_question value:COUNTER:0:65535 30 | dns_rcode value:COUNTER:0:65535 31 | dns_reject value:COUNTER:0:65535 32 | dns_request value:COUNTER:0:65535 33 | dns_resolver value:COUNTER:0:65535 34 | dns_response value:COUNTER:0:65535 35 | dns_transfer value:COUNTER:0:65535 36 | dns_update value:COUNTER:0:65535 37 | dns_zops value:COUNTER:0:65535 38 | email_check value:GAUGE:0:U 39 | email_count value:GAUGE:0:U 40 | email_size value:GAUGE:0:U 41 | entropy entropy:GAUGE:0:4294967295 42 | fanspeed value:GAUGE:0:U 43 | files value:GAUGE:0:U 44 | frequency frequency:GAUGE:0:U 45 | frequency_offset ppm:GAUGE:-1000000:1000000 46 | gauge value:GAUGE:U:U 47 | humidity value:GAUGE:0:100 48 | if_collisions value:COUNTER:0:4294967295 49 | if_dropped rx:COUNTER:0:4294967295, tx:COUNTER:0:4294967295 50 | if_errors rx:COUNTER:0:4294967295, tx:COUNTER:0:4294967295 51 | if_multicast value:COUNTER:0:4294967295 52 | if_octets rx:COUNTER:0:4294967295, tx:COUNTER:0:4294967295 53 | if_packets rx:COUNTER:0:4294967295, tx:COUNTER:0:4294967295 54 | if_rx_errors value:COUNTER:0:4294967295 55 | if_tx_errors value:COUNTER:0:4294967295 56 | io_octets rx:COUNTER:0:4294967295, tx:COUNTER:0:4294967295 57 | io_packets rx:COUNTER:0:4294967295, tx:COUNTER:0:4294967295 58 | ipt_bytes value:COUNTER:0:134217728 59 | ipt_packets value:COUNTER:0:134217728 60 | irq value:COUNTER:U:65535 61 | latency value:GAUGE:0:65535 62 | load shortterm:GAUGE:0:100, midterm:GAUGE:0:100, longterm:GAUGE:0:100 63 | memcached_command value:COUNTER:0:U 64 | memcached_connections value:GAUGE:0:U 65 | memcached_items value:GAUGE:0:U 66 | memcached_octets rx:COUNTER:0:4294967295, tx:COUNTER:0:4294967295 67 | memcached_ops value:COUNTER:0:134217728 68 | memory value:GAUGE:0:281474976710656 69 | multimeter value:GAUGE:U:U 70 | mysql_commands value:COUNTER:0:U 71 | mysql_handler value:COUNTER:0:U 72 | mysql_octets rx:COUNTER:0:4294967295, tx:COUNTER:0:4294967295 73 | mysql_qcache hits:COUNTER:0:U, inserts:COUNTER:0:U, not_cached:COUNTER:0:U, lowmem_prunes:COUNTER:0:U, queries_in_cache:GAUGE:0:U 74 | mysql_threads running:GAUGE:0:U, connected:GAUGE:0:U, cached:GAUGE:0:U, created:COUNTER:0:U 75 | nfs_procedure value:COUNTER:0:4294967295 76 | nginx_connections value:GAUGE:0:U 77 | nginx_requests value:COUNTER:0:134217728 78 | operations value:COUNTER:0:4294967295 79 | percent percent:GAUGE:0:100.1 80 | pg_blks value:COUNTER:0:U 81 | pg_db_size value:GAUGE:0:U 82 | pg_n_tup_c value:COUNTER:0:U 83 | pg_n_tup_g value:GAUGE:0:U 84 | pg_numbackends value:GAUGE:0:U 85 | pg_scan value:COUNTER:0:U 86 | pg_xact value:COUNTER:0:U 87 | ping ping:GAUGE:0:65535 88 | players value:GAUGE:0:1000000 89 | power value:GAUGE:0:U 90 | ps_count processes:GAUGE:0:1000000, threads:GAUGE:0:1000000 91 | ps_cputime user:COUNTER:0:16000000, syst:COUNTER:0:16000000 92 | ps_pagefaults minflt:COUNTER:0:9223372036854775807, majflt:COUNTER:0:9223372036854775807 93 | ps_rss value:GAUGE:0:9223372036854775807 94 | ps_stacksize value:GAUGE:0:9223372036854775807 95 | ps_state value:GAUGE:0:65535 96 | ps_vm value:GAUGE:0:9223372036854775807 97 | queue_length value:GAUGE:0:U 98 | serial_octets rx:COUNTER:0:4294967295, tx:COUNTER:0:4294967295 99 | signal_noise value:GAUGE:U:0 100 | signal_power value:GAUGE:U:0 101 | signal_quality value:GAUGE:0:U 102 | spam_check value:GAUGE:0:U 103 | spam_score value:GAUGE:U:U 104 | swap value:GAUGE:0:1099511627776 105 | tcp_connections value:GAUGE:0:4294967295 106 | temperature value:GAUGE:-273.15:U 107 | time_dispersion seconds:GAUGE:-1000000:1000000 108 | timeleft timeleft:GAUGE:0:3600 109 | time_offset seconds:GAUGE:-1000000:1000000 110 | users users:GAUGE:0:65535 111 | virt_cpu_total ns:COUNTER:0:256000000000 112 | virt_vcpu ns:COUNTER:0:1000000000 113 | vmpage_action value:COUNTER:0:4294967295 114 | vmpage_faults minflt:COUNTER:0:9223372036854775807, majflt:COUNTER:0:9223372036854775807 115 | vmpage_io in:COUNTER:0:4294967295, out:COUNTER:0:4294967295 116 | vmpage_number value:GAUGE:0:4294967295 117 | voltage_threshold value:GAUGE:U:U, threshold:GAUGE:U:U 118 | voltage value:GAUGE:U:U 119 | vs_memory value:GAUGE:0:9223372036854775807 120 | vs_processes value:GAUGE:0:65535 121 | vs_threads value:GAUGE:0:65535 122 | -------------------------------------------------------------------------------- /cookbooks/db_mysql/templates/centos/init-mysql.erb: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # mysqld This shell script takes care of starting and stopping 4 | # the MySQL subsystem (mysqld). 5 | # 6 | # chkconfig: - 64 36 7 | # description: MySQL database server. 8 | # processname: mysqld 9 | # config: /etc/my.cnf 10 | # pidfile: /var/run/mysqld/mysqld.pid 11 | 12 | # Source function library. 13 | . /etc/rc.d/init.d/functions 14 | 15 | # Source networking configuration. 16 | . /etc/sysconfig/network 17 | 18 | prog="MySQL" 19 | MYADMIN="/usr/bin/mysqladmin" 20 | 21 | # *** Wait for process to be alive, connected, and innodb ready. 22 | # on startup: timeout results in failure status even if mysql is half up (and connection is available). 23 | # innodb *must be enabled 24 | START_TIMEOUT=<%= @node[:db_mysql][:init_timeout] %> 25 | 26 | # *** Wait for process to exit 27 | # on shutdown: timeout results in forced shutdown, do not set this too low! 28 | STOP_TIMEOUT=<%= @node[:db_mysql][:init_timeout] %> 29 | 30 | # extract value of a MySQL option from config files 31 | # Usage: get_mysql_option SECTION VARNAME DEFAULT 32 | # result is returned in $result 33 | # We use my_print_defaults which prints all options from multiple files, 34 | # with the more specific ones later; hence take the last match. 35 | get_mysql_option(){ 36 | result=`/usr/bin/my_print_defaults "$1" | sed -n "s/^--$2=//p" | tail -n 1` 37 | if [ -z "$result" ]; then 38 | # not found, use default 39 | result="$3" 40 | fi 41 | } 42 | 43 | get_mysql_option mysqld datadir "/var/lib/mysql" 44 | datadir="$result" 45 | get_mysql_option mysqld socket "$datadir/mysql.sock" 46 | socketfile="$result" 47 | get_mysql_option mysqld_safe log-error "/var/log/mysqld.log" 48 | errlogfile="$result" 49 | get_mysql_option mysqld_safe pid-file "/var/run/mysqld/mysqld.pid" 50 | mypidfile="$result" 51 | 52 | start(){ 53 | # check if mysql is already running 54 | check_pid 55 | if [ $PID_ALIVE -eq 0 ]; then 56 | echo "already running" 57 | start_failed; exit 1 58 | fi 59 | 60 | touch "$errlogfile" 61 | chown mysql:mysql "$errlogfile" 62 | chmod 0640 "$errlogfile" 63 | [ -x /sbin/restorecon ] && /sbin/restorecon "$errlogfile" 64 | if [ ! -d "$datadir/mysql" ] ; then 65 | action $"Initializing MySQL database: " /usr/bin/mysql_install_db 66 | ret=$? 67 | chown -R mysql:mysql "$datadir" 68 | if [ $ret -ne 0 ] ; then 69 | return $ret 70 | fi 71 | fi 72 | chown mysql:mysql "$datadir" 73 | chmod 0755 "$datadir" 74 | # Pass all the options determined above, to ensure consistent behavior. 75 | # In many cases mysqld_safe would arrive at the same conclusions anyway 76 | # but we need to be sure. 77 | /usr/bin/mysqld_safe --datadir="$datadir" --relay_log="$datadir/mysqld-relay-bin" --socket="$socketfile" \ 78 | --log-error="$errlogfile" --pid-file="$mypidfile" \ 79 | >/dev/null 2>&1 & 80 | ret=$? 81 | if [ $ret -eq 0 ]; then 82 | wait_for_startup 83 | if [ $STARTED -eq 0 ]; then 84 | start_success 85 | else 86 | start_failed 87 | fi 88 | else 89 | start_failed 90 | fi 91 | } 92 | 93 | stop() { 94 | check_pid 95 | if [ $PID_ALIVE -eq 0 ]; then 96 | kill_and_wait 97 | if [ $KILLED -eq 0 ]; then 98 | stop_success 99 | else 100 | kill_and_wait 9 101 | # we will never fail to kill 102 | stop_success 103 | fi 104 | else 105 | echo "not running" 106 | stop_failed 107 | fi 108 | } 109 | 110 | restart(){ 111 | stop 112 | start 113 | } 114 | 115 | condrestart(){ 116 | [ -e /var/lock/subsys/mysqld ] && restart || : 117 | } 118 | 119 | # Checks that pid file exists and that process is running 120 | check_pid() { 121 | MYSQLPID=`cat "$mypidfile" 2>/dev/null ` 122 | PID_ALIVE=1 123 | if [ -n "$MYSQLPID" ]; then 124 | ps $MYSQLPID > /dev/null 2>&1 125 | if [ $? -eq 0 ]; then PID_ALIVE=0; fi 126 | fi 127 | } 128 | 129 | # Check for innodb engine status 130 | check_innodb() { 131 | INNODB_ALIVE=1 132 | $MYADMIN variables 2> /dev/null | egrep -q have_innodb.*YES 133 | if [ $? -eq 0 ]; then INNODB_ALIVE=0; fi 134 | } 135 | 136 | # wait N seconds for mysqld to be ready 137 | wait_for_startup() { 138 | STARTTIMEOUT=$START_TIMEOUT 139 | while [ 1 ]; do 140 | check_innodb 141 | if [ $INNODB_ALIVE -eq 0 ]; then STARTED=0; break; fi 142 | if [ $STARTTIMEOUT -eq 0 ]; then STARTED=1; break; fi 143 | let STARTTIMEOUT=${STARTTIMEOUT}-1 144 | sleep 1 145 | done 146 | } 147 | 148 | start_failed() { 149 | action $"Starting $prog: " /bin/false 150 | return 1 151 | } 152 | 153 | start_success() { 154 | action $"Starting $prog: " /bin/true 155 | touch /var/lock/subsys/mysqld 156 | return 0 157 | } 158 | 159 | # send kill signal 160 | kill_and_wait() { 161 | if [ "$1" = "9" ]; then 162 | echo "killing mysql with signal 9" 163 | # mysqld_safe will restart mysql if we do not remove pid 164 | rm -f $mypidfile 165 | /bin/kill -9 "$MYSQLPID" >/dev/null 2>&1 166 | else 167 | /bin/kill "$MYSQLPID" >/dev/null 2>&1 168 | fi 169 | KILLED=$? 170 | # wait for death 171 | STOPTIMEOUT=$STOP_TIMEOUT 172 | while [ $STOPTIMEOUT -gt 0 ]; do 173 | /bin/kill -0 "$MYSQLPID" >/dev/null 2>&1 || break 174 | sleep 1 175 | let STOPTIMEOUT=${STOPTIMEOUT}-1 176 | done 177 | if [ $STOPTIMEOUT -eq 0 ]; then 178 | echo "timeout occured" 179 | KILLED=1 180 | fi 181 | } 182 | 183 | stop_success() { 184 | rm -f /var/lock/subsys/mysqld 185 | rm -f "$socketfile" 186 | action $"Stopping $prog: " /bin/true 187 | return 0 188 | } 189 | 190 | stop_failed() { 191 | action $"Stopping $prog: " /bin/false 192 | return 1 193 | } 194 | 195 | # MAIN 196 | case "$1" in 197 | start) 198 | start 199 | ;; 200 | stop) 201 | stop 202 | ;; 203 | status) 204 | status mysqld 205 | ;; 206 | restart) 207 | restart 208 | ;; 209 | condrestart) 210 | condrestart 211 | ;; 212 | *) 213 | echo $"Usage: $0 {start|stop|status|condrestart|restart}" 214 | exit 1 215 | esac 216 | 217 | exit $? 218 | -------------------------------------------------------------------------------- /cookbooks/app_php/metadata.rb: -------------------------------------------------------------------------------- 1 | maintainer "RightScale, Inc." 2 | maintainer_email "support@rightscale.com" 3 | license IO.read(File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'LICENSE'))) 4 | description "Installs the php application server." 5 | long_description IO.read(File.join(File.dirname(__FILE__), 'README.rdoc')) 6 | version "0.0.1" 7 | 8 | depends "web_apache" 9 | depends "repo_git" 10 | depends "repo_git_pull(url, branch, dest, cred)" 11 | 12 | recipe "app_php::default", "Runs app_php::install_php." 13 | recipe "app_php::do_db_restore", "Restore the application database schema from a remote location." 14 | recipe "app_php::do_update_code", "Update application source files from the remote repository." 15 | recipe "app_php::install_php", "Installs the php application server." 16 | 17 | attribute "php", 18 | :display_name => "PHP Application Settings", 19 | :type => "hash" 20 | 21 | # 22 | # required attributes 23 | # 24 | attribute "php/db_app_user", 25 | :display_name => "Database User", 26 | :description => "If the MySQL administrator set up a restricted MySQL account for application servers to access the database, then specify the username of that account for this input. If there is not a restricted MySQL account then use the same value that's used for 'Database Admin Username'. The application server will then have unrestricted access to the database.", 27 | :required => true, 28 | :recipes => [ "app_php::do_db_restore" ] 29 | 30 | attribute "php/db_app_passwd", 31 | :display_name => "Database Password", 32 | :description => "If the MySQL administrator set up a restricted MySQL account for application servers to access the database, then specify the password of that account for this input. If there is not a restricted MySQL account then use the same value that's used for 'Database Admin Password'. The application server will then have unrestricted access to the database.", 33 | :required => true, 34 | :recipes => [ "app_php::do_db_restore" ] 35 | 36 | attribute "php/db_schema_name", 37 | :display_name => "Database Schema Name", 38 | :description => "Enter the name of the MySQL database schema to which applications will connect. The database schema was created when the initial database was first set up. This input will be used to set the application server's database config file so that applications can connect to the correct schema within the database. This input is also used for MySQL dump backups in order to determine which schema is getting backed up. Ex: mydbschema", 39 | :required => true, 40 | :recipes => [ "app_php::do_db_restore" ] 41 | 42 | attribute "php/db_dns_name", 43 | :display_name => "Database Dns Name", 44 | :description => "The fully qualified domain name of the database server to which the application server(s) will connect. Ex: master.mydatabase.com", 45 | :required => true, 46 | :recipes => [ "app_php::install_php", "app_php::default" ] 47 | 48 | attribute "php/code", 49 | :display_name => "PHP Application Code", 50 | :type => "hash" 51 | 52 | attribute "php/code/url", 53 | :display_name => "Repository URL", 54 | :description => "Specify the URL location of the repository that contains the application code. Ex: git://github.com/mysite/myapp.git", 55 | :required => true, 56 | :recipes => [ "app_php::do_update_code", "app_php::do_db_restore", "app_php::install_php", "app_php::default" ] 57 | 58 | attribute "php/code/credentials", 59 | :display_name => "Repository Credentials", 60 | :description => "The private SSH key of the git repository.", 61 | :required => false, 62 | :default => "", 63 | :recipes => [ "app_php::do_update_code", "app_php::do_db_restore", "app_php::install_php", "app_php::default" ] 64 | 65 | # 66 | # recommended attributes 67 | # 68 | attribute "php/server_name", 69 | :display_name => "Server Name", 70 | :description => "The fully qualified domain name of the application server used to define your virtual host.", 71 | :required => true, 72 | :recipes => [ "app_php::install_php", "app_php::default" ] 73 | 74 | attribute "php/application_name", 75 | :display_name => "Application Name", 76 | :description => "Sets the directory for your application's web files (/home/webapps/Application Name/current/). If you have multiple applications, you can run the code checkout script multiple times, each with a different value for APPLICATION, so each application will be stored in a unique directory. This must be a valid directory name. Do not use symbols in the name.", 77 | :default => "myapp", 78 | :recipes => [ "app_php::install_php", "app_php::default" ] 79 | 80 | attribute "php/db_mysqldump_file_path", 81 | :display_name => "Mysqldump File Path", 82 | :description => "This input allows you to restore your database by choosing a specific MySQL database backup file. You will need to specify a full path and/or filename. Ex: branch/mydb-200910300402.gz", 83 | :recipes => [ "app_php::do_db_restore" ] 84 | 85 | # 86 | # optional attributes 87 | # 88 | 89 | attribute "php/code/branch", 90 | :display_name => "Repository Branch", 91 | :description => "The name of the branch within the git repository where the application code should be pulled from.", 92 | :default => "master", 93 | :recipes => [ "app_php::do_update_code", "app_php::do_db_restore", "app_php::install_php", "app_php::default" ] 94 | 95 | attribute "php/application_port", 96 | :display_name => "Application Port", 97 | :description => "This input is normally set to 8000 if this server is a combined HAProxy and application server. If this is an application server (w/o HAproxy), set it to 80. When setting this in a deployment, you should use 80 at the deployment level since you want all of your servers in the array to use this value. If the server is a FE+APP server, you can set it to 8000 at the server level so that it overrides the deployment level input.", 98 | :default => "8000", 99 | :recipes => [ "app_php::install_php", "app_php::default" ] 100 | 101 | #attribute "php/modules_list", 102 | # :display_name => "PHP modules", 103 | # :discription => "An optional list of php modules to install", 104 | # :type => "array", 105 | # :recipes => [ "app_php::install_php" ] 106 | 107 | -------------------------------------------------------------------------------- /cookbooks/db_mysql/templates/default/init-mysql.erb: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | ### BEGIN INIT INFO 4 | # Provides: mysql 5 | # Required-Start: $remote_fs $syslog mysql-ndb 6 | # Required-Stop: $remote_fs $syslog mysql-ndb 7 | # Should-Start: $network $named $time 8 | # Should-Stop: $network $named $time 9 | # Default-Start: 2 3 4 5 10 | # Default-Stop: 0 1 6 11 | # Short-Description: Start and stop the mysql database server daemon 12 | # Description: Controls the main MySQL database server daemon "mysqld" 13 | # and its wrapper script "mysqld_safe". 14 | ### END INIT INFO 15 | # 16 | set -e 17 | set -u 18 | ${DEBIAN_SCRIPT_DEBUG:+ set -v -x} 19 | 20 | test -x /usr/sbin/mysqld || exit 0 21 | 22 | . /lib/lsb/init-functions 23 | 24 | SELF=$(cd $(dirname $0); pwd -P)/$(basename $0) 25 | CONF=/etc/mysql/my.cnf 26 | MYADMIN="/usr/bin/mysqladmin --defaults-file=/etc/mysql/debian.cnf" 27 | 28 | # priority can be overriden and "-s" adds output to stderr 29 | ERR_LOGGER="logger -p daemon.err -t /etc/init.d/mysql -i" 30 | 31 | # Safeguard (relative paths, core dumps..) 32 | cd / 33 | umask 077 34 | 35 | # mysqladmin likes to read /root/.my.cnf. This is usually not what I want 36 | # as many admins e.g. only store a password without a username there and 37 | # so break my scripts. 38 | export HOME=/etc/mysql/ 39 | 40 | ## Fetch a particular option from mysql's invocation. 41 | # 42 | # Usage: void mysqld_get_param option 43 | mysqld_get_param() { 44 | /usr/sbin/mysqld --print-defaults \ 45 | | tr " " "\n" \ 46 | | grep -- "--$1" \ 47 | | tail -n 1 \ 48 | | cut -d= -f2 49 | } 50 | 51 | ## Do some sanity checks before even trying to start mysqld. 52 | sanity_checks() { 53 | # check for config file 54 | if [ ! -r /etc/mysql/my.cnf ]; then 55 | log_warning_msg "$0: WARNING: /etc/mysql/my.cnf cannot be read. See README.Debian.gz" 56 | echo "WARNING: /etc/mysql/my.cnf cannot be read. See README.Debian.gz" | $ERR_LOGGER 57 | fi 58 | 59 | # check for diskspace shortage 60 | datadir=`mysqld_get_param datadir` 61 | if LC_ALL=C BLOCKSIZE= df --portability $datadir/. | tail -n 1 | awk '{ exit ($4>4096) }'; then 62 | log_failure_msg "$0: ERROR: The partition with $datadir is too full!" 63 | echo "ERROR: The partition with $datadir is too full!" | $ERR_LOGGER 64 | exit 1 65 | fi 66 | } 67 | 68 | ## Checks if there is a server running and if so if it is accessible. 69 | # 70 | # check_alive insists on a pingable server 71 | # check_dead also fails if there is a lost mysqld in the process list 72 | # 73 | # Usage: boolean mysqld_status [check_alive|check_dead] [warn|nowarn] 74 | mysqld_status () { 75 | ping_output=`$MYADMIN ping 2>&1`; ping_alive=$(( ! $? )) 76 | 77 | ps_alive=0 78 | pidfile=`mysqld_get_param pid-file` 79 | if [ -f "$pidfile" ] && ps `cat $pidfile` >/dev/null 2>&1; then ps_alive=1; fi 80 | 81 | if [ "$1" = "check_alive" -a $ping_alive = 1 ] || 82 | [ "$1" = "check_dead" -a $ping_alive = 0 -a $ps_alive = 0 ]; then 83 | return 0 # EXIT_SUCCESS 84 | else 85 | if [ "$2" = "warn" ]; then 86 | echo -e "$ps_alive processes alive and '$MYADMIN ping' resulted in\n$ping_output\n" | $ERR_LOGGER -p daemon.debug 87 | fi 88 | return 1 # EXIT_FAILURE 89 | fi 90 | } 91 | 92 | # 93 | # main() 94 | # 95 | 96 | case "${1:-''}" in 97 | 'start') 98 | sanity_checks; 99 | # Start daemon 100 | log_daemon_msg "Starting MySQL database server" "mysqld" 101 | if mysqld_status check_alive nowarn; then 102 | log_progress_msg "already running" 103 | log_end_msg 0 104 | else 105 | /usr/bin/mysqld_safe > /dev/null 2>&1 & 106 | # 6s was reported in #352070 to be too few when using ndbcluster 107 | for i in `seq 1 <%= @node[:db_mysql][:init_timeout] %>`; do 108 | sleep 1 109 | if mysqld_status check_alive nowarn ; then break; fi 110 | log_progress_msg "." 111 | done 112 | if mysqld_status check_alive warn; then 113 | log_end_msg 0 114 | # Now start mysqlcheck or whatever the admin wants. 115 | output=$(/etc/mysql/debian-start) 116 | [ -n "$output" ] && log_action_msg "$output" 117 | else 118 | log_end_msg 1 119 | log_failure_msg "Please take a look at the syslog" 120 | fi 121 | fi 122 | 123 | # Some warnings 124 | if $MYADMIN variables | egrep -q have_bdb.*YES; then 125 | echo "BerkeleyDB is obsolete, see /usr/share/doc/mysql-server-5.0/README.Debian.gz" | $ERR_LOGGER -p daemon.info 126 | fi 127 | if [ -f /etc/mysql/debian-log-rotate.conf ]; then 128 | echo "/etc/mysql/debian-log-rotate.conf is obsolete, see /usr/share/doc/mysql-server-5.0/NEWS.Debian.gz" | $ERR_LOGGER -p daemon.info 129 | fi 130 | ;; 131 | 132 | 'stop') 133 | # * As a passwordless mysqladmin (e.g. via ~/.my.cnf) must be possible 134 | # at least for cron, we can rely on it here, too. (although we have 135 | # to specify it explicit as e.g. sudo environments points to the normal 136 | # users home and not /root) 137 | log_daemon_msg "Stopping MySQL database server" "mysqld" 138 | if ! mysqld_status check_dead nowarn; then 139 | set +e 140 | shutdown_out=`$MYADMIN shutdown 2>&1`; r=$? 141 | set -e 142 | if [ "$r" -ne 0 ]; then 143 | log_end_msg 1 144 | [ "$VERBOSE" != "no" ] && log_failure_msg "Error: $shutdown_out" 145 | log_daemon_msg "Killing MySQL database server by signal" "mysqld" 146 | killall -15 mysqld 147 | server_down= 148 | for i in `seq 1 <%= @node[:db_mysql][:init_timeout] %>`; do 149 | sleep 1 150 | if mysqld_status check_dead nowarn; then server_down=1; break; fi 151 | done 152 | if test -z "$server_down"; then killall -9 mysqld; fi 153 | fi 154 | fi 155 | 156 | if ! mysqld_status check_dead warn; then 157 | log_end_msg 1 158 | log_failure_msg "Please stop MySQL manually and read /usr/share/doc/mysql-server-5.0/README.Debian.gz!" 159 | exit -1 160 | else 161 | log_end_msg 0 162 | fi 163 | ;; 164 | 165 | 'restart') 166 | set +e; $SELF stop; set -e 167 | $SELF start 168 | ;; 169 | 170 | 'reload'|'force-reload') 171 | log_daemon_msg "Reloading MySQL database server" "mysqld" 172 | $MYADMIN reload 173 | log_end_msg 0 174 | ;; 175 | 176 | 'status') 177 | if mysqld_status check_alive nowarn; then 178 | log_action_msg "$($MYADMIN version)" 179 | else 180 | log_action_msg "MySQL is stopped." 181 | exit 3 182 | fi 183 | ;; 184 | 185 | *) 186 | echo "Usage: $SELF start|stop|restart|reload|force-reload|status" 187 | exit 1 188 | ;; 189 | esac 190 | 191 | -------------------------------------------------------------------------------- /cookbooks/db_mysql/recipes/install_mysql.rb: -------------------------------------------------------------------------------- 1 | # Cookbook Name:: db_mysql 2 | # Recipe:: server 3 | # 4 | # Copyright (c) 2009 RightScale Inc 5 | # 6 | # Permission is hereby granted, free of charge, to any person obtaining 7 | # a copy of this software and associated documentation files (the 8 | # "Software"), to deal in the Software without restriction, including 9 | # without limitation the rights to use, copy, modify, merge, publish, 10 | # distribute, sublicense, and/or sell copies of the Software, and to 11 | # permit persons to whom the Software is furnished to do so, subject to 12 | # the following conditions: 13 | # 14 | # The above copyright notice and this permission notice shall be 15 | # included in all copies or substantial portions of the Software. 16 | # 17 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | 25 | include_recipe "db_mysql::client" 26 | 27 | # Log resource submitted to opscode. http://tickets.opscode.com/browse/CHEF-923 28 | log "EC2 Instance type detected: #{@node[:db_mysql][:server_usage]}-#{@node[:ec2][:instance_type]}" if @node[:ec2] == "true" 29 | 30 | # preseeding is only required for ubuntu and debian 31 | case node[:platform] 32 | when "debian","ubuntu" 33 | 34 | directory "/var/cache/local/preseeding" do 35 | owner "root" 36 | group "root" 37 | mode "755" 38 | recursive true 39 | end 40 | 41 | execute "preseed mysql-server" do 42 | command "debconf-set-selections /var/cache/local/preseeding/mysql-server.seed" 43 | action :nothing 44 | end 45 | 46 | template "/var/cache/local/preseeding/mysql-server.seed" do 47 | source "mysql-server.seed.erb" 48 | owner "root" 49 | group "root" 50 | mode "0600" 51 | notifies :run, resources(:execute => "preseed mysql-server"), :immediately 52 | end 53 | 54 | remote_file "/etc/mysql/debian.cnf" do 55 | source "debian.cnf" 56 | end 57 | end 58 | 59 | # THIS INSTALLS PLATFORM EQUIVALENT OF the mysql-server package; see attributes. 60 | # ALSO install other packages we require. 61 | @node[:db_mysql][:packages_install].each do |p| 62 | package p 63 | end unless @node[:db_mysql][:packages_install] == "" 64 | 65 | # uninstall other packages we don't 66 | @node[:db_mysql][:packages_uninstall].each do |p| 67 | package p do 68 | action :remove 69 | end 70 | end unless @node[:db_mysql][:packages_uninstall] == "" 71 | 72 | # Drop in best practice replacement for mysqld startup. Timeouts enabled. 73 | template value_for_platform([ "centos", "redhat", "suse" ] => {"default" => "/etc/init.d/mysqld"}, "default" => "/etc/init.d/mysql") do 74 | source "init-mysql.erb" 75 | mode "0755" 76 | end 77 | 78 | # Setup my.cnf 79 | include_recipe "db_mysql::setup_my_cnf" 80 | 81 | # Initialize the binlog dir 82 | binlog = ::File.dirname(@node[:db_mysql][:log_bin]) 83 | directory binlog do 84 | owner "mysql" 85 | group "mysql" 86 | recursive true 87 | end 88 | 89 | # Create it so mysql can use it if configured 90 | file "/var/log/mysqlslow.log" do 91 | owner "mysql" 92 | group "mysql" 93 | end 94 | 95 | service "mysql" do 96 | service_name value_for_platform([ "centos", "redhat", "suse" ] => {"default" => "mysqld"}, "default" => "mysql") 97 | supports :status => true, :restart => true, :reload => true 98 | action [:enable, :start] 99 | end 100 | 101 | # Disable the "check_for_crashed_tables" for ubuntu 102 | # And setup Debian maintenance user 103 | case node[:platform] 104 | when "debian","ubuntu" 105 | execute "sed -i 's/^.*check_for_crashed_tables.*/ #check_for_crashed_tables;/g' /etc/mysql/debian-start" 106 | execute "sed -i 's/user.*/user = #{@node[:db_mysql][:admin_user]}/g' /etc/mysql/debian.cnf" 107 | execute "sed -i 's/password.*/password = #{@node[:db_mysql][:admin_user]}/g' /etc/mysql/debian.cnf" 108 | end 109 | 110 | # bugfix: mysqd_safe high cpu usage 111 | # https://bugs.launchpad.net/ubuntu/+source/mysql-dfsg-5.0/+bug/105457 112 | service "mysql" do 113 | only_if do 114 | right_platform = node[:platform] == "ubuntu" && 115 | (node[:platform_version] == "8.04" || 116 | node[:platform_version] == "8.10") 117 | 118 | right_platform && node[:db_mysql][:kill_bug_mysqld_safe] 119 | end 120 | 121 | action :stop 122 | end 123 | 124 | ruby_block "fix buggy mysqld_safe" do 125 | only_if do 126 | right_platform = node[:platform] == "ubuntu" && 127 | (node[:platform_version] == "8.04" || 128 | node[:platform_version] == "8.10") 129 | 130 | right_platform && node[:db_mysql][:kill_bug_mysqld_safe] 131 | end 132 | block do 133 | Chef::Log.info("Found buggy mysqld_safe on first boot..") 134 | output = "" 135 | status = Chef::Mixin::Command.popen4("pgrep mysqld_safe") do |pid, stdin, stdout, stderr| 136 | stdout.each do |line| 137 | output << line.strip 138 | end 139 | end 140 | bug = output.to_i 141 | unless bug == 0 142 | Chef::Log.info("Buggy mysql_safe PID: #{bug}, killing..") 143 | Process.kill(15, bug) unless bug == 0 144 | end 145 | node[:db_mysql][:kill_bug_mysqld_safe] = false 146 | end 147 | end 148 | 149 | service "mysql" do 150 | only_if do true end # http://tickets.opscode.com/browse/CHEF-894 151 | not_if do ::File.symlink?(node[:db_mysql][:datadir]) end 152 | action :stop 153 | end 154 | 155 | # moves mysql default db to storage location, removes ib_logfiles for re-config of innodb_log_file_size 156 | ruby_block "clean innodb logfiles, relocate default datafiles to storage drive, symlink storage to default datadir" do 157 | not_if do ::File.symlink?(node[:db_mysql][:datadir]) end 158 | block do 159 | require 'fileutils' 160 | remove_files = ::Dir.glob(::File.join(node[:db_mysql][:datadir], 'ib_logfile*')) + ::Dir.glob(::File.join(node[:db_mysql][:datadir], 'ibdata*')) 161 | Chef::Log.info("Prep for innodb config changes on pristine install, removing files: #{remove_files.join(',')} ") 162 | FileUtils.rm_rf(remove_files) 163 | Chef::Log.info("Relocating default mysql datafiles to #{node[:db_mysql][:datadir_relocate]}") 164 | FileUtils.cp_r(node[:db_mysql][:datadir], node[:db_mysql][:datadir_relocate]) 165 | FileUtils.rm_rf(node[:db_mysql][:datadir]) 166 | File.symlink(node[:db_mysql][:datadir_relocate], node[:db_mysql][:datadir]) 167 | end 168 | end 169 | 170 | ruby_block "chown mysql datadir" do 171 | block do 172 | FileUtils.chown_R("mysql", "mysql", node[:db_mysql][:datadir_relocate]) 173 | end 174 | end 175 | 176 | service "mysql" do 177 | not_if do false end # http://tickets.opscode.com/browse/CHEF-894 178 | Chef::Log.info "Attempting to start mysql service" 179 | action :start 180 | end 181 | 182 | ## Fix Privileges 4.0+ 183 | execute "/usr/bin/mysql_fix_privilege_tables" 184 | -------------------------------------------------------------------------------- /cookbooks/db_mysql/templates/default/my.cnf.erb: -------------------------------------------------------------------------------- 1 | # Generated by Chef for <%= @node[:hostname] %> 2 | # 3 | # Local modifications will be overwritten. 4 | # 5 | # The MySQL database server configuration file. 6 | # 7 | # You can copy this to one of: 8 | # - "/etc/mysql/my.cnf" to set global options, 9 | # - "~/.my.cnf" to set user-specific options. 10 | # 11 | # One can use all long options that the program supports. 12 | # Run program with --help to get a list of available options and with 13 | # --print-defaults to see which it would actually understand and use. 14 | # 15 | # For explanations see 16 | # http://dev.mysql.com/doc/mysql/en/server-system-variables.html 17 | 18 | # This will be passed to all mysql clients 19 | # It has been reported that passwords should be enclosed with ticks/quotes 20 | # escpecially if they contain "#" chars... 21 | # Remember to edit /etc/mysql/debian.cnf when changing the socket location. 22 | [client] 23 | port = 3306 24 | socket = <%= @node[:db_mysql][:socket] %> 25 | 26 | # Here is entries for some specific programs 27 | # The following values assume you have at least 32M ram 28 | 29 | # This was formally known as [safe_mysqld]. Both versions are currently parsed. 30 | [mysqld_safe] 31 | socket = <%= @node[:db_mysql][:socket] %> 32 | nice = 0 33 | 34 | [mysqld] 35 | # 36 | # * Basic Settings 37 | # 38 | 39 | # 40 | # * IMPORTANT 41 | # If you make changes to these settings and your system uses apparmor, you may 42 | # also need to also adjust /etc/apparmor.d/usr.sbin.mysqld. 43 | # 44 | user = mysql 45 | pid-file = /var/run/mysqld/mysqld.pid 46 | socket = <%= @node[:db_mysql][:socket] %> 47 | port = 3306 48 | basedir = <%= @node[:db_mysql][:basedir] %> 49 | datadir = <%= @node[:db_mysql][:datadir] %> 50 | tmpdir = <%= @node[:db_mysql][:tmpdir] %> 51 | #default_table_type = INNODB 52 | skip-external-locking 53 | # 54 | # Instead of skip-networking the default is now to listen only on 55 | # localhost which is more compatible and is not less secure. 56 | bind-address = <%= @node[:db_mysql][:bind_address] %> 57 | # 58 | # * Fine Tuning 59 | # 60 | key_buffer = <%= @node[:db_mysql][:tunable][:key_buffer] %> 61 | max_allowed_packet = 16M 62 | thread_stack = 128K 63 | thread_cache_size = <%= @node[:db_mysql][:tunable][:thread_cache_size] %> 64 | # This replaces the startup script and checks MyISAM tables if needed 65 | # the first time they are touched 66 | myisam-recover = BACKUP 67 | #max_connections = 100 68 | #table_cache = 64 69 | #thread_concurrency = 10 70 | max_connections = <%= @node[:db_mysql][:tunable][:max_connections] %> 71 | wait_timeout = <%= @node[:db_mysql][:tunable][:wait_timeout] %> 72 | net_read_timeout = <%= @node[:db_mysql][:tunable][:net_read_timeout] %> 73 | net_write_timeout = <%= @node[:db_mysql][:tunable][:net_write_timeout] %> 74 | back_log = <%= @node[:db_mysql][:tunable][:back_log] %> 75 | table_cache = <%= @node[:db_mysql][:tunable][:table_cache] %> 76 | max_heap_table_size = <%= @node[:db_mysql][:tunable][:max_heap_table_size] %> 77 | 78 | sort_buffer_size = <%= @node[:db_mysql][:tunable][:sort_buffer_size] %> 79 | read_buffer_size = <%= @node[:db_mysql][:tunable][:read_buffer_size] %> 80 | read_rnd_buffer_size = <%= @node[:db_mysql][:tunable][:read_rnd_buffer_size] %> 81 | myisam_sort_buffer_size = <%= @node[:db_mysql][:tunable][:myisam_sort_buffer_size] %> 82 | net_buffer_length = <%= @node[:db_mysql][:tunable][:net_buffer_length] %> 83 | 84 | <%= @node[:db_mysql][:tunable][:log_slow_queries] %> 85 | <%= @node[:db_mysql][:tunable][:long_query_time] %> 86 | 87 | # 88 | # * Query Cache Configuration 89 | # 90 | query_cache_limit = 1M 91 | query_cache_size = <%= @node[:db_mysql][:tunable][:query_cache_size] %> 92 | # 93 | # * Logging and Replication 94 | # 95 | # Both location gets rotated by the cronjob. 96 | # Be aware that this log type is a performance killer. 97 | <%= @node[:db_mysql][:log] %> 98 | <%= @node[:db_mysql][:log_error] %> 99 | # 100 | # Error logging goes to syslog. This is a Debian improvement :) 101 | # 102 | # Here you can see queries with especially long duration 103 | log_slow_queries = /var/log/mysql/mysql-slow.log 104 | long_query_time = 2 105 | log-queries-not-using-indexes 106 | # 107 | # The following can be used as easy to replay backup logs or for replication. 108 | # note: if you are setting up a replication slave, see README.Debian about 109 | # other settings you may need to change. 110 | <%= "read_only = 1" unless @node[:db_mysql][:tunable][:read_only] == nil %> 111 | server-id = <%= @server_id %> 112 | <% if @node[:db_mysql][:log_bin_enabled] %> 113 | <%= "log_bin = #{@node[:db_mysql][:log_bin]}" %> 114 | <%= "expire_logs_days = #{@node[:expire_logs_days]}" %> 115 | <% end %> 116 | max_binlog_size = 100M 117 | #binlog_do_db = include_database_name 118 | #binlog_ignore_db = include_database_name 119 | # 120 | # * BerkeleyDB 121 | # 122 | # Using BerkeleyDB is now discouraged as its support will cease in 5.1.12. 123 | skip-bdb 124 | # 125 | # * InnoDB 126 | # 127 | # InnoDB is enabled by default with a 10MB datafile in /var/lib/mysql/. 128 | # Read the manual for more InnoDB related options. There are many! 129 | # You might want to disable InnoDB to shrink the mysqld process by circa 100MB. 130 | #skip-innodb 131 | innodb_data_home_dir = /var/lib/mysql/ 132 | innodb_data_file_path = ibdata1:10M:autoextend 133 | innodb_log_group_home_dir = /var/lib/mysql 134 | innodb_log_arch_dir = /var/lib/mysql 135 | innodb_file_per_table 136 | # You can set .._buffer_pool_size up to 50 - 80 % 137 | # of RAM but beware of setting memory usage too high 138 | innodb_buffer_pool_size = <%= @node[:db_mysql][:tunable][:innodb_buffer_pool_size] %> 139 | innodb_additional_mem_pool_size = <%= @node[:db_mysql][:tunable][:innodb_additional_mem_pool_size] %> 140 | # Set .._log_file_size to 25 % of buffer pool size 141 | innodb_log_file_size = 64M 142 | innodb_log_buffer_size = 8M 143 | # Write to log but don't flush on commit (it will be flushed every "second") 144 | innodb_flush_log_at_trx_commit = 2 145 | innodb_lock_wait_timeout = 50 146 | innodb_support_xa = 1 147 | # innodb_doublewrite 148 | innodb_fast_shutdown = 1 149 | 150 | # 151 | # * Security Features 152 | # 153 | # Read the manual, too, if you want chroot! 154 | # chroot = /var/lib/mysql/ 155 | # 156 | # For generating SSL certificates I recommend the OpenSSL GUI "tinyca". 157 | # 158 | # ssl-ca=/etc/mysql/cacert.pem 159 | # ssl-cert=/etc/mysql/server-cert.pem 160 | # ssl-key=/etc/mysql/server-key.pem 161 | 162 | [mysqldump] 163 | quick 164 | quote-names 165 | max_allowed_packet = 16M 166 | 167 | [mysql] 168 | #no-auto-rehash # faster start of mysql but no tab completition 169 | 170 | [isamchk] 171 | key_buffer = <%= @node[:db_mysql][:tunable][:isamchk][:key_buffer] %> 172 | sort_buffer_size = <%= @node[:db_mysql][:tunable][:isamchk][:sort_buffer_size] %> 173 | 174 | [myisamchk] 175 | key_buffer = <%= @node[:db_mysql][:tunable][:myisamchk][:key_buffer] %> 176 | sort_buffer_size = <%= @node[:db_mysql][:tunable][:myisamchk][:sort_buffer_size] %> 177 | 178 | # 179 | # * NDB Cluster 180 | # 181 | # See /usr/share/doc/mysql-server-*/README.Debian for more information. 182 | # 183 | # The following configuration is read by the NDB Data Nodes (ndbd processes) 184 | # not from the NDB Management Nodes (ndb_mgmd processes). 185 | # 186 | # [MYSQL_CLUSTER] 187 | # ndb-connectstring=127.0.0.1 188 | # 189 | # * IMPORTANT: Additional settings that can override those from this file! 190 | # The files must end with '.cnf', otherwise they'll be ignored. 191 | # 192 | <%= "!includedir /etc/mysql/conf.d/" unless ["centos", "redhat","suse"].include?(@node[:platform]) %> 193 | -------------------------------------------------------------------------------- /cookbooks/app_rails/metadata.rb: -------------------------------------------------------------------------------- 1 | maintainer "RightScale, Inc." 2 | maintainer_email "support@rightscale.com" 3 | license IO.read(File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'LICENSE'))) 4 | description "Installs the rails application server on apache+passenger." 5 | long_description IO.read(File.join(File.dirname(__FILE__), 'README.rdoc')) 6 | version "0.0.1" 7 | 8 | depends "web_apache" 9 | depends "rails" 10 | depends "passenger_apache2::mod_rails" 11 | depends "mysql::client" 12 | depends "repo_git" 13 | depends "db_mysql" 14 | 15 | depends "repo_git_pull(url, branch, user, dest, cred)" 16 | 17 | recipe "app_rails::default", "Runs app_rails::install_rails." 18 | recipe "app_rails::do_db_restore", "Restore the application database schema from a remote location." 19 | recipe "app_rails::do_update_code", "Update application source files from the remote repository." 20 | recipe "app_rails::install_rails", "Installs the rails application server." 21 | recipe "app_rails::setup_db_config", "Configures the rails database.yml file." 22 | 23 | attribute "rails", 24 | :display_name => "Rails Passenger Settings", 25 | :type => "hash" 26 | 27 | # 28 | # required attributes 29 | # 30 | attribute "rails/db_app_user", 31 | :display_name => "Database User", 32 | :description => "If the MySQL administrator set up a restricted MySQL account for application servers to access the database, then specify the username of that account for this input. If there is not a restricted MySQL account then use the same value that's used for 'Database Admin Username'. The application server will then have unrestricted access to the database.", 33 | :required => true, 34 | :recipes => ["app_rails::do_db_restore", "app_rails::install_rails", "app_rails::default"] 35 | 36 | attribute "rails/db_app_passwd", 37 | :display_name => "Database Password", 38 | :description => "If the MySQL administrator set up a restricted MySQL account for application servers to access the database, then specify the password of that account for this input. If there is not a restricted MySQL account then use the same value that's used for 'Database Admin Password'. The application server will then have unrestricted access to the database.", 39 | :required => true, 40 | :recipes => ["app_rails::do_db_restore"] 41 | 42 | attribute "rails/db_schema_name", 43 | :display_name => "Database Schema Name", 44 | :description => "Enter the name of the MySQL database schema to which applications will connect. The database schema was created when the initial database was first set up. This input will be used to set the application server's database config file so that applications can connect to the correct schema within the database. This input is also used for MySQL dump backups in order to determine which schema is getting backed up. Ex: mydbschema", 45 | :required => true, 46 | :recipes => ["app_rails::do_db_restore"] 47 | 48 | #attribute "rails/db_dns_name", 49 | # :display_name => "Database DNS Name", 50 | # :description => "The fully qualified domain name of the database server to which the application server(s) will connect. Ex: master.mydatabase.com", 51 | # :required => true, 52 | # :recipes => [] 53 | 54 | attribute "rails/code", 55 | :display_name => "Rails Application Code", 56 | :type => "hash" 57 | 58 | attribute "rails/code/url", 59 | :display_name => "Repository URL", 60 | :description => "Specify the URL location of the repository that contains the application code. Ex: git://github.com/mysite/myapp.git", 61 | :required => true, 62 | :recipes => ["app_rails::do_db_restore", "app_rails::do_update_code", "app_rails::install_rails", "app_rails::default", "app_rails::default" ] 63 | 64 | 65 | # 66 | # recommended attributes 67 | # 68 | attribute "rails/server_name", 69 | :display_name => "Server Name", 70 | :description => "The fully qualified domain name of the application server used to define your virtual host.", 71 | :default => "myserver", 72 | :recipes => ["app_rails::do_db_restore", "app_rails::do_update_code", "app_rails::install_rails", "app_rails::default" ] 73 | 74 | attribute "rails/application_name", 75 | :display_name => "Application Name", 76 | :description => "Sets the directory for your application's web files (/home/webapps/Application Name/current/). If you have multiple applications, you can run the code checkout script multiple times, each with a different value for 'Application Name', so each application will be stored in a unique directory. This must be a valid directory name. Do not use symbols in the name.", 77 | :default => "myapp", 78 | :recipes => ["app_rails::install_rails", "app_rails::default" ] 79 | 80 | #attribute "rails/environment", 81 | # :display_name => "Rails Environment", 82 | # :description => "The Rails Environment of the current workspace.", 83 | # :default => "production", 84 | # :recipes => ["app_rails::do_db_restore", "app_rails::do_update_code", "app_rails::install_rails" ] 85 | 86 | attribute "rails/db_mysqldump_file_path", 87 | :display_name => "Mysqldump File Path", 88 | :description => "This input allows you to restore your database by choosing a specific MySQL database backup file. You will need to specify a full path and/or filename. Ex: branch/mydb-200910300402.gz", 89 | :recipes => ["app_rails::do_db_restore"] 90 | 91 | 92 | # 93 | # optional attributes 94 | # 95 | attribute "rails/code/credentials", 96 | :display_name => "Repository Credentials", 97 | :description => "The private SSH key of the git repository.", 98 | :recipes => ["app_rails::do_db_restore", "app_rails::do_update_code", "app_rails::install_rails", "app_rails::default", "app_rails::default" ] 99 | 100 | #attribute "rails/version", 101 | # :display_name => "Rails Version", 102 | # :description => "Specify which version of Rails to install. Ex: 2.2.2", 103 | # :default => "false", 104 | # :recipes => ["app_rails::do_db_restore", "app_rails::do_update_code", "app_rails::install_rails" ] 105 | 106 | #attribute "rails/max_pool_size", 107 | # :display_name => "Rails Max Pool Size", 108 | # :description => "Specify the MaxPoolSize in the Apache vhost. Sets the number of desired mongrel processes on the Rails server. Specify a value between 4-8 for a small instance.", 109 | # :default => "4", 110 | # :recipes => ["app_rails::do_db_restore", "app_rails::do_update_code", "app_rails::install_rails" ] 111 | 112 | attribute "rails/code/branch", 113 | :display_name => "Repository Branch", 114 | :description => "The name of the branch within the git repository where the application code should be pulled from.", 115 | :default => "master", 116 | :recipes => ["app_rails::do_db_restore", "app_rails::do_update_code", "app_rails::install_rails", "app_rails::default" ] 117 | 118 | attribute "rails/application_port", 119 | :display_name => "Application Port", 120 | :description => "This input is normally set to 8000 if this server is a combined HAProxy and application server. If this is an application server (w/o HAproxy), set it to 80. When setting this in a deployment, you should use 80 at the deployment level since you want all of your servers in the array to use this value. If the server is a FE+APP server, you can set it to 8000 at the server level so that it overrides the deployment level input.", 121 | :default => "8000", 122 | :recipes => [ "app_rails::install_rails", "app_rails::default" ] 123 | 124 | #attribute "rails/spawn_method", 125 | # :display_name => "Spawn Method", 126 | # :description => "Specify which Rails spawn method should be used. Ex: conservative, smart, smart-lv2", 127 | # :default => "conservative", 128 | # :recipes => ["app_rails::do_db_restore", "app_rails::do_update_code", "app_rails::install_rails" ] 129 | 130 | attribute "rails/gems_list", 131 | :display_name => "Gems List", 132 | :description => "An optional list of gems that's required by your application.", 133 | :type => "array", 134 | :required => false, 135 | :recipes => [ "app_rails::install_rails", "app_rails::default" ] 136 | 137 | -------------------------------------------------------------------------------- /cookbooks/app_php/metadata.json: -------------------------------------------------------------------------------- 1 | { 2 | "providing": { 3 | "app_php::do_update_code": [ 4 | 5 | ], 6 | "app_php": [ 7 | 8 | ], 9 | "app_php::do_db_restore": [ 10 | 11 | ], 12 | "app_php::install_php": [ 13 | 14 | ] 15 | }, 16 | "long_description": "= DESCRIPTION:\n\n= REQUIREMENTS:\n\n= ATTRIBUTES: \n\n= USAGE:\n\n", 17 | "dependencies": { 18 | "repo_git_pull(url, branch, dest, cred)": [ 19 | 20 | ], 21 | "web_apache": [ 22 | 23 | ], 24 | "repo_git": [ 25 | 26 | ] 27 | }, 28 | "replacing": { 29 | 30 | }, 31 | "description": "Installs the php application server.", 32 | "maintainer": "RightScale, Inc.", 33 | "name": "app_php", 34 | "recommendations": { 35 | 36 | }, 37 | "maintainer_email": "support@rightscale.com", 38 | "suggestions": { 39 | 40 | }, 41 | "platforms": { 42 | 43 | }, 44 | "version": "0.0.1", 45 | "recipes": { 46 | "app_php": "", 47 | "app_php::do_update_code": "Update application source files from the remote repository.", 48 | "app_php::default": "Runs app_php::install_php.", 49 | "app_php::do_db_restore": "Restore the application database schema from a remote location.", 50 | "app_php::install_php": "Installs the php application server." 51 | }, 52 | "attributes": { 53 | "php\/db_dns_name": { 54 | "type": "string", 55 | "multiple_values": false, 56 | "description": "The fully qualified domain name of the database server to which the application server(s) will connect. Ex: master.mydatabase.com", 57 | "display_name": "Database Dns Name", 58 | "recipes": [ 59 | "app_php::install_php", 60 | "app_php::default" 61 | ], 62 | "required": true 63 | }, 64 | "php\/db_app_user": { 65 | "type": "string", 66 | "multiple_values": false, 67 | "description": "If the MySQL administrator set up a restricted MySQL account for application servers to access the database, then specify the username of that account for this input. If there is not a restricted MySQL account then use the same value that's used for 'Database Admin Username'. The application server will then have unrestricted access to the database.", 68 | "display_name": "Database User", 69 | "recipes": [ 70 | "app_php::do_db_restore" 71 | ], 72 | "required": true 73 | }, 74 | "php\/code\/branch": { 75 | "default": "master", 76 | "type": "string", 77 | "multiple_values": false, 78 | "description": "The name of the branch within the git repository where the application code should be pulled from.", 79 | "display_name": "Repository Branch", 80 | "recipes": [ 81 | "app_php::do_update_code", 82 | "app_php::do_db_restore", 83 | "app_php::install_php", 84 | "app_php::default" 85 | ], 86 | "required": false 87 | }, 88 | "php": { 89 | "type": "hash", 90 | "multiple_values": false, 91 | "display_name": "PHP Application Settings", 92 | "recipes": [ 93 | 94 | ], 95 | "required": false 96 | }, 97 | "php\/db_mysqldump_file_path": { 98 | "type": "string", 99 | "multiple_values": false, 100 | "description": "This input allows you to restore your database by choosing a specific MySQL database backup file. You will need to specify a full path and\/or filename. Ex: branch\/mydb-200910300402.gz", 101 | "display_name": "Mysqldump File Path", 102 | "recipes": [ 103 | "app_php::do_db_restore" 104 | ], 105 | "required": false 106 | }, 107 | "php\/code\/credentials": { 108 | "default": "", 109 | "type": "string", 110 | "multiple_values": false, 111 | "description": "The private SSH key of the git repository.", 112 | "display_name": "Repository Credentials", 113 | "recipes": [ 114 | "app_php::do_update_code", 115 | "app_php::do_db_restore", 116 | "app_php::install_php", 117 | "app_php::default" 118 | ], 119 | "required": false 120 | }, 121 | "php\/db_app_passwd": { 122 | "type": "string", 123 | "multiple_values": false, 124 | "description": "If the MySQL administrator set up a restricted MySQL account for application servers to access the database, then specify the password of that account for this input. If there is not a restricted MySQL account then use the same value that's used for 'Database Admin Password'. The application server will then have unrestricted access to the database.", 125 | "display_name": "Database Password", 126 | "recipes": [ 127 | "app_php::do_db_restore" 128 | ], 129 | "required": true 130 | }, 131 | "php\/application_port": { 132 | "default": "8000", 133 | "type": "string", 134 | "multiple_values": false, 135 | "description": "This input is normally set to 8000 if this server is a combined HAProxy and application server. If this is an application server (w\/o HAproxy), set it to 80. When setting this in a deployment, you should use 80 at the deployment level since you want all of your servers in the array to use this value. If the server is a FE+APP server, you can set it to 8000 at the server level so that it overrides the deployment level input.", 136 | "display_name": "Application Port", 137 | "recipes": [ 138 | "app_php::install_php", 139 | "app_php::default" 140 | ], 141 | "required": false 142 | }, 143 | "php\/code\/url": { 144 | "type": "string", 145 | "multiple_values": false, 146 | "description": "Specify the URL location of the repository that contains the application code. Ex: git:\/\/github.com\/mysite\/myapp.git", 147 | "display_name": "Repository URL", 148 | "recipes": [ 149 | "app_php::do_update_code", 150 | "app_php::do_db_restore", 151 | "app_php::install_php", 152 | "app_php::default" 153 | ], 154 | "required": true 155 | }, 156 | "php\/code": { 157 | "type": "hash", 158 | "multiple_values": false, 159 | "display_name": "PHP Application Code", 160 | "recipes": [ 161 | 162 | ], 163 | "required": false 164 | }, 165 | "php\/server_name": { 166 | "type": "string", 167 | "multiple_values": false, 168 | "description": "The fully qualified domain name of the application server used to define your virtual host.", 169 | "display_name": "Server Name", 170 | "recipes": [ 171 | "app_php::install_php", 172 | "app_php::default" 173 | ], 174 | "required": true 175 | }, 176 | "php\/db_schema_name": { 177 | "type": "string", 178 | "multiple_values": false, 179 | "description": "Enter the name of the MySQL database schema to which applications will connect. The database schema was created when the initial database was first set up. This input will be used to set the application server's database config file so that applications can connect to the correct schema within the database. This input is also used for MySQL dump backups in order to determine which schema is getting backed up. Ex: mydbschema", 180 | "display_name": "Database Schema Name", 181 | "recipes": [ 182 | "app_php::do_db_restore" 183 | ], 184 | "required": true 185 | }, 186 | "php\/application_name": { 187 | "default": "myapp", 188 | "type": "string", 189 | "multiple_values": false, 190 | "description": "Sets the directory for your application's web files (\/home\/webapps\/Application Name\/current\/). If you have multiple applications, you can run the code checkout script multiple times, each with a different value for APPLICATION, so each application will be stored in a unique directory. This must be a valid directory name. Do not use symbols in the name.", 191 | "display_name": "Application Name", 192 | "recipes": [ 193 | "app_php::install_php", 194 | "app_php::default" 195 | ], 196 | "required": false 197 | } 198 | }, 199 | "conflicting": { 200 | 201 | }, 202 | "license": "Copyright (c) 2009 RightScale, Inc.\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n'Software'), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and\/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n" 203 | } -------------------------------------------------------------------------------- /cookbooks/web_apache/templates/default/apache2.conf.erb: -------------------------------------------------------------------------------- 1 | # 2 | # Generated by Chef 3 | # 4 | # Based on the Ubuntu apache2.conf 5 | 6 | ServerRoot "<%= @node[:apache][:dir] %>" 7 | 8 | # 9 | # The accept serialization lock file MUST BE STORED ON A LOCAL DISK. 10 | # 11 | <% if @node[:platform] == "debian" || @node[:platform] == "ubuntu" -%> 12 | LockFile /var/lock/apache2/accept.lock 13 | <% else %> 14 | LockFile logs/accept.lock 15 | <% end -%> 16 | 17 | # 18 | # PidFile: The file in which the server should record its process 19 | # identification number when it starts. 20 | # 21 | <% if @node[:platform] == "debian" || @node[:platform] == "ubuntu" -%> 22 | PidFile /var/run/apache2.pid 23 | <% else -%> 24 | PidFile logs/httpd.pid 25 | <% end -%> 26 | 27 | # 28 | # Timeout: The number of seconds before receives and sends time out. 29 | # 30 | Timeout <%= @node[:apache][:timeout] %> 31 | 32 | # 33 | # KeepAlive: Whether or not to allow persistent connections (more than 34 | # one request per connection). Set to "Off" to deactivate. 35 | # 36 | KeepAlive <%= @node[:apache][:keepalive] %> 37 | 38 | # 39 | # MaxKeepAliveRequests: The maximum number of requests to allow 40 | # during a persistent connection. Set to 0 to allow an unlimited amount. 41 | # We recommend you leave this number high, for maximum performance. 42 | # 43 | MaxKeepAliveRequests <%= @node[:apache][:keepaliverequests] %> 44 | 45 | # 46 | # KeepAliveTimeout: Number of seconds to wait for the next request from the 47 | # same client on the same connection. 48 | # 49 | KeepAliveTimeout <%= @node[:apache][:keepalivetimeout] %> 50 | 51 | ## 52 | ## Server-Pool Size Regulation (MPM specific) 53 | ## 54 | 55 | # prefork MPM 56 | # StartServers: number of server processes to start 57 | # MinSpareServers: minimum number of server processes which are kept spare 58 | # MaxSpareServers: maximum number of server processes which are kept spare 59 | # MaxClients: maximum number of server processes allowed to start 60 | # MaxRequestsPerChild: maximum number of requests a server process serves 61 | 62 | StartServers <%= @node[:apache][:prefork][:startservers] %> 63 | MinSpareServers <%= @node[:apache][:prefork][:minspareservers] %> 64 | MaxSpareServers <%= @node[:apache][:prefork][:maxspareservers] %> 65 | ServerLimit <%= @node[:apache][:prefork][:serverlimit] %> 66 | MaxClients <%= @node[:apache][:prefork][:maxclients] %> 67 | MaxRequestsPerChild <%= @node[:apache][:prefork][:maxrequestsperchild] %> 68 | 69 | 70 | # worker MPM 71 | # StartServers: initial number of server processes to start 72 | # MaxClients: maximum number of simultaneous client connections 73 | # MinSpareThreads: minimum number of worker threads which are kept spare 74 | # MaxSpareThreads: maximum number of worker threads which are kept spare 75 | # ThreadsPerChild: constant number of worker threads in each server process 76 | # MaxRequestsPerChild: maximum number of requests a server process serves 77 | 78 | StartServers <%= @node[:apache][:worker][:startservers] %> 79 | MaxClients <%= @node[:apache][:worker][:maxclients] %> 80 | MinSpareThreads <%= @node[:apache][:worker][:minsparethreads] %> 81 | MaxSpareThreads <%= @node[:apache][:worker][:maxsparethreads] %> 82 | ThreadsPerChild <%= @node[:apache][:worker][:threadsperchild] %> 83 | MaxRequestsPerChild <%= @node[:apache][:worker][:maxrequestsperchild] %> 84 | 85 | 86 | User <%= @node[:apache][:user] %> 87 | Group <%= @node[:apache][:user] %> 88 | 89 | # 90 | # AccessFileName: The name of the file to look for in each directory 91 | # for additional configuration directives. See also the AllowOverride 92 | # directive. 93 | # 94 | 95 | AccessFileName .htaccess 96 | 97 | # 98 | # The following lines prevent .htaccess and .htpasswd files from being 99 | # viewed by Web clients. 100 | # 101 | 102 | Order allow,deny 103 | Deny from all 104 | 105 | 106 | # 107 | # DefaultType is the default MIME type the server will use for a document 108 | # if it cannot otherwise determine one, such as from filename extensions. 109 | # If your server contains mostly text or HTML documents, "text/plain" is 110 | # a good value. If most of your content is binary, such as applications 111 | # or images, you may want to use "application/octet-stream" instead to 112 | # keep browsers from trying to display binary files as though they are 113 | # text. 114 | # 115 | DefaultType text/plain 116 | 117 | 118 | # 119 | # HostnameLookups: Log the names of clients or just their IP addresses 120 | # e.g., www.apache.org (on) or 204.62.129.132 (off). 121 | # The default is off because it'd be overall better for the net if people 122 | # had to knowingly turn this feature on, since enabling it means that 123 | # each client request will result in AT LEAST one lookup request to the 124 | # nameserver. 125 | # 126 | HostnameLookups Off 127 | 128 | # ErrorLog: The location of the error log file. 129 | # If you do not specify an ErrorLog directive within a 130 | # container, error messages relating to that virtual host will be 131 | # logged here. If you *do* define an error logfile for a 132 | # container, that host's errors will be logged there and not here. 133 | # 134 | ErrorLog <%= @node[:apache][:log_dir] %>/error.log 135 | 136 | # 137 | # LogLevel: Control the number of messages logged to the error_log. 138 | # Possible values include: debug, info, notice, warn, error, crit, 139 | # alert, emerg. 140 | # 141 | LogLevel warn 142 | 143 | # Include module configuration: 144 | Include <%= @node[:apache][:dir] %>/mods-enabled/*.load 145 | Include <%= @node[:apache][:dir] %>/mods-enabled/*.conf 146 | 147 | # Include ports listing 148 | Include <%= @node[:apache][:dir] %>/ports.conf 149 | 150 | # 151 | # The following directives define some format nicknames for use with 152 | # a CustomLog directive (see below). 153 | # 154 | LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined 155 | LogFormat "%h %l %u %t \"%r\" %>s %b" common 156 | LogFormat "%{Referer}i -> %U" referer 157 | LogFormat "%{User-agent}i" agent 158 | 159 | # 160 | # ExtendedStatus controls whether Apache will generate "full" status 161 | # information (ExtendedStatus On) or just basic information (ExtendedStatus 162 | # Off) when the "server-status" handler is called. The default is Off. 163 | # 164 | ExtendedStatus <%= @node[:apache][:extended_status] %> 165 | 166 | # 167 | # Customizable error responses come in three flavors: 168 | # 1) plain text 2) local redirects 3) external redirects 169 | # 170 | # Some examples: 171 | #ErrorDocument 500 "The server made a boo boo." 172 | #ErrorDocument 404 /missing.html 173 | #ErrorDocument 404 "/cgi-bin/missing_handler.pl" 174 | #ErrorDocument 402 http://www.example.com/subscription_info.html 175 | # 176 | 177 | # 178 | # Putting this all together, we can internationalize error responses. 179 | # 180 | # We use Alias to redirect any /error/HTTP_.html.var response to 181 | # our collection of by-error message multi-language collections. We use 182 | # includes to substitute the appropriate text. 183 | # 184 | # You can modify the messages' appearance without changing any of the 185 | # default HTTP_.html.var files by adding the line: 186 | # 187 | # Alias /error/include/ "/your/include/path/" 188 | # 189 | # which allows you to create your own set of files by starting with the 190 | # /usr/share/apache2/error/include/ files and copying them to /your/include/path/, 191 | # even on a per-VirtualHost basis. The default include files will display 192 | # your Apache version number and your ServerAdmin email address regardless 193 | # of the setting of ServerSignature. 194 | # 195 | # The internationalized error documents require mod_alias, mod_include 196 | # and mod_negotiation. To activate them, uncomment the following 30 lines. 197 | 198 | # Alias /error/ "/usr/share/apache2/error/" 199 | # 200 | # 201 | # AllowOverride None 202 | # Options IncludesNoExec 203 | # AddOutputFilter Includes html 204 | # AddHandler type-map var 205 | # Order allow,deny 206 | # Allow from all 207 | # LanguagePriority en cs de es fr it nl sv pt-br ro 208 | # ForceLanguagePriority Prefer Fallback 209 | # 210 | # 211 | # ErrorDocument 400 /error/HTTP_BAD_REQUEST.html.var 212 | # ErrorDocument 401 /error/HTTP_UNAUTHORIZED.html.var 213 | # ErrorDocument 403 /error/HTTP_FORBIDDEN.html.var 214 | # ErrorDocument 404 /error/HTTP_NOT_FOUND.html.var 215 | # ErrorDocument 405 /error/HTTP_METHOD_NOT_ALLOWED.html.var 216 | # ErrorDocument 408 /error/HTTP_REQUEST_TIME_OUT.html.var 217 | # ErrorDocument 410 /error/HTTP_GONE.html.var 218 | # ErrorDocument 411 /error/HTTP_LENGTH_REQUIRED.html.var 219 | # ErrorDocument 412 /error/HTTP_PRECONDITION_FAILED.html.var 220 | # ErrorDocument 413 /error/HTTP_REQUEST_ENTITY_TOO_LARGE.html.var 221 | # ErrorDocument 414 /error/HTTP_REQUEST_URI_TOO_LARGE.html.var 222 | # ErrorDocument 415 /error/HTTP_UNSUPPORTED_MEDIA_TYPE.html.var 223 | # ErrorDocument 500 /error/HTTP_INTERNAL_SERVER_ERROR.html.var 224 | # ErrorDocument 501 /error/HTTP_NOT_IMPLEMENTED.html.var 225 | # ErrorDocument 502 /error/HTTP_BAD_GATEWAY.html.var 226 | # ErrorDocument 503 /error/HTTP_SERVICE_UNAVAILABLE.html.var 227 | # ErrorDocument 506 /error/HTTP_VARIANT_ALSO_VARIES.html.var 228 | 229 | 230 | 231 | # Include generic snippets of statements 232 | Include <%= @node[:apache][:dir] %>/conf.d/ 233 | 234 | # Include the virtual host configurations: 235 | Include <%= @node[:apache][:dir] %>/sites-enabled/ 236 | -------------------------------------------------------------------------------- /cookbooks/app_rails/metadata.json: -------------------------------------------------------------------------------- 1 | { 2 | "providing": { 3 | "app_rails::do_db_restore": [ 4 | 5 | ], 6 | "app_rails::setup_db_config": [ 7 | 8 | ], 9 | "app_rails": [ 10 | 11 | ], 12 | "app_rails::install_rails": [ 13 | 14 | ], 15 | "app_rails::do_update_code": [ 16 | 17 | ] 18 | }, 19 | "long_description": "= DESCRIPTION:\n\n= REQUIREMENTS:\n\n= ATTRIBUTES: \n\n= USAGE:\n\n", 20 | "dependencies": { 21 | "repo_git_pull(url, branch, user, dest, cred)": [ 22 | 23 | ], 24 | "db_mysql": [ 25 | 26 | ], 27 | "rails": [ 28 | 29 | ], 30 | "mysql::client": [ 31 | 32 | ], 33 | "web_apache": [ 34 | 35 | ], 36 | "repo_git": [ 37 | 38 | ], 39 | "passenger_apache2::mod_rails": [ 40 | 41 | ] 42 | }, 43 | "replacing": { 44 | 45 | }, 46 | "description": "Installs the rails application server on apache+passenger.", 47 | "maintainer": "RightScale, Inc.", 48 | "name": "app_rails", 49 | "recommendations": { 50 | 51 | }, 52 | "maintainer_email": "support@rightscale.com", 53 | "suggestions": { 54 | 55 | }, 56 | "platforms": { 57 | 58 | }, 59 | "version": "0.0.1", 60 | "recipes": { 61 | "app_rails::do_db_restore": "Restore the application database schema from a remote location.", 62 | "app_rails::setup_db_config": "Configures the rails database.yml file.", 63 | "app_rails": "", 64 | "app_rails::install_rails": "Installs the rails application server.", 65 | "app_rails::do_update_code": "Update application source files from the remote repository.", 66 | "app_rails::default": "Runs app_rails::install_rails." 67 | }, 68 | "attributes": { 69 | "rails\/application_port": { 70 | "default": "8000", 71 | "type": "string", 72 | "multiple_values": false, 73 | "description": "This input is normally set to 8000 if this server is a combined HAProxy and application server. If this is an application server (w\/o HAproxy), set it to 80. When setting this in a deployment, you should use 80 at the deployment level since you want all of your servers in the array to use this value. If the server is a FE+APP server, you can set it to 8000 at the server level so that it overrides the deployment level input.", 74 | "display_name": "Application Port", 75 | "recipes": [ 76 | "app_rails::install_rails", 77 | "app_rails::default" 78 | ], 79 | "required": false 80 | }, 81 | "rails\/code\/credentials": { 82 | "type": "string", 83 | "multiple_values": false, 84 | "description": "The private SSH key of the git repository.", 85 | "display_name": "Repository Credentials", 86 | "recipes": [ 87 | "app_rails::do_db_restore", 88 | "app_rails::do_update_code", 89 | "app_rails::install_rails", 90 | "app_rails::default", 91 | "app_rails::default" 92 | ], 93 | "required": false 94 | }, 95 | "rails\/db_mysqldump_file_path": { 96 | "type": "string", 97 | "multiple_values": false, 98 | "description": "This input allows you to restore your database by choosing a specific MySQL database backup file. You will need to specify a full path and\/or filename. Ex: branch\/mydb-200910300402.gz", 99 | "display_name": "Mysqldump File Path", 100 | "recipes": [ 101 | "app_rails::do_db_restore" 102 | ], 103 | "required": false 104 | }, 105 | "rails": { 106 | "type": "hash", 107 | "multiple_values": false, 108 | "display_name": "Rails Passenger Settings", 109 | "recipes": [ 110 | 111 | ], 112 | "required": false 113 | }, 114 | "rails\/gems_list": { 115 | "type": "array", 116 | "multiple_values": false, 117 | "description": "An optional list of gems that's required by your application.", 118 | "display_name": "Gems List", 119 | "recipes": [ 120 | "app_rails::install_rails", 121 | "app_rails::default" 122 | ], 123 | "required": false 124 | }, 125 | "rails\/code\/branch": { 126 | "default": "master", 127 | "type": "string", 128 | "multiple_values": false, 129 | "description": "The name of the branch within the git repository where the application code should be pulled from.", 130 | "display_name": "Repository Branch", 131 | "recipes": [ 132 | "app_rails::do_db_restore", 133 | "app_rails::do_update_code", 134 | "app_rails::install_rails", 135 | "app_rails::default" 136 | ], 137 | "required": false 138 | }, 139 | "rails\/db_schema_name": { 140 | "type": "string", 141 | "multiple_values": false, 142 | "description": "Enter the name of the MySQL database schema to which applications will connect. The database schema was created when the initial database was first set up. This input will be used to set the application server's database config file so that applications can connect to the correct schema within the database. This input is also used for MySQL dump backups in order to determine which schema is getting backed up. Ex: mydbschema", 143 | "display_name": "Database Schema Name", 144 | "recipes": [ 145 | "app_rails::do_db_restore" 146 | ], 147 | "required": true 148 | }, 149 | "rails\/db_app_passwd": { 150 | "type": "string", 151 | "multiple_values": false, 152 | "description": "If the MySQL administrator set up a restricted MySQL account for application servers to access the database, then specify the password of that account for this input. If there is not a restricted MySQL account then use the same value that's used for 'Database Admin Password'. The application server will then have unrestricted access to the database.", 153 | "display_name": "Database Password", 154 | "recipes": [ 155 | "app_rails::do_db_restore" 156 | ], 157 | "required": true 158 | }, 159 | "rails\/server_name": { 160 | "default": "myserver", 161 | "type": "string", 162 | "multiple_values": false, 163 | "description": "The fully qualified domain name of the application server used to define your virtual host.", 164 | "display_name": "Server Name", 165 | "recipes": [ 166 | "app_rails::do_db_restore", 167 | "app_rails::do_update_code", 168 | "app_rails::install_rails", 169 | "app_rails::default" 170 | ], 171 | "required": false 172 | }, 173 | "rails\/application_name": { 174 | "default": "myapp", 175 | "type": "string", 176 | "multiple_values": false, 177 | "description": "Sets the directory for your application's web files (\/home\/webapps\/Application Name\/current\/). If you have multiple applications, you can run the code checkout script multiple times, each with a different value for 'Application Name', so each application will be stored in a unique directory. This must be a valid directory name. Do not use symbols in the name.", 178 | "display_name": "Application Name", 179 | "recipes": [ 180 | "app_rails::install_rails", 181 | "app_rails::default" 182 | ], 183 | "required": false 184 | }, 185 | "rails\/code\/url": { 186 | "type": "string", 187 | "multiple_values": false, 188 | "description": "Specify the URL location of the repository that contains the application code. Ex: git:\/\/github.com\/mysite\/myapp.git", 189 | "display_name": "Repository URL", 190 | "recipes": [ 191 | "app_rails::do_db_restore", 192 | "app_rails::do_update_code", 193 | "app_rails::install_rails", 194 | "app_rails::default", 195 | "app_rails::default" 196 | ], 197 | "required": true 198 | }, 199 | "rails\/code": { 200 | "type": "hash", 201 | "multiple_values": false, 202 | "display_name": "Rails Application Code", 203 | "recipes": [ 204 | 205 | ], 206 | "required": false 207 | }, 208 | "rails\/db_app_user": { 209 | "type": "string", 210 | "multiple_values": false, 211 | "description": "If the MySQL administrator set up a restricted MySQL account for application servers to access the database, then specify the username of that account for this input. If there is not a restricted MySQL account then use the same value that's used for 'Database Admin Username'. The application server will then have unrestricted access to the database.", 212 | "display_name": "Database User", 213 | "recipes": [ 214 | "app_rails::do_db_restore", 215 | "app_rails::install_rails", 216 | "app_rails::default" 217 | ], 218 | "required": true 219 | } 220 | }, 221 | "conflicting": { 222 | 223 | }, 224 | "license": "Copyright (c) 2009 RightScale, Inc.\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n'Software'), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and\/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n" 225 | } -------------------------------------------------------------------------------- /cookbooks/db_mysql/attributes/mysql_tuning.rb: -------------------------------------------------------------------------------- 1 | # Cookbook Name:: db_mysql 2 | # 3 | # Copyright (c) 2009 RightScale Inc 4 | # 5 | # Permission is hereby granted, free of charge, to any person obtaining 6 | # a copy of this software and associated documentation files (the 7 | # "Software"), to deal in the Software without restriction, including 8 | # without limitation the rights to use, copy, modify, merge, publish, 9 | # distribute, sublicense, and/or sell copies of the Software, and to 10 | # permit persons to whom the Software is furnished to do so, subject to 11 | # the following conditions: 12 | # 13 | # The above copyright notice and this permission notice shall be 14 | # included in all copies or substantial portions of the Software. 15 | # 16 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 20 | # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 21 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 22 | # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | set_unless[:db_mysql][:tunable][:thread_cache_size] = "50" 25 | set_unless[:db_mysql][:tunable][:max_connections] = "800" 26 | set_unless[:db_mysql][:tunable][:wait_timeout] = "28800" 27 | set_unless[:db_mysql][:tunable][:net_read_timeout] = "30" 28 | set_unless[:db_mysql][:tunable][:net_write_timeout] = "30" 29 | set_unless[:db_mysql][:tunable][:back_log] = "128" 30 | set_unless[:db_mysql][:tunable][:max_heap_table_size] = "32M" 31 | set_unless[:db_mysql][:tunable][:expire_logs_days] = "10" 32 | 33 | if !attribute?("ec2") 34 | set_unless[:db_mysql][:init_timeout] = 1200 35 | 36 | # using the same settings as a dedicated-m1.small ec2 instance 37 | set_unless[:db_mysql][:tunable][:key_buffer] = "128M" 38 | set_unless[:db_mysql][:tunable][:table_cache] = "256" 39 | set_unless[:db_mysql][:tunable][:sort_buffer_size] = "1M" 40 | set_unless[:db_mysql][:tunable][:net_buffer_length] = "8K" 41 | set_unless[:db_mysql][:tunable][:read_buffer_size] = "1M" 42 | set_unless[:db_mysql][:tunable][:read_rnd_buffer_size] = "4M" 43 | set_unless[:db_mysql][:tunable][:myisam_sort_buffer_size] = "64M" 44 | set_unless[:db_mysql][:tunable][:query_cache_size] = "24M" 45 | set_unless[:db_mysql][:tunable][:innodb_buffer_pool_size] = "1G" 46 | set_unless[:db_mysql][:tunable][:innodb_additional_mem_pool_size] = "24M" 47 | set_unless[:db_mysql][:tunable][:log_slow_queries] = "log_slow_queries = /var/log/mysqlslow.log" 48 | set_unless[:db_mysql][:tunable][:long_query_time] = "long_query_time = 5" 49 | set_unless[:db_mysql][:tunable][:isamchk][:key_buffer] = "128M" 50 | set_unless[:db_mysql][:tunable][:isamchk][:sort_buffer_size] = "128M" 51 | set_unless[:db_mysql][:tunable][:myisamchk][:key_buffer] = "128M" 52 | set_unless[:db_mysql][:tunable][:myisamchk][:sort_buffer_size] = "128M" 53 | else 54 | 55 | # Override the init timeout value for EC2 instance types 56 | case ec2[:instance_type] 57 | when "m1.small" 58 | set_unless[:db_mysql][:init_timeout] = "600" 59 | when "c1.medium" 60 | set_unless[:db_mysql][:init_timeout] = "1200" 61 | when "m1.large" 62 | set_unless[:db_mysql][:init_timeout] = "1800" 63 | when "c1.xlarge" 64 | set_unless[:db_mysql][:init_timeout] = "1800" 65 | when "m1.xlarge" 66 | set_unless[:db_mysql][:init_timeout] = "1800" 67 | else 68 | set_unless[:db_mysql][:init_timeout] = "1200" 69 | end 70 | 71 | # tune the database for dedicated vs. shared and instance type 72 | case ec2[:instance_type] 73 | when "m1.small", "c1.medium" 74 | if (db_mysql[:server_usage] == :dedicated) 75 | set_unless[:db_mysql][:tunable][:key_buffer] = "128M" 76 | set_unless[:db_mysql][:tunable][:table_cache] = "256" 77 | set_unless[:db_mysql][:tunable][:sort_buffer_size] = "1M" 78 | set_unless[:db_mysql][:tunable][:net_buffer_length] = "8K" 79 | set_unless[:db_mysql][:tunable][:read_buffer_size] = "1M" 80 | set_unless[:db_mysql][:tunable][:read_rnd_buffer_size] = "4M" 81 | set_unless[:db_mysql][:tunable][:myisam_sort_buffer_size] = "64M" 82 | set_unless[:db_mysql][:tunable][:query_cache_size] = "24M" 83 | set_unless[:db_mysql][:tunable][:innodb_buffer_pool_size] = "1G" 84 | set_unless[:db_mysql][:tunable][:innodb_additional_mem_pool_size] = "24M" 85 | set_unless[:db_mysql][:tunable][:log_slow_queries] = "log_slow_queries = /var/log/mysqlslow.log" 86 | set_unless[:db_mysql][:tunable][:long_query_time] = "long_query_time = 5" 87 | set_unless[:db_mysql][:tunable][:isamchk][:key_buffer] = "128M" 88 | set_unless[:db_mysql][:tunable][:isamchk][:sort_buffer_size] = "128M" 89 | set_unless[:db_mysql][:tunable][:myisamchk][:key_buffer] = "128M" 90 | set_unless[:db_mysql][:tunable][:myisamchk][:sort_buffer_size] = "128M" 91 | else 92 | set_unless[:db_mysql][:tunable][:key_buffer] = "64M" 93 | set_unless[:db_mysql][:tunable][:table_cache] = "64" 94 | set_unless[:db_mysql][:tunable][:sort_buffer_size] = "512K" 95 | set_unless[:db_mysql][:tunable][:net_buffer_length] = "8K" 96 | set_unless[:db_mysql][:tunable][:read_buffer_size] = "512K" 97 | set_unless[:db_mysql][:tunable][:read_rnd_buffer_size] = "1M" 98 | set_unless[:db_mysql][:tunable][:myisam_sort_buffer_size] = "8M" 99 | set_unless[:db_mysql][:tunable][:query_cache_size] = "4M" 100 | set_unless[:db_mysql][:tunable][:innodb_buffer_pool_size] = "16M" 101 | set_unless[:db_mysql][:tunable][:innodb_additional_mem_pool_size] = "2M" 102 | set_unless[:db_mysql][:tunable][:log_slow_queries] = "" 103 | set_unless[:db_mysql][:tunable][:long_query_time] = "" 104 | set_unless[:db_mysql][:tunable][:isamchk][:key_buffer] = "20M" 105 | set_unless[:db_mysql][:tunable][:isamchk][:sort_buffer_size] = "20M" 106 | set_unless[:db_mysql][:tunable][:myisamchk][:key_buffer] = "20M" 107 | set_unless[:db_mysql][:tunable][:myisamchk][:sort_buffer_size] = "20M" 108 | end 109 | when "m1.large", "c1.xlarge" 110 | if (db_mysql[:server_usage] == :dedicated) 111 | set_unless[:db_mysql][:tunable][:key_buffer] = "192M" 112 | set_unless[:db_mysql][:tunable][:table_cache] = "512" 113 | set_unless[:db_mysql][:tunable][:sort_buffer_size] = "4M" 114 | set_unless[:db_mysql][:tunable][:net_buffer_length] = "16K" 115 | set_unless[:db_mysql][:tunable][:read_buffer_size] = "1M" 116 | set_unless[:db_mysql][:tunable][:read_rnd_buffer_size] = "4M" 117 | set_unless[:db_mysql][:tunable][:myisam_sort_buffer_size] = "64M" 118 | set_unless[:db_mysql][:tunable][:query_cache_size] = "32M" 119 | set_unless[:db_mysql][:tunable][:innodb_buffer_pool_size] = "4500M" 120 | set_unless[:db_mysql][:tunable][:innodb_additional_mem_pool_size] = "200M" 121 | set_unless[:db_mysql][:tunable][:log_slow_queries] = "log_slow_queries = /var/log/mysqlslow.log" 122 | set_unless[:db_mysql][:tunable][:long_query_time] = "long_query_time = 5" 123 | set_unless[:db_mysql][:tunable][:isamchk][:key_buffer] = "128M" 124 | set_unless[:db_mysql][:tunable][:isamchk][:sort_buffer_size] = "128M" 125 | set_unless[:db_mysql][:tunable][:myisamchk][:key_buffer] = "128M" 126 | set_unless[:db_mysql][:tunable][:myisamchk][:sort_buffer_size] = "128M" 127 | else 128 | set_unless[:db_mysql][:tunable][:key_buffer] = "128M" 129 | set_unless[:db_mysql][:tunable][:table_cache] = "256" 130 | set_unless[:db_mysql][:tunable][:sort_buffer_size] = "2M" 131 | set_unless[:db_mysql][:tunable][:net_buffer_length] = "8K" 132 | set_unless[:db_mysql][:tunable][:read_buffer_size] = "256K" 133 | set_unless[:db_mysql][:tunable][:read_rnd_buffer_size] = "512K" 134 | set_unless[:db_mysql][:tunable][:myisam_sort_buffer_size] = "8M" 135 | set_unless[:db_mysql][:tunable][:query_cache_size] = "24M" 136 | set_unless[:db_mysql][:tunable][:innodb_buffer_pool_size] = "2G" 137 | set_unless[:db_mysql][:tunable][:innodb_additional_mem_pool_size] = "100M" 138 | set_unless[:db_mysql][:tunable][:log_slow_queries] = "" 139 | set_unless[:db_mysql][:tunable][:long_query_time] = "" 140 | set_unless[:db_mysql][:tunable][:isamchk][:key_buffer] = "20M" 141 | set_unless[:db_mysql][:tunable][:isamchk][:sort_buffer_size] = "20M" 142 | set_unless[:db_mysql][:tunable][:myisamchk][:key_buffer] = "20M" 143 | set_unless[:db_mysql][:tunable][:myisamchk][:sort_buffer_size] = "20M" 144 | end 145 | when "m1.xlarge" 146 | if (db_mysql[:server_usage] == :dedicated) 147 | set_unless[:db_mysql][:tunable][:key_buffer] = "265M" 148 | set_unless[:db_mysql][:tunable][:table_cache] = "1024" 149 | set_unless[:db_mysql][:tunable][:sort_buffer_size] = "8M" 150 | set_unless[:db_mysql][:tunable][:net_buffer_length] = "16K" 151 | set_unless[:db_mysql][:tunable][:read_buffer_size] = "1M" 152 | set_unless[:db_mysql][:tunable][:read_rnd_buffer_size] = "4M" 153 | set_unless[:db_mysql][:tunable][:myisam_sort_buffer_size] = "96M" 154 | set_unless[:db_mysql][:tunable][:query_cache_size] = "64M" 155 | set_unless[:db_mysql][:tunable][:innodb_buffer_pool_size] = "900M" 156 | set_unless[:db_mysql][:tunable][:innodb_additional_mem_pool_size] = "200M" 157 | set_unless[:db_mysql][:tunable][:log_slow_queries] = "log_slow_queries = /var/log/mysqlslow.log" 158 | set_unless[:db_mysql][:tunable][:long_query_time] = "long_query_time = 5" 159 | set_unless[:db_mysql][:tunable][:isamchk][:key_buffer] = "128M" 160 | set_unless[:db_mysql][:tunable][:isamchk][:sort_buffer_size] = "128M" 161 | set_unless[:db_mysql][:tunable][:myisamchk][:key_buffer] = "128M" 162 | set_unless[:db_mysql][:tunable][:myisamchk][:sort_buffer_size] = "128M" 163 | else 164 | set_unless[:db_mysql][:tunable][:key_buffer] = "192M" 165 | set_unless[:db_mysql][:tunable][:table_cache] = "512" 166 | set_unless[:db_mysql][:tunable][:sort_buffer_size] = "2M" 167 | set_unless[:db_mysql][:tunable][:net_buffer_length] = "8K" 168 | set_unless[:db_mysql][:tunable][:read_buffer_size] = "512K" 169 | set_unless[:db_mysql][:tunable][:read_rnd_buffer_size] = "512K" 170 | set_unless[:db_mysql][:tunable][:myisam_sort_buffer_size] = "8M" 171 | set_unless[:db_mysql][:tunable][:query_cache_size] = "32M" 172 | set_unless[:db_mysql][:tunable][:innodb_buffer_pool_size] = "4G" 173 | set_unless[:db_mysql][:tunable][:innodb_additional_mem_pool_size] = "100M" 174 | set_unless[:db_mysql][:tunable][:log_slow_queries] = "" 175 | set_unless[:db_mysql][:tunable][:long_query_time] = "" 176 | set_unless[:db_mysql][:tunable][:isamchk][:key_buffer] = "20M" 177 | set_unless[:db_mysql][:tunable][:isamchk][:sort_buffer_size] = "20M" 178 | set_unless[:db_mysql][:tunable][:myisamchk][:key_buffer] = "20M" 179 | set_unless[:db_mysql][:tunable][:myisamchk][:sort_buffer_size] = "20M" 180 | end 181 | end 182 | end 183 | --------------------------------------------------------------------------------