megalodon 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +4 -0
- data/README.md +80 -0
- data/bin/megalodon +68 -0
- data/config/rake.rb +60 -0
- data/config/run_list.json +5 -0
- data/config/run_vhosts.json +5 -0
- data/config/solo.rb +20 -0
- data/cookbooks/dnsmasq/recipies/default.rb +28 -0
- data/cookbooks/elasticsearch/recipies/default.rb +23 -0
- data/cookbooks/erlang/README.rdoc +8 -0
- data/cookbooks/erlang/metadata.rb +6 -0
- data/cookbooks/erlang/recipes/default.rb +8 -0
- data/cookbooks/git/README.rdoc +8 -0
- data/cookbooks/git/metadata.rb +6 -0
- data/cookbooks/git/recipes/default.rb +24 -0
- data/cookbooks/git/templates/default/dot.gitconfig.erb +47 -0
- data/cookbooks/homebrew/README.rdoc +73 -0
- data/cookbooks/homebrew/libraries/homebrew_package.rb +85 -0
- data/cookbooks/homebrew/metadata.json +33 -0
- data/cookbooks/homebrew/metadata.rb +9 -0
- data/cookbooks/homebrew/recipes/default.rb +11 -0
- data/cookbooks/jenkins/metadata.rb +9 -0
- data/cookbooks/jenkins/recipes/default.rb +21 -0
- data/cookbooks/maatkit/recipes/default.rb +10 -0
- data/cookbooks/megalodon/attributes/default.rb +3 -0
- data/cookbooks/megalodon/definitions/megalodon_app.rb +21 -0
- data/cookbooks/megalodon/recipes/apache_vhosts.rb +46 -0
- data/cookbooks/megalodon/recipes/default.rb +55 -0
- data/cookbooks/megalodon/recipes/misc.rb +14 -0
- data/cookbooks/megalodon/templates/default/default.conf.erb +26 -0
- data/cookbooks/megalodon/templates/default/default.json.erb +5 -0
- data/cookbooks/megalodon/templates/default/dot.profile.erb +22 -0
- data/cookbooks/megalodon/templates/default/php5.conf.erb +12 -0
- data/cookbooks/megalodon/templates/default/vhost.conf.erb +28 -0
- data/cookbooks/memcached/README.rdoc +8 -0
- data/cookbooks/memcached/metadata.rb +2 -0
- data/cookbooks/memcached/recipes/default.rb +9 -0
- data/cookbooks/mongodb/recipes/default.rb +23 -0
- data/cookbooks/mvim/README.rdoc +8 -0
- data/cookbooks/mvim/metadata.rb +6 -0
- data/cookbooks/mvim/recipes/default.rb +47 -0
- data/cookbooks/mvim/templates/default/dot.vimrc.erb +23 -0
- data/cookbooks/mysql/README.rdoc +143 -0
- data/cookbooks/mysql/attributes/server.rb +58 -0
- data/cookbooks/mysql/metadata.rb +78 -0
- data/cookbooks/mysql/recipes/default.rb +24 -0
- data/cookbooks/mysql/recipes/mariadb.rb +41 -0
- data/cookbooks/mysql/templates/default/my.cnf.erb +161 -0
- data/cookbooks/nginx/recipes/default.rb +66 -0
- data/cookbooks/nginx/templates/default/app_nginx.conf.erb +42 -0
- data/cookbooks/nginx/templates/default/default.conf.erb +40 -0
- data/cookbooks/nginx/templates/default/fastcgi_params.erb +23 -0
- data/cookbooks/nginx/templates/default/nginx.conf.erb +33 -0
- data/cookbooks/node/README.rdoc +8 -0
- data/cookbooks/node/metadata.rb +6 -0
- data/cookbooks/node/recipes/default.rb +12 -0
- data/cookbooks/php/attributes/default.rb +3 -0
- data/cookbooks/php/metadata.rb +2 -0
- data/cookbooks/php/providers/pear.rb +229 -0
- data/cookbooks/php/providers/pear_channel.rb +91 -0
- data/cookbooks/php/recipes/default.rb +25 -0
- data/cookbooks/php/recipes/fpm.rb +45 -0
- data/cookbooks/php/recipes/module_apc.rb +12 -0
- data/cookbooks/php/recipes/module_memcached.rb +12 -0
- data/cookbooks/php/recipes/module_mongo.rb +11 -0
- data/cookbooks/php/recipes/module_xdebug.rb +11 -0
- data/cookbooks/php/resources/pear.rb +28 -0
- data/cookbooks/php/resources/pear_channel.rb +28 -0
- data/cookbooks/php/templates/default/mods/apc.ini.erb +4 -0
- data/cookbooks/php/templates/default/mods/memcached.ini.erb +1 -0
- data/cookbooks/php/templates/default/mods/mongo.ini.erb +1 -0
- data/cookbooks/php/templates/default/mods/xdebug.ini.erb +39 -0
- data/cookbooks/php/templates/default/net.php.php-fpm.plist.erb +23 -0
- data/cookbooks/php/templates/default/php-fpm.conf.erb +323 -0
- data/cookbooks/php/templates/default/php.ini.erb +1854 -0
- data/cookbooks/php.tgz +0 -0
- data/cookbooks/phpunit/metadata.rb +8 -0
- data/cookbooks/phpunit/recipes/default.rb +38 -0
- data/cookbooks/python/README.rdoc +8 -0
- data/cookbooks/python/metadata.rb +6 -0
- data/cookbooks/python/recipes/default.rb +6 -0
- data/cookbooks/redis/recipes/default.rb +23 -0
- data/cookbooks/siege/recipes/default.rb +4 -0
- data/cookbooks/solr/metadata.json +36 -0
- data/cookbooks/solr/metadata.rb +9 -0
- data/cookbooks/solr/recipes/default.rb +18 -0
- data/cookbooks/varnish/attributes/default.rb +2 -0
- data/cookbooks/varnish/recipes/default.rb +24 -0
- data/cookbooks/varnish/templates/default/default.vcl.erb +268 -0
- data/cookbooks/varnish/templates/default/ubuntu-default.erb +103 -0
- data/cookbooks/xhprof/metadata.json +36 -0
- data/cookbooks/xhprof/metadata.rb +12 -0
- data/cookbooks/xhprof/recipes/default.rb +43 -0
- data/cookbooks/xhprof/templates/default/xhprof.ini.erb +2 -0
- data/formulas/apc.rb +63 -0
- data/formulas/cclient.rb +57 -0
- data/formulas/megalodon.rb +27 -0
- data/formulas/memcached-php.rb +24 -0
- data/formulas/mongo-php.rb +25 -0
- data/formulas/mongodb-php.rb +31 -0
- data/formulas/php-memcached.rb +31 -0
- data/formulas/php.rb +261 -0
- data/formulas/xdebug.rb +36 -0
- data/formulas/xhprof.rb +33 -0
- data/lib/megalodon/version.rb +3 -0
- data/megalodon.gemspec +14 -0
- data/roles/nginx_web_server.json +23 -0
- data/roles/web_server.json +19 -0
- metadata +170 -0
@@ -0,0 +1,21 @@
|
|
1
|
+
# Cookbook Name:: megalodon
|
2
|
+
# Definition:: megalodon_app
|
3
|
+
#
|
4
|
+
|
5
|
+
define :megalodon_app, :template => "megalodon_app.conf.erb", :enable => true do
|
6
|
+
|
7
|
+
application_name = params[:name]
|
8
|
+
|
9
|
+
template "/usr/local/etc/megalodon/apache_confs/#{application_name}.conf" do
|
10
|
+
source params[:template]
|
11
|
+
mode 0644
|
12
|
+
if params[:cookbook]
|
13
|
+
cookbook params[:cookbook]
|
14
|
+
end
|
15
|
+
variables(
|
16
|
+
:application_name => application_name,
|
17
|
+
:params => params
|
18
|
+
)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
@@ -0,0 +1,46 @@
|
|
1
|
+
brew_prefix = `brew --prefix`.strip
|
2
|
+
directory "#{brew_prefix}/etc/megalodon/apache_confs" do
|
3
|
+
action :create
|
4
|
+
end
|
5
|
+
|
6
|
+
# Setup databag directory for virtual hosts.
|
7
|
+
directory "#{ENV['HOME']}/.megalodon/data_bags/vhosts" do
|
8
|
+
action :create
|
9
|
+
end
|
10
|
+
|
11
|
+
# Write out initial default vhost data bag item.
|
12
|
+
template "#{ENV['HOME']}/.megalodon/data_bags/vhosts/default.json" do
|
13
|
+
source "default.json.erb"
|
14
|
+
action :create
|
15
|
+
end
|
16
|
+
|
17
|
+
# Update built-in Apache with administrative privleges.
|
18
|
+
# TODO - Use Ruby auth bindings instead of AppleScript.
|
19
|
+
# {Ruby OSX Auth}[http://ruby-osxauth.rubyforge.org/]
|
20
|
+
execute "Include conf in Mac Apache with admin privileges" do
|
21
|
+
command <<-EOS
|
22
|
+
/usr/bin/osascript -e 'do shell script "echo \\"Include /usr/local/etc/megalodon/apache_confs/*.conf\\" >> /etc/apache2/httpd.conf" with administrator privileges'
|
23
|
+
EOS
|
24
|
+
not_if "grep '^Include /usr/local/etc/megalodon/apache_confs' /etc/apache2/httpd.conf"
|
25
|
+
end
|
26
|
+
|
27
|
+
megalodon_app "000-default" do
|
28
|
+
docroot node["megalodon"]["docroot"]
|
29
|
+
server_name "localhost"
|
30
|
+
template "default.conf.erb"
|
31
|
+
end
|
32
|
+
|
33
|
+
vhosts = data_bag("vhosts")
|
34
|
+
vhosts.each do |vhost_name|
|
35
|
+
vhost = data_bag_item("vhosts", vhost_name)
|
36
|
+
megalodon_app vhost['id'] do
|
37
|
+
docroot vhost['docroot']
|
38
|
+
server_name vhost['servername']
|
39
|
+
server_aliases vhost['server_aliases']
|
40
|
+
template "vhost.conf.erb"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
template "#{node[:megalodon][:brew_prefix]}/etc/megalodon/apache_confs/php5.conf" do
|
45
|
+
source "php5.conf.erb"
|
46
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
#
|
2
|
+
# Cookbook Name:: megalodon
|
3
|
+
# Recipe:: default
|
4
|
+
#
|
5
|
+
|
6
|
+
directory "#{ENV['HOME']}/.megalodon" do
|
7
|
+
action :create
|
8
|
+
end
|
9
|
+
|
10
|
+
brew_prefix = `brew --prefix`.strip
|
11
|
+
|
12
|
+
directory "#{brew_prefix}/etc/megalodon" do
|
13
|
+
action :create
|
14
|
+
end
|
15
|
+
|
16
|
+
directory "#{brew_prefix}/var/www" do
|
17
|
+
action :create
|
18
|
+
end
|
19
|
+
|
20
|
+
directory "#{ENV['HOME']}/.megalodon/data_bags" do
|
21
|
+
action :create
|
22
|
+
end
|
23
|
+
|
24
|
+
directory "#{ENV['HOME']}/Library/LaunchAgents" do
|
25
|
+
action :create
|
26
|
+
end
|
27
|
+
|
28
|
+
template "#{ENV['HOME']}/.megalodon.profile" do
|
29
|
+
mode 0700
|
30
|
+
owner ENV['USER']
|
31
|
+
group Etc.getgrgid(Process.gid).name
|
32
|
+
source "dot.profile.erb"
|
33
|
+
variables({ :home => ENV['HOME'] })
|
34
|
+
end
|
35
|
+
|
36
|
+
%w(bash_profile bashrc zshrc).each do |config_file|
|
37
|
+
execute "include megalodon environment into defaults for ~/.#{config_file}" do
|
38
|
+
command "if [ -f ~/.#{config_file} ]; then echo 'source ~/.megalodon.profile' >> ~/.#{config_file}; fi"
|
39
|
+
not_if "grep -q 'megalodon.profile' ~/.#{config_file}"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
execute "setup megalodon profile sourcing in ~/.profile" do
|
44
|
+
command "echo 'source ~/.megalodon.profile' >> ~/.profile"
|
45
|
+
not_if "grep -q 'megalodon.profile' ~/.profile"
|
46
|
+
end
|
47
|
+
|
48
|
+
package "git"
|
49
|
+
script "updating homebrew from github" do
|
50
|
+
interpreter "bash"
|
51
|
+
code <<-EOS
|
52
|
+
source ~/.megalodon.profile
|
53
|
+
/usr/local/bin/brew update >> ~/.megalodon/brew.log 2>&1
|
54
|
+
EOS
|
55
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
#
|
2
|
+
# Cookbook Name:: megalodon
|
3
|
+
# Recipe:: misc
|
4
|
+
#
|
5
|
+
|
6
|
+
#root = File.expand_path(File.join(File.dirname(__FILE__), ".."))
|
7
|
+
|
8
|
+
#require root + '/resources/homebrew'
|
9
|
+
#require root + '/providers/homebrew'
|
10
|
+
include_recipe 'homebrew'
|
11
|
+
|
12
|
+
%w(autoconf automake coreutils bash-completion xz patchutils sqlite wget markdown ctags).each do |pkg|
|
13
|
+
package pkg
|
14
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
NameVirtualHost *:80
|
2
|
+
|
3
|
+
<VirtualHost *:80>
|
4
|
+
ServerName "<%= @params[:server_name] %>"
|
5
|
+
DocumentRoot "<%= @params[:docroot] %>"
|
6
|
+
RewriteEngine On
|
7
|
+
|
8
|
+
<Directory "<%= @params[:docroot] %>">
|
9
|
+
Options FollowSymLinks
|
10
|
+
AllowOverride All
|
11
|
+
Order allow,deny
|
12
|
+
Allow from all
|
13
|
+
|
14
|
+
AddOutputFilterByType DEFLATE text/html text/plain text/xml
|
15
|
+
AddOutputFilterByType DEFLATE application/x-javascript
|
16
|
+
AddOutputFilterByType DEFLATE application/javascript
|
17
|
+
AddOutputFilterByType DEFLATE text/javascript
|
18
|
+
AddOutputFilterByType DEFLATE text/css
|
19
|
+
</Directory>
|
20
|
+
|
21
|
+
<Directory />
|
22
|
+
Options FollowSymLinks
|
23
|
+
AllowOverride None
|
24
|
+
</Directory>
|
25
|
+
</VirtualHost>
|
26
|
+
|
@@ -0,0 +1,22 @@
|
|
1
|
+
PATH="/usr/local/bin:/usr/local/share/npm/bin:/usr/local/sbin:$PATH"; export PATH
|
2
|
+
MANPATH="/usr/local/share/man:$MANPATH"; export MANPATH
|
3
|
+
CFLAGS="-I/usr/local/include"; export CFLAGS
|
4
|
+
CPPFLAGS="-I/usr/local/include"; export CPPFLAGS
|
5
|
+
CXXFLAGS="-I/usr/local/include"; export CXXFLAGS
|
6
|
+
LDFLAGS="-L/usr/local/lib"; export LDFLAGS
|
7
|
+
NODE_PATH="/usr/local/lib/node"; export NODE_PATH
|
8
|
+
|
9
|
+
export CONFIGURE_ARGS="--with-cflags='$CFLAGS' --with-ldflags='$LDFLAGS'"
|
10
|
+
|
11
|
+
export rvm_path=/usr/local/.rvm
|
12
|
+
if [[ -s /usr/local/.rvm/scripts/rvm ]] ; then
|
13
|
+
source /usr/local/.rvm/scripts/rvm
|
14
|
+
fi
|
15
|
+
|
16
|
+
if [[ -d <%= node['megalodon']['php_prefix'] %>/bin ]]; then
|
17
|
+
export PATH=$PATH:<%= node['megalodon']['php_prefix'] %>/bin
|
18
|
+
fi
|
19
|
+
|
20
|
+
if [[ -f ~/.megalodon.profile.custom ]]; then
|
21
|
+
source ~/.megalodon.profile.custom
|
22
|
+
fi
|
@@ -0,0 +1,12 @@
|
|
1
|
+
LoadModule php5_module <%= node['megalodon']['php_prefix'] %>/libexec/apache2/libphp5.so
|
2
|
+
|
3
|
+
<IfModule php5_module>
|
4
|
+
AddType application/x-httpd-php .php
|
5
|
+
AddType application/x-httpd-php-source .phps
|
6
|
+
|
7
|
+
<IfModule dir_module>
|
8
|
+
DirectoryIndex index.html index.php index.htm
|
9
|
+
</IfModule>
|
10
|
+
</IfModule>
|
11
|
+
|
12
|
+
|
@@ -0,0 +1,28 @@
|
|
1
|
+
<VirtualHost *:80>
|
2
|
+
ServerName "<%= @params[:server_name] %>"
|
3
|
+
<% if @params[:server_aliases] %>
|
4
|
+
ServerAlias <%= @params[:server_aliases].join(" ") %>
|
5
|
+
<% end %>
|
6
|
+
|
7
|
+
DocumentRoot "<%= @params[:docroot] %>"
|
8
|
+
RewriteEngine On
|
9
|
+
|
10
|
+
<Directory "<%= @params[:docroot] %>">
|
11
|
+
Options FollowSymLinks
|
12
|
+
AllowOverride All
|
13
|
+
Order allow,deny
|
14
|
+
Allow from all
|
15
|
+
|
16
|
+
AddOutputFilterByType DEFLATE text/html text/plain text/xml
|
17
|
+
AddOutputFilterByType DEFLATE application/x-javascript
|
18
|
+
AddOutputFilterByType DEFLATE application/javascript
|
19
|
+
AddOutputFilterByType DEFLATE text/javascript
|
20
|
+
AddOutputFilterByType DEFLATE text/css
|
21
|
+
</Directory>
|
22
|
+
|
23
|
+
<Directory />
|
24
|
+
Options FollowSymLinks
|
25
|
+
AllowOverride None
|
26
|
+
</Directory>
|
27
|
+
</VirtualHost>
|
28
|
+
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# Cookbook Name:: mongodb
|
2
|
+
# Recipe:: default
|
3
|
+
|
4
|
+
package "mongodb"
|
5
|
+
|
6
|
+
plist="homebrew.mxcl.mongodb.plist"
|
7
|
+
|
8
|
+
bash "copy plist firsttime" do
|
9
|
+
code <<-EOS
|
10
|
+
(cp /usr/local/Cellar/mongodb/*/#{plist} ~/Library/LaunchAgents/)
|
11
|
+
(launchctl load -w ~/Library/LaunchAgents/#{plist})
|
12
|
+
EOS
|
13
|
+
not_if File.exists?("~/Library/LaunchAgents/#{plist}")
|
14
|
+
end
|
15
|
+
|
16
|
+
bash "copy new plist" do
|
17
|
+
code <<-EOS
|
18
|
+
launchctl unload -w ~/Library/LaunchAgents/#{plist}
|
19
|
+
cp /usr/local/Cellar/mongodb/*/#{plist} ~/Library/LaunchAgents/
|
20
|
+
launchctl load -w ~/Library/LaunchAgents/#{plist}
|
21
|
+
EOS
|
22
|
+
only_if File.exists?("~/Library/LaunchAgents/#{plist}")
|
23
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
#
|
2
|
+
# Cookbook Name:: atmos.vim
|
3
|
+
# Recipe:: default
|
4
|
+
#
|
5
|
+
|
6
|
+
script "installing http://github.com/carlhuda/janus" do
|
7
|
+
interpreter "bash"
|
8
|
+
code <<-EOS
|
9
|
+
source ~/.megaladon.profile
|
10
|
+
if [ ! -d ~/.vim ]; then
|
11
|
+
git clone git://github.com/carlhuda/janus.git ~/.vim
|
12
|
+
cd ~/.vim
|
13
|
+
rake
|
14
|
+
elif [ ! -d ~/.vim/Rakefile ]; then
|
15
|
+
for i in ~/.vim ~/.vimrc ~/.gvimrc; do [ -e $i ] && mv $i $i.old; done
|
16
|
+
git clone git://github.com/carlhuda/janus.git ~/.vim
|
17
|
+
cd ~/.vim
|
18
|
+
rake
|
19
|
+
fi
|
20
|
+
EOS
|
21
|
+
end
|
22
|
+
|
23
|
+
directory "#{ENV['HOME']}/.vimswap" do
|
24
|
+
action 'create'
|
25
|
+
end
|
26
|
+
|
27
|
+
template "#{ENV['HOME']}/.vimrc.local" do
|
28
|
+
source "dot.vimrc.erb"
|
29
|
+
end
|
30
|
+
|
31
|
+
template "#{ENV['HOME']}/.gvimrc.local" do
|
32
|
+
source "dot.vimrc.erb"
|
33
|
+
end
|
34
|
+
|
35
|
+
script "installed macvim from github" do
|
36
|
+
interpreter "bash"
|
37
|
+
code <<-EOS
|
38
|
+
source ~/.megaladon.profile
|
39
|
+
if [ ! -e /usr/local/bin/mvim ]; then
|
40
|
+
rm -rf /Applications/MacVim.app
|
41
|
+
curl -L https://github.com/downloads/b4winckler/macvim/MacVim-snapshot-59.tbz -o - | tar xj -
|
42
|
+
cd MacVim-snapshot-59
|
43
|
+
cp mvim /usr/local/bin/
|
44
|
+
cp -r MacVim.app /Applications/
|
45
|
+
fi
|
46
|
+
EOS
|
47
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
let g:NERDTreeMapOpenSplit = 'i'
|
2
|
+
set nu
|
3
|
+
set et
|
4
|
+
set ts=2
|
5
|
+
set sw=2
|
6
|
+
set ruler
|
7
|
+
colorscheme vibrantink
|
8
|
+
"set columns=145
|
9
|
+
"set lines=48
|
10
|
+
set guioptions-=T
|
11
|
+
set guioptions-=r
|
12
|
+
set guioptions-=L
|
13
|
+
set gfn=Inconsolata:h14
|
14
|
+
set backupdir=~/.vimswap
|
15
|
+
set directory=~/.vimswap
|
16
|
+
set nobackup
|
17
|
+
set noswapfile
|
18
|
+
set winheight=11
|
19
|
+
command! Trail :%s/\s\+$//g
|
20
|
+
nnoremap <D-r> :NERDTreeToggle<CR>
|
21
|
+
nnoremap <C-L> :nohls<CR><C-L>
|
22
|
+
set vb
|
23
|
+
set t_vb=
|
@@ -0,0 +1,143 @@
|
|
1
|
+
= DESCRIPTION:
|
2
|
+
|
3
|
+
Installs and configures MySQL client or server.
|
4
|
+
|
5
|
+
= REQUIREMENTS:
|
6
|
+
|
7
|
+
== Platform:
|
8
|
+
|
9
|
+
Best tested on Ubuntu 9.04,9.10. On EC2, requires platform that supports -o bind option for the 'mount' command.
|
10
|
+
|
11
|
+
== Cookbooks:
|
12
|
+
|
13
|
+
Requires Opscode's openssl cookbook for secure password generation.
|
14
|
+
|
15
|
+
Requires a C compiler and Ruby development package in order to build mysql gem with native extensions. On Debian and Ubuntu systems this is satisfied by installing the "build-essential" and "ruby-dev" packages before running Chef. See USAGE below for information on how to handle this during a Chef run.
|
16
|
+
|
17
|
+
= RESOURCES AND PROVIDERS
|
18
|
+
|
19
|
+
The cookbook contains a LWRP, +mysql_database+ which can be used to manage databases through calls to the MySQL API. The mysql gem is installed to make this usable. The provider currently supports three actions:
|
20
|
+
|
21
|
+
* +flush_tables_with_read_lock+ - sends the sql command "flush tables with read lock", used for setting up mysql master/slave replication.
|
22
|
+
* +unflush_tables+ - sends the sql command "unflush tables", used for setting up master/slave replication.
|
23
|
+
* +create_db+ - specify a database to be created.
|
24
|
+
|
25
|
+
For example see the USAGE section below.
|
26
|
+
|
27
|
+
= ATTRIBUTES:
|
28
|
+
|
29
|
+
* +mysql[:server_root_password]+ - Set the server's root password with this, default is a randomly generated password with +OpenSSL::Random.random_bytes+.
|
30
|
+
* +mysql[:server_repl_password]+ - Set the replication user 'repl' password with this, default is a randomly generated password with +OpenSSL::Random.random_bytes+.
|
31
|
+
* +mysql[:server_debian_password]+ - Set the debian-sys-maint user password with this, default is a randomly generated password with +OpenSSL::Random.random_bytes+.
|
32
|
+
* +mysql[:bind_address]+ - Listen address for MySQLd, default is node's ipaddress.
|
33
|
+
* +mysql[:datadir]+ - Location for mysql data directory, default is "/var/lib/mysql"
|
34
|
+
* +mysql[:ec2_path]+ - location of mysql datadir on EC2 nodes, default "/mnt/mysql"
|
35
|
+
|
36
|
+
Performance tuning attributes, each corresponds to the same-named parameter in my.cnf; default values listed
|
37
|
+
|
38
|
+
* +mysql[:tunable][:key_buffer]+ = "250M"
|
39
|
+
* +mysql[:tunable][:max_connections]+ = "800"
|
40
|
+
* +mysql[:tunable][:wait_timeout]+ = "180"
|
41
|
+
* +mysql[:tunable][:net_write_timeout]+ = "30"
|
42
|
+
* +mysql[:tunable][:net_write_timeout]+ = "30"
|
43
|
+
* +mysql[:tunable][:back_log]+ = "128"
|
44
|
+
* +mysql[:tunable][:table_cache]+ = "128"
|
45
|
+
* +mysql[:tunable][:max_heap_table_size]+ = "32M"
|
46
|
+
|
47
|
+
= USAGE:
|
48
|
+
|
49
|
+
On client nodes,
|
50
|
+
|
51
|
+
include_recipe "mysql::client"
|
52
|
+
|
53
|
+
This will install the MySQL client libraries and development headers on the system. It will also install the Ruby Gem +mysql+, so that the cookbook's LWRP (above) can be used. This is done during the compile-phase of the Chef run.
|
54
|
+
|
55
|
+
r = package ... do
|
56
|
+
action :nothing
|
57
|
+
end
|
58
|
+
|
59
|
+
r.run_action(:install)
|
60
|
+
|
61
|
+
This creates a resource object for the package and does the installation before other recipes are parsed. You'll need to have the C compiler and such (ie, build-essential on Ubuntu) before running the recipes, but we already do that when installing Chef :-). If you want to be able to access a MySQL database via Ruby within another recipe, you could do so, like so:
|
62
|
+
|
63
|
+
Gem.clear_paths # needed for Chef to find the gem...
|
64
|
+
require 'mysql' # requires the mysql gem
|
65
|
+
|
66
|
+
mysql_database "create application_production database" do
|
67
|
+
host "localhost"
|
68
|
+
username "root"
|
69
|
+
password node[:mysql][:server_root_password]
|
70
|
+
database "application_production"
|
71
|
+
action :create_db
|
72
|
+
end
|
73
|
+
|
74
|
+
This will connect to the MySQL server running on localhost as "root" and password as +mysql[:server_root_password]+ attribute (see below) and create the database specified with the +database+ parameter. The provider will attempt to determine whether the database exists first.
|
75
|
+
|
76
|
+
On server nodes,
|
77
|
+
|
78
|
+
include_recipe "mysql::server"
|
79
|
+
|
80
|
+
On Debian and Ubuntu, this will preseed the mysql-server package with the randomly generated root password from the attributes file. On other platforms, it simply installs the required packages. It will also create an SQL file, /etc/mysql/grants.sql, that will be used to set up grants for the root, repl and debian-sys-maint users.
|
81
|
+
|
82
|
+
On EC2 nodes,
|
83
|
+
|
84
|
+
include_recipe "mysql::server_ec2"
|
85
|
+
|
86
|
+
When the ec2_path doesn't exist we look for a mounted filesystem (eg, EBS) and move the datadir there.
|
87
|
+
|
88
|
+
The client recipe is already included by server and 'default' recipes.
|
89
|
+
|
90
|
+
To make sure that a C compiler and the Ruby development libraries are installed, use the following run list in the node or in a role:
|
91
|
+
|
92
|
+
{
|
93
|
+
"run_list": [
|
94
|
+
"recipe[build-essential]",
|
95
|
+
"recipe[ruby]",
|
96
|
+
"recipe[mysql::server]"
|
97
|
+
]
|
98
|
+
}
|
99
|
+
|
100
|
+
The build-essential and ruby cookbooks install the packages in question during the "execution" phase of the Chef client run, rather than the compile phase when the MySQL gem is installed. To work around this for now until the build-essential and ruby packages are updated, modify your local copies of the recipes:
|
101
|
+
|
102
|
+
In the Opscode build-essential default recipe:
|
103
|
+
|
104
|
+
%w{build-essential binutils-doc}.each do |pkg|
|
105
|
+
p = package pkg do
|
106
|
+
action :nothing
|
107
|
+
end
|
108
|
+
p.run_action(:install)
|
109
|
+
end
|
110
|
+
|
111
|
+
And the ruby recipe to have the following:
|
112
|
+
|
113
|
+
extra_packages.each do |pkg|
|
114
|
+
p = package pkg do
|
115
|
+
action :nothing
|
116
|
+
end
|
117
|
+
p.run_action(:install)
|
118
|
+
end
|
119
|
+
|
120
|
+
These cookbooks aren't strict dependencies, and not if the installation process already included installing build-essential and ruby1.8-dev (e.g. RubyGems installation).
|
121
|
+
|
122
|
+
For more infromation on the compile vs execution phase of a Chef run:
|
123
|
+
|
124
|
+
http://wiki.opscode.com/display/chef/Anatomy+of+a+Chef+Run
|
125
|
+
|
126
|
+
= LICENSE and AUTHOR:
|
127
|
+
|
128
|
+
Author:: Joshua Timberman (<joshua@opscode.com>)
|
129
|
+
Author:: AJ Christensen (<aj@opscode.com>)
|
130
|
+
|
131
|
+
Copyright:: 2009, Opscode, Inc
|
132
|
+
|
133
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
134
|
+
you may not use this file except in compliance with the License.
|
135
|
+
You may obtain a copy of the License at
|
136
|
+
|
137
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
138
|
+
|
139
|
+
Unless required by applicable law or agreed to in writing, software
|
140
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
141
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
142
|
+
See the License for the specific language governing permissions and
|
143
|
+
limitations under the License.
|
@@ -0,0 +1,58 @@
|
|
1
|
+
#
|
2
|
+
# Cookbook Name:: mysql
|
3
|
+
# Attributes:: server
|
4
|
+
#
|
5
|
+
# Copyright 2008-2009, Opscode, Inc.
|
6
|
+
#
|
7
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
+
# you may not use this file except in compliance with the License.
|
9
|
+
# You may obtain a copy of the License at
|
10
|
+
#
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
#
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
+
# See the License for the specific language governing permissions and
|
17
|
+
# limitations under the License.
|
18
|
+
#
|
19
|
+
|
20
|
+
#::Chef::Node.send(:include, Opscode::OpenSSL::Password)
|
21
|
+
|
22
|
+
#set_unless[:mysql][:server_root_password] = secure_password
|
23
|
+
#set_unless[:mysql][:server_repl_password] = secure_password
|
24
|
+
default[:mysql][:bind_address] = "127.0.0.1"
|
25
|
+
default[:mysql][:datadir] = "/usr/local/var/mysql"
|
26
|
+
|
27
|
+
default[:mysql][:tunable][:back_log] = "128"
|
28
|
+
default[:mysql][:tunable][:key_buffer] = "32M"
|
29
|
+
default[:mysql][:tunable][:max_allowed_packet] = "16M"
|
30
|
+
default[:mysql][:tunable][:max_connections] = "20"
|
31
|
+
default[:mysql][:tunable][:max_heap_table_size] = "32M"
|
32
|
+
default[:mysql][:tunable][:myisam_recover] = "BACKUP"
|
33
|
+
default[:mysql][:tunable][:net_read_timeout] = "30"
|
34
|
+
default[:mysql][:tunable][:net_write_timeout] = "30"
|
35
|
+
default[:mysql][:tunable][:table_cache] = "256"
|
36
|
+
default[:mysql][:tunable][:table_open_cache] = "256"
|
37
|
+
default[:mysql][:tunable][:thread_cache] = "128"
|
38
|
+
default[:mysql][:tunable][:thread_cache_size] = 8
|
39
|
+
default[:mysql][:tunable][:thread_concurrency] = 10
|
40
|
+
default[:mysql][:tunable][:thread_stack] = "256K"
|
41
|
+
default[:mysql][:tunable][:wait_timeout] = "180"
|
42
|
+
|
43
|
+
default[:mysql][:tunable][:query_cache_limit] = "1M"
|
44
|
+
default[:mysql][:tunable][:query_cache_size] = "32M"
|
45
|
+
|
46
|
+
default[:mysql][:tunable][:tmp_table_size] = "32M"
|
47
|
+
default[:mysql][:tunable][:max_heap_table_size] = "64M"
|
48
|
+
|
49
|
+
|
50
|
+
default[:mysql][:tunable][:log_slow_queries] = "/usr/local/var/log/mysql/slow.log"
|
51
|
+
default[:mysql][:tunable][:long_query_time] = 2
|
52
|
+
|
53
|
+
default[:mysql][:tunable][:innodb_buffer_pool_size] = "256M"
|
54
|
+
default[:mysql][:tunable][:key_buffer_size] = "4M"
|
55
|
+
default[:mysql][:tunable][:join_buffer_size] = "4M"
|
56
|
+
default[:mysql][:tunable][:read_buffer_size] = "4M"
|
57
|
+
default[:mysql][:tunable][:read_rnd_buffer_size] = "4M"
|
58
|
+
default[:mysql][:tunable][:sort_buffer_size] = "4M"
|
@@ -0,0 +1,78 @@
|
|
1
|
+
maintainer "Opscode, Inc."
|
2
|
+
maintainer_email "cookbooks@opscode.com"
|
3
|
+
license "Apache 2.0"
|
4
|
+
description "Installs and configures mysql for client or server"
|
5
|
+
long_description IO.read(File.join(File.dirname(__FILE__), 'README.rdoc'))
|
6
|
+
version "0.24.1"
|
7
|
+
recipe "mysql", "Includes the client recipe to configure a client"
|
8
|
+
recipe "mysql::client", "Installs packages required for mysql clients using run_action magic"
|
9
|
+
recipe "mysql::server", "Installs packages required for mysql servers w/o manual intervention"
|
10
|
+
recipe "mysql::server_ec2", "Performs EC2-specific mountpoint manipulation"
|
11
|
+
|
12
|
+
%w{ debian ubuntu centos suse fedora redhat mac_os_x}.each do |os|
|
13
|
+
supports os
|
14
|
+
end
|
15
|
+
|
16
|
+
depends "openssl"
|
17
|
+
|
18
|
+
attribute "mysql/server_root_password",
|
19
|
+
:display_name => "MySQL Server Root Password",
|
20
|
+
:description => "Randomly generated password for the mysqld root user",
|
21
|
+
:default => "randomly generated"
|
22
|
+
|
23
|
+
attribute "mysql/bind_address",
|
24
|
+
:display_name => "MySQL Bind Address",
|
25
|
+
:description => "Address that mysqld should listen on",
|
26
|
+
:default => "ipaddress"
|
27
|
+
|
28
|
+
attribute "mysql/datadir",
|
29
|
+
:display_name => "MySQL Data Directory",
|
30
|
+
:description => "Location of mysql databases",
|
31
|
+
:default => "/var/lib/mysql"
|
32
|
+
|
33
|
+
attribute "mysql/ec2_path",
|
34
|
+
:display_name => "MySQL EC2 Path",
|
35
|
+
:description => "Location of mysql directory on EC2 instance EBS volumes",
|
36
|
+
:default => "/mnt/mysql"
|
37
|
+
|
38
|
+
attribute "mysql/tunable",
|
39
|
+
:display_name => "MySQL Tunables",
|
40
|
+
:description => "Hash of MySQL tunable attributes",
|
41
|
+
:type => "hash"
|
42
|
+
|
43
|
+
attribute "mysql/tunable/key_buffer",
|
44
|
+
:display_name => "MySQL Tuntable Key Buffer",
|
45
|
+
:default => "250M"
|
46
|
+
|
47
|
+
attribute "mysql/tunable/max_connections",
|
48
|
+
:display_name => "MySQL Tunable Max Connections",
|
49
|
+
:default => "800"
|
50
|
+
|
51
|
+
attribute "mysql/tunable/wait_timeout",
|
52
|
+
:display_name => "MySQL Tunable Wait Timeout",
|
53
|
+
:default => "180"
|
54
|
+
|
55
|
+
attribute "mysql/tunable/net_read_timeout",
|
56
|
+
:display_name => "MySQL Tunable Net Read Timeout",
|
57
|
+
:default => "30"
|
58
|
+
|
59
|
+
attribute "mysql/tunable/net_write_timeout",
|
60
|
+
:display_name => "MySQL Tunable Net Write Timeout",
|
61
|
+
:default => "30"
|
62
|
+
|
63
|
+
attribute "mysql/tunable/back_log",
|
64
|
+
:display_name => "MySQL Tunable Back Log",
|
65
|
+
:default => "128"
|
66
|
+
|
67
|
+
attribute "mysql/tunable/table_cache",
|
68
|
+
:display_name => "MySQL Tunable Table Cache for MySQL < 5.1.3",
|
69
|
+
:default => "128"
|
70
|
+
|
71
|
+
attribute "mysql/tunable/table_open_cache",
|
72
|
+
:display_name => "MySQL Tunable Table Cache for MySQL >= 5.1.3",
|
73
|
+
:default => "128"
|
74
|
+
|
75
|
+
attribute "mysql/tunable/max_heap_table_size",
|
76
|
+
:display_name => "MySQL Tunable Max Heap Table Size",
|
77
|
+
:default => "32M"
|
78
|
+
|