elzar 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (156) hide show
  1. data/.chef/knife.rb +3 -0
  2. data/.gitignore +1 -0
  3. data/.rvmrc +1 -0
  4. data/Gemfile +11 -0
  5. data/Gemfile.lock +96 -0
  6. data/README.md +42 -0
  7. data/Rakefile +1 -0
  8. data/Vagrantfile +16 -0
  9. data/cookbooks/.gitkeep +0 -0
  10. data/cookbooks/apt/README.md +122 -0
  11. data/cookbooks/apt/files/default/apt-cacher +9 -0
  12. data/cookbooks/apt/files/default/apt-cacher.conf +144 -0
  13. data/cookbooks/apt/files/default/apt-proxy-v2.conf +50 -0
  14. data/cookbooks/apt/metadata.rb +13 -0
  15. data/cookbooks/apt/providers/repository.rb +73 -0
  16. data/cookbooks/apt/recipes/cacher-client.rb +44 -0
  17. data/cookbooks/apt/recipes/cacher.rb +45 -0
  18. data/cookbooks/apt/recipes/default.rb +50 -0
  19. data/cookbooks/apt/resources/repository.rb +30 -0
  20. data/cookbooks/build-essential/README.md +24 -0
  21. data/cookbooks/build-essential/metadata.rb +10 -0
  22. data/cookbooks/build-essential/recipes/default.rb +45 -0
  23. data/cookbooks/database/README.md +403 -0
  24. data/cookbooks/database/libraries/provider_database_mysql.rb +97 -0
  25. data/cookbooks/database/libraries/provider_database_mysql_user.rb +76 -0
  26. data/cookbooks/database/libraries/provider_database_postgresql.rb +126 -0
  27. data/cookbooks/database/libraries/provider_database_postgresql_user.rb +78 -0
  28. data/cookbooks/database/libraries/provider_database_sql_server.rb +109 -0
  29. data/cookbooks/database/libraries/provider_database_sql_server_user.rb +106 -0
  30. data/cookbooks/database/libraries/resource_database.rb +111 -0
  31. data/cookbooks/database/libraries/resource_database_user.rb +90 -0
  32. data/cookbooks/database/libraries/resource_mysql_database.rb +34 -0
  33. data/cookbooks/database/libraries/resource_mysql_database_user.rb +34 -0
  34. data/cookbooks/database/libraries/resource_postgresql_database.rb +35 -0
  35. data/cookbooks/database/libraries/resource_postgresql_database_user.rb +35 -0
  36. data/cookbooks/database/libraries/resource_sql_server_database.rb +34 -0
  37. data/cookbooks/database/libraries/resource_sql_server_database_user.rb +34 -0
  38. data/cookbooks/database/metadata.rb +21 -0
  39. data/cookbooks/database/recipes/default.rb +20 -0
  40. data/cookbooks/database/recipes/ebs_backup.rb +89 -0
  41. data/cookbooks/database/recipes/ebs_volume.rb +196 -0
  42. data/cookbooks/database/recipes/master.rb +78 -0
  43. data/cookbooks/database/recipes/snapshot.rb +62 -0
  44. data/cookbooks/database/templates/default/app_grants.sql.erb +8 -0
  45. data/cookbooks/database/templates/default/aws_config.erb +3 -0
  46. data/cookbooks/database/templates/default/chef-solo-database-snapshot.cron.erb +10 -0
  47. data/cookbooks/database/templates/default/chef-solo-database-snapshot.json.erb +1 -0
  48. data/cookbooks/database/templates/default/chef-solo-database-snapshot.rb.erb +6 -0
  49. data/cookbooks/database/templates/default/ebs-backup-cron.erb +2 -0
  50. data/cookbooks/database/templates/default/ebs-db-backup.sh.erb +8 -0
  51. data/cookbooks/database/templates/default/ebs-db-restore.sh.erb +10 -0
  52. data/cookbooks/database/templates/default/s3cfg.erb +27 -0
  53. data/cookbooks/mysql/README.md +148 -0
  54. data/cookbooks/mysql/attributes/server.rb +68 -0
  55. data/cookbooks/mysql/libraries/database.rb +19 -0
  56. data/cookbooks/mysql/libraries/helpers.rb +33 -0
  57. data/cookbooks/mysql/metadata.rb +90 -0
  58. data/cookbooks/mysql/recipes/client.rb +51 -0
  59. data/cookbooks/mysql/recipes/default.rb +20 -0
  60. data/cookbooks/mysql/recipes/server.rb +133 -0
  61. data/cookbooks/mysql/recipes/server_ec2.rb +49 -0
  62. data/cookbooks/mysql/templates/default/debian.cnf.erb +12 -0
  63. data/cookbooks/mysql/templates/default/grants.sql.erb +15 -0
  64. data/cookbooks/mysql/templates/default/my.cnf.erb +176 -0
  65. data/cookbooks/mysql/templates/default/mysql-server.seed.erb +10 -0
  66. data/cookbooks/mysql/templates/default/port_mysql.erb +3 -0
  67. data/cookbooks/openssl/README.md +37 -0
  68. data/cookbooks/openssl/libraries/secure_password.rb +37 -0
  69. data/cookbooks/openssl/metadata.rb +8 -0
  70. data/cookbooks/openssl/recipes/default.rb +19 -0
  71. data/cookbooks/passenger_enterprise/README.rdoc +8 -0
  72. data/cookbooks/passenger_enterprise/attributes/default.rb +28 -0
  73. data/cookbooks/passenger_enterprise/cc.gemspec +36 -0
  74. data/cookbooks/passenger_enterprise/metadata.json +44 -0
  75. data/cookbooks/passenger_enterprise/metadata.rb +16 -0
  76. data/cookbooks/passenger_enterprise/recipes/apache2.rb +54 -0
  77. data/cookbooks/passenger_enterprise/recipes/default.rb +30 -0
  78. data/cookbooks/passenger_enterprise/recipes/nginx.rb +50 -0
  79. data/cookbooks/passenger_enterprise/templates/default/passenger.conf.erb +2 -0
  80. data/cookbooks/passenger_enterprise/templates/default/passenger.load.erb +1 -0
  81. data/cookbooks/passenger_enterprise/templates/default/passenger_nginx.conf.erb +2 -0
  82. data/cookbooks/ruby_enterprise/README.rdoc +55 -0
  83. data/cookbooks/ruby_enterprise/attributes/default.rb +33 -0
  84. data/cookbooks/ruby_enterprise/cc.gemspec +36 -0
  85. data/cookbooks/ruby_enterprise/definitions/ree_gem.rb +28 -0
  86. data/cookbooks/ruby_enterprise/metadata.json +45 -0
  87. data/cookbooks/ruby_enterprise/metadata.rb +13 -0
  88. data/cookbooks/ruby_enterprise/recipes/default.rb +67 -0
  89. data/data_bags/deploy/authorized_keys.json +9 -0
  90. data/dna.json +25 -0
  91. data/elzar.gemspec +22 -0
  92. data/lib/elzar.rb +21 -0
  93. data/lib/elzar/assistant.rb +77 -0
  94. data/lib/elzar/chef_dna.rb +48 -0
  95. data/lib/elzar/template.rb +24 -0
  96. data/lib/elzar/templates/Gemfile +11 -0
  97. data/lib/elzar/templates/Vagrantfile.erb +16 -0
  98. data/lib/elzar/templates/dna.json +25 -0
  99. data/lib/elzar/templates/solo.rb.erb +6 -0
  100. data/lib/elzar/version.rb +3 -0
  101. data/roles/enterprise_appstack.rb +4 -0
  102. data/roles/plumbing.rb +11 -0
  103. data/roles/postgres_database.rb +4 -0
  104. data/roles/ruby_appstack.rb +4 -0
  105. data/script/install_cookbook +6 -0
  106. data/script/new_cookbook +5 -0
  107. data/site-cookbooks/.gitkeep +0 -0
  108. data/site-cookbooks/curl/README.md +17 -0
  109. data/site-cookbooks/curl/metadata.rb +6 -0
  110. data/site-cookbooks/curl/recipes/default.rb +11 -0
  111. data/site-cookbooks/nginx/CHANGELOG.md +11 -0
  112. data/site-cookbooks/nginx/CONTRIBUTING +29 -0
  113. data/site-cookbooks/nginx/LICENSE +201 -0
  114. data/site-cookbooks/nginx/README.md +76 -0
  115. data/site-cookbooks/nginx/attributes/default.rb +65 -0
  116. data/site-cookbooks/nginx/definitions/nginx_site.rb +35 -0
  117. data/site-cookbooks/nginx/files/default/mime.types +73 -0
  118. data/site-cookbooks/nginx/metadata.rb +89 -0
  119. data/site-cookbooks/nginx/recipes/default.rb +57 -0
  120. data/site-cookbooks/nginx/recipes/source.rb +126 -0
  121. data/site-cookbooks/nginx/templates/default/default-site.erb +11 -0
  122. data/site-cookbooks/nginx/templates/default/nginx.conf.erb +42 -0
  123. data/site-cookbooks/nginx/templates/default/nginx.init.erb +91 -0
  124. data/site-cookbooks/nginx/templates/default/nxdissite.erb +29 -0
  125. data/site-cookbooks/nginx/templates/default/nxensite.erb +38 -0
  126. data/site-cookbooks/passenger/README.md +12 -0
  127. data/site-cookbooks/passenger/attributes/default.rb +3 -0
  128. data/site-cookbooks/passenger/metadata.rb +6 -0
  129. data/site-cookbooks/passenger/recipes/default.rb +39 -0
  130. data/site-cookbooks/passenger/templates/default/passenger_nginx.conf.erb +2 -0
  131. data/site-cookbooks/postgresql/README.md +150 -0
  132. data/site-cookbooks/postgresql/attributes/default.rb +72 -0
  133. data/site-cookbooks/postgresql/metadata.rb +21 -0
  134. data/site-cookbooks/postgresql/recipes/client.rb +40 -0
  135. data/site-cookbooks/postgresql/recipes/default.rb +20 -0
  136. data/site-cookbooks/postgresql/recipes/server.rb +74 -0
  137. data/site-cookbooks/postgresql/recipes/server_debian.rb +62 -0
  138. data/site-cookbooks/postgresql/recipes/server_redhat.rb +82 -0
  139. data/site-cookbooks/postgresql/templates/default/debian.postgresql.conf.erb +499 -0
  140. data/site-cookbooks/postgresql/templates/default/pg_hba.conf.erb +83 -0
  141. data/site-cookbooks/postgresql/templates/default/redhat.postgresql.conf.erb +501 -0
  142. data/site-cookbooks/rails_app/README.md +15 -0
  143. data/site-cookbooks/rails_app/attributes/default.rb +2 -0
  144. data/site-cookbooks/rails_app/files/default/sudoers +26 -0
  145. data/site-cookbooks/rails_app/metadata.rb +6 -0
  146. data/site-cookbooks/rails_app/recipes/default.rb +143 -0
  147. data/site-cookbooks/rails_app/recipes/system_libraries.rb +12 -0
  148. data/site-cookbooks/rails_app/templates/default/pg_hba.conf.erb +84 -0
  149. data/site-cookbooks/rails_app/templates/default/rails_app_nginx.erb +10 -0
  150. data/site-cookbooks/ruby/README.md +12 -0
  151. data/site-cookbooks/ruby/attributes/default.rb +6 -0
  152. data/site-cookbooks/ruby/metadata.rb +6 -0
  153. data/site-cookbooks/ruby/recipes/default.rb +54 -0
  154. data/solo.rb +7 -0
  155. data/upgrade-chef.sh +8 -0
  156. metadata +272 -0
@@ -0,0 +1,50 @@
1
+ [DEFAULT]
2
+ ;; All times are in seconds, but you can add a suffix
3
+ ;; for minutes(m), hours(h) or days(d)
4
+
5
+ ;; commented out address so apt-proxy will listen on all IPs
6
+ ;; address = 127.0.0.1
7
+ port = 9999
8
+ cache_dir = /var/cache/apt-proxy
9
+
10
+ ;; Control files (Packages/Sources/Contents) refresh rate
11
+ min_refresh_delay = 1s
12
+ complete_clientless_downloads = 1
13
+
14
+ ;; Debugging settings.
15
+ debug = all:4 db:0
16
+
17
+ time = 30
18
+ passive_ftp = on
19
+
20
+ ;;--------------------------------------------------------------
21
+ ;; Cache housekeeping
22
+
23
+ cleanup_freq = 1d
24
+ max_age = 120d
25
+ max_versions = 3
26
+
27
+ ;;---------------------------------------------------------------
28
+ ;; Backend servers
29
+ ;;
30
+ ;; Place each server in its own [section]
31
+
32
+ [ubuntu]
33
+ ; Ubuntu archive
34
+ backends =
35
+ http://us.archive.ubuntu.com/ubuntu
36
+
37
+ [ubuntu-security]
38
+ ; Ubuntu security updates
39
+ backends = http://security.ubuntu.com/ubuntu
40
+
41
+ [debian]
42
+ ;; Backend servers, in order of preference
43
+ backends =
44
+ http://debian.osuosl.org/debian/
45
+
46
+ [security]
47
+ ;; Debian security archive
48
+ backends =
49
+ http://security.debian.org/debian-security
50
+ http://ftp2.de.debian.org/debian-security
@@ -0,0 +1,13 @@
1
+ maintainer "Opscode, Inc."
2
+ maintainer_email "cookbooks@opscode.com"
3
+ license "Apache 2.0"
4
+ description "Configures apt and apt services and an LWRP for managing apt repositories"
5
+ long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
6
+ version "1.2.0"
7
+ recipe "apt", "Runs apt-get update during compile phase and sets up preseed directories"
8
+ recipe "apt::cacher", "Set up an APT cache"
9
+ recipe "apt::cacher-client", "Client for the apt::cacher server"
10
+
11
+ %w{ ubuntu debian }.each do |os|
12
+ supports os
13
+ end
@@ -0,0 +1,73 @@
1
+ #
2
+ # Cookbook Name:: apt
3
+ # Provider:: repository
4
+ #
5
+ # Copyright 2010-2011, Opscode, Inc.
6
+ #
7
+ # Licensed under the Apache License, Version 2.0 (the "License");
8
+ # you may not use this file except in compliance with the License.
9
+ # You may obtain a copy of the License at
10
+ #
11
+ # http://www.apache.org/licenses/LICENSE-2.0
12
+ #
13
+ # Unless required by applicable law or agreed to in writing, software
14
+ # distributed under the License is distributed on an "AS IS" BASIS,
15
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ # See the License for the specific language governing permissions and
17
+ # limitations under the License.
18
+ #
19
+
20
+ action :add do
21
+ unless ::File.exists?("/etc/apt/sources.list.d/#{new_resource.repo_name}-source.list")
22
+ Chef::Log.info "Adding #{new_resource.repo_name} repository to /etc/apt/sources.list.d/#{new_resource.repo_name}-source.list"
23
+ # add key
24
+ if new_resource.keyserver && new_resource.key
25
+ execute "install-key #{new_resource.key}" do
26
+ command "apt-key adv --keyserver #{new_resource.keyserver} --recv #{new_resource.key}"
27
+ action :nothing
28
+ end.run_action(:run)
29
+ elsif new_resource.key && (new_resource.key =~ /http/)
30
+ key_name = new_resource.key.split(/\//).last
31
+ remote_file "#{Chef::Config[:file_cache_path]}/#{key_name}" do
32
+ source new_resource.key
33
+ mode "0644"
34
+ action :nothing
35
+ end.run_action(:create_if_missing)
36
+ execute "install-key #{key_name}" do
37
+ command "apt-key add #{Chef::Config[:file_cache_path]}/#{key_name}"
38
+ action :nothing
39
+ end.run_action(:run)
40
+ end
41
+ # build our listing
42
+ repository = "deb"
43
+ repository = "deb-src" if new_resource.deb_src
44
+ repository = "# Created by the Chef apt_repository LWRP\n" + repository
45
+ repository += " #{new_resource.uri}"
46
+ repository += " #{new_resource.distribution}"
47
+ new_resource.components.each {|component| repository += " #{component}"}
48
+ # write out the file, replace it if it already exists
49
+ file "/etc/apt/sources.list.d/#{new_resource.repo_name}-source.list" do
50
+ owner "root"
51
+ group "root"
52
+ mode 0644
53
+ content repository + "\n"
54
+ action :nothing
55
+ end.run_action(:create)
56
+ execute "update package index" do
57
+ command "apt-get update"
58
+ ignore_failure true
59
+ action :nothing
60
+ end.run_action(:run)
61
+ new_resource.updated_by_last_action(true)
62
+ end
63
+ end
64
+
65
+ action :remove do
66
+ if ::File.exists?("/etc/apt/sources.list.d/#{new_resource.repo_name}-source.list")
67
+ Chef::Log.info "Removing #{new_resource.repo_name} repository from /etc/apt/sources.list.d/"
68
+ file "/etc/apt/sources.list.d/#{new_resource.repo_name}-source.list" do
69
+ action :delete
70
+ end
71
+ new_resource.updated_by_last_action(true)
72
+ end
73
+ end
@@ -0,0 +1,44 @@
1
+ #
2
+ # Cookbook Name:: apt
3
+ # Recipe:: cacher-client
4
+ #
5
+ # Copyright 2011, Opscode, Inc.
6
+ #
7
+ # Licensed under the Apache License, Version 2.0 (the "License");
8
+ # you may not use this file except in compliance with the License.
9
+ # You may obtain a copy of the License at
10
+ #
11
+ # http://www.apache.org/licenses/LICENSE-2.0
12
+ #
13
+ # Unless required by applicable law or agreed to in writing, software
14
+ # distributed under the License is distributed on an "AS IS" BASIS,
15
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ # See the License for the specific language governing permissions and
17
+ # limitations under the License.
18
+ #
19
+
20
+ #remove Acquire::http::Proxy lines from /etc/apt/apt.conf since we use 01proxy
21
+ #these are leftover from preseed installs
22
+ execute "Remove proxy from /etc/apt/apt.conf" do
23
+ command "sed --in-place '/^Acquire::http::Proxy/d' /etc/apt/apt.conf"
24
+ only_if "grep Acquire::http::Proxy /etc/apt/apt.conf"
25
+ end
26
+
27
+ servers = search(:node, 'recipes:apt\:\:cacher') || []
28
+ if servers.length > 0
29
+ Chef::Log.info("apt-cacher server found on #{servers[0]}.")
30
+ proxy = "Acquire::http::Proxy \"http://#{servers[0].ipaddress}:3142\";\n"
31
+ file "/etc/apt/apt.conf.d/01proxy" do
32
+ owner "root"
33
+ group "root"
34
+ mode "0644"
35
+ content proxy
36
+ action :create
37
+ end
38
+ else
39
+ Chef::Log.info("No apt-cacher server found.")
40
+ file "/etc/apt/apt.conf.d/01proxy" do
41
+ action :delete
42
+ only_if {File.exists?("/etc/apt/apt.conf.d/01proxy")}
43
+ end
44
+ end
@@ -0,0 +1,45 @@
1
+ #
2
+ # Cookbook Name:: apt
3
+ # Recipe:: cacher
4
+ #
5
+ # Copyright 2008-2011, Opscode, Inc.
6
+ #
7
+ # Licensed under the Apache License, Version 2.0 (the "License");
8
+ # you may not use this file except in compliance with the License.
9
+ # You may obtain a copy of the License at
10
+ #
11
+ # http://www.apache.org/licenses/LICENSE-2.0
12
+ #
13
+ # Unless required by applicable law or agreed to in writing, software
14
+ # distributed under the License is distributed on an "AS IS" BASIS,
15
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ # See the License for the specific language governing permissions and
17
+ # limitations under the License.
18
+ #
19
+ package "apt-cacher" do
20
+ action :install
21
+ end
22
+
23
+ service "apt-cacher" do
24
+ supports :restart => true, :status => false
25
+ action [ :enable, :start ]
26
+ end
27
+
28
+ cookbook_file "/etc/apt-cacher/apt-cacher.conf" do
29
+ source "apt-cacher.conf"
30
+ owner "root"
31
+ group "root"
32
+ mode 0644
33
+ notifies :restart, resources(:service => "apt-cacher")
34
+ end
35
+
36
+ cookbook_file "/etc/default/apt-cacher" do
37
+ source "apt-cacher"
38
+ owner "root"
39
+ group "root"
40
+ mode 0644
41
+ notifies :restart, resources(:service => "apt-cacher")
42
+ end
43
+
44
+ #this will help seed the proxy
45
+ include_recipe "apt::cacher-client"
@@ -0,0 +1,50 @@
1
+ #
2
+ # Cookbook Name:: apt
3
+ # Recipe:: default
4
+ #
5
+ # Copyright 2008-2011, Opscode, Inc.
6
+ # Copyright 2009, Bryan McLellan <btm@loftninjas.org>
7
+ #
8
+ # Licensed under the Apache License, Version 2.0 (the "License");
9
+ # you may not use this file except in compliance with the License.
10
+ # You may obtain a copy of the License at
11
+ #
12
+ # http://www.apache.org/licenses/LICENSE-2.0
13
+ #
14
+ # Unless required by applicable law or agreed to in writing, software
15
+ # distributed under the License is distributed on an "AS IS" BASIS,
16
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
+ # See the License for the specific language governing permissions and
18
+ # limitations under the License.
19
+ #
20
+
21
+ # Run apt-get update to create the stamp file
22
+ execute "apt-get-update" do
23
+ command "apt-get update"
24
+ ignore_failure true
25
+ not_if do ::File.exists?('/var/lib/apt/periodic/update-success-stamp') end
26
+ action :nothing
27
+ end
28
+
29
+ # provides /var/lib/apt/periodic/update-success-stamp on apt-get update
30
+ package "update-notifier-common" do
31
+ notifies :run, resources(:execute => "apt-get-update"), :immediately
32
+ end
33
+
34
+ execute "apt-get-update-periodic" do
35
+ command "apt-get update"
36
+ ignore_failure true
37
+ only_if do
38
+ File.exists?('/var/lib/apt/periodic/update-success-stamp') &&
39
+ File.mtime('/var/lib/apt/periodic/update-success-stamp') < Time.now - 86400
40
+ end
41
+ end
42
+
43
+ %w{/var/cache/local /var/cache/local/preseeding}.each do |dirname|
44
+ directory dirname do
45
+ owner "root"
46
+ group "root"
47
+ mode 0644
48
+ action :create
49
+ end
50
+ end
@@ -0,0 +1,30 @@
1
+ #
2
+ # Cookbook Name:: apt
3
+ # Resource:: repository
4
+ #
5
+ # Copyright 2010-2011, Opscode, Inc.
6
+ #
7
+ # Licensed under the Apache License, Version 2.0 (the "License");
8
+ # you may not use this file except in compliance with the License.
9
+ # You may obtain a copy of the License at
10
+ #
11
+ # http://www.apache.org/licenses/LICENSE-2.0
12
+ #
13
+ # Unless required by applicable law or agreed to in writing, software
14
+ # distributed under the License is distributed on an "AS IS" BASIS,
15
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ # See the License for the specific language governing permissions and
17
+ # limitations under the License.
18
+ #
19
+
20
+ actions :add, :remove
21
+
22
+ #name of the repo, used for source.list filename
23
+ attribute :repo_name, :kind_of => String, :name_attribute => true
24
+ attribute :uri, :kind_of => String
25
+ attribute :distribution, :kind_of => String
26
+ attribute :components, :kind_of => Array, :default => []
27
+ #whether or not to add the repository as a source repo as well
28
+ attribute :deb_src, :default => false
29
+ attribute :keyserver, :kind_of => String, :default => nil
30
+ attribute :key, :kind_of => String, :default => nil
@@ -0,0 +1,24 @@
1
+ DESCRIPTION
2
+ ===========
3
+
4
+ Installs packages required for compiling C software from source.
5
+
6
+ LICENSE AND AUTHOR
7
+ ==================
8
+
9
+ Author:: Joshua Timberman (<joshua@opscode.com>)
10
+ Author:: Seth Chisamore (<schisamo@opscode.com>)
11
+
12
+ Copyright 2009-2011, Opscode, Inc.
13
+
14
+ Licensed under the Apache License, Version 2.0 (the "License");
15
+ you may not use this file except in compliance with the License.
16
+ You may obtain a copy of the License at
17
+
18
+ http://www.apache.org/licenses/LICENSE-2.0
19
+
20
+ Unless required by applicable law or agreed to in writing, software
21
+ distributed under the License is distributed on an "AS IS" BASIS,
22
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
23
+ See the License for the specific language governing permissions and
24
+ limitations under the License.
@@ -0,0 +1,10 @@
1
+ maintainer "Opscode, Inc."
2
+ maintainer_email "cookbooks@opscode.com"
3
+ license "Apache 2.0"
4
+ description "Installs C compiler / build tools"
5
+ version "1.0.0"
6
+ recipe "build-essential", "Installs C compiler and build tools on Linux"
7
+
8
+ %w{ fedora redhat centos ubuntu debian }.each do |os|
9
+ supports os
10
+ end
@@ -0,0 +1,45 @@
1
+ #
2
+ # Cookbook Name:: build-essential
3
+ # Recipe:: default
4
+ #
5
+ # Copyright 2008-2009, Opscode, Inc.
6
+ #
7
+ # Licensed under the Apache License, Version 2.0 (the "License");
8
+ # you may not use this file except in compliance with the License.
9
+ # You may obtain a copy of the License at
10
+ #
11
+ # http://www.apache.org/licenses/LICENSE-2.0
12
+ #
13
+ # Unless required by applicable law or agreed to in writing, software
14
+ # distributed under the License is distributed on an "AS IS" BASIS,
15
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ # See the License for the specific language governing permissions and
17
+ # limitations under the License.
18
+ #
19
+
20
+ case node['platform']
21
+ when "ubuntu","debian"
22
+ %w{build-essential binutils-doc}.each do |pkg|
23
+ package pkg do
24
+ action :install
25
+ end
26
+ end
27
+ when "centos","redhat","fedora"
28
+ %w{gcc gcc-c++ kernel-devel make}.each do |pkg|
29
+ package pkg do
30
+ action :install
31
+ end
32
+ end
33
+ end
34
+
35
+ package "autoconf" do
36
+ action :install
37
+ end
38
+
39
+ package "flex" do
40
+ action :install
41
+ end
42
+
43
+ package "bison" do
44
+ action :install
45
+ end
@@ -0,0 +1,403 @@
1
+ Database Cookbook
2
+ =================
3
+
4
+ The main highlight of this cookbook is the `database` and `database_user` resources for managing databases and database users in a RDBMS. Providers for MySQL, PostgreSQL and SQL Server are also provided, see usage documentation below.
5
+
6
+ This cookbook also contains recipes to configure mysql database masters and slaves and uses EBS for storage, integrating together with the application cookbook utilizing data bags for application related information. These recipes are written primarily to use MySQL and the Opscode mysql cookbook. Other RDBMS may be supported at a later date. This cookbook does not automatically restore database dumps, but does install tools to help with that.
7
+
8
+ Requirements
9
+ ============
10
+
11
+ Chef 0.10.0 or higher required (for Chef environment use).
12
+
13
+ Platform
14
+ --------
15
+
16
+ * Debian, Ubuntu
17
+ * Red Hat, CentOS, Scientific, Fedora
18
+
19
+ Cookbooks
20
+ ---------
21
+
22
+ The following Opscode cookbooks are dependencies:
23
+
24
+ * mysql
25
+ * postgresql
26
+ * xfs
27
+ * aws
28
+
29
+ Resources/Providers
30
+ ===================
31
+
32
+ These resources aim to expose an abstraction layer for interacting with different RDBMS in a general way. Currently the cookbook ships with providers for MySQL, PostgreSQL and SQL Server. Please see specific usage in the __Example__ sections below. The providers use specific Ruby gems to execute commands and carry out actions. These gems will need to be installed before the providers can operate correctly. Specific notes for each RDBS flavor:
33
+
34
+ - MySQL: leverages the `mysql` gem which is installed as part of the `mysql::client` recipe.
35
+ - PostgreSQL: leverages the `pg` gem which is installed as part of the `postgresql::client` recipe.
36
+ - SQL Server: leverages the `tiny_tds` gem which is installed as part of the `sql_server::client` recipe.
37
+
38
+ `database`
39
+ ----------
40
+
41
+ Manage databases in a RDBMS. Use the proper shortcut resource depending on your RDBMS: `mysql_database`, `postgresql_database` or `sql_server_database`.
42
+
43
+ ### Actions
44
+
45
+ - :create: create a named database
46
+ - :drop: drop a named database
47
+ - :query: execute an arbitrary query against a named database
48
+
49
+ ### Attribute Parameters
50
+
51
+ - database_name: name attribute. Name of the database to interact with
52
+ - connection: hash of connection info. valid keys include :host, :port, :username, :password
53
+ - sql: string of sql to execute against the database. used by :query action only
54
+
55
+ ### Providers
56
+
57
+ - **Chef::Provider::Database::Mysql**: shortcut resource `mysql_database`
58
+ - **Chef::Provider::Database::Postgresql**: shortcut resource `postgresql_database`
59
+ - **Chef::Provider::Database::SqlServer**: shortcut resource `sql_server_database`
60
+
61
+ ### Examples
62
+
63
+ # create a mysql database
64
+ mysql_database 'oracle_rules' do
65
+ connection ({:host => "localhost", :username => 'root', :password => node['mysql']['server_root_password']})
66
+ action :create
67
+ end
68
+
69
+ # create a sql server database
70
+ sql_server_database 'mr_softie' do
71
+ connection ({:host => "127.0.0.1", :port => node['sql_server']['port'], :username => 'sa', :password => node['sql_server']['server_sa_password']})
72
+ action :create
73
+ end
74
+
75
+ # create a postgresql database
76
+ postgresql_database 'mr_softie' do
77
+ connection ({:host => "127.0.0.1", :port => 5432, :username => 'postgres', :password => node['postgresql']['password']['postgres']})
78
+ action :create
79
+ end
80
+
81
+ # create a postgresql database with additional parameters
82
+ postgresql_database 'mr_softie' do
83
+ connection ({:host => "127.0.0.1", :port => 5432, :username => 'postgres', :password => node['postgresql']['password']['postgres']})
84
+ template 'DEFAULT'
85
+ encoding 'DEFAULT'
86
+ tablespace 'DEFAULT'
87
+ connection_limit '-1'
88
+ owner 'postgres'
89
+ action :create
90
+ end
91
+
92
+ # externalize conection info in a ruby hash
93
+ mysql_connection_info = {:host => "localhost", :username => 'root', :password => node['mysql']['server_root_password']}
94
+ sql_server_connection_info = {:host => "localhost", :port => node['sql_server']['port'], :username => 'sa', :password => node['sql_server']['server_sa_password']}
95
+ postgresql_connection_info = {:host => "127.0.0.1", :port => 5432, :username => 'postgres', :password => node['postgresql']['password']['postgres']}
96
+
97
+ # same create commands, connection info as an external hash
98
+ mysql_database 'foo' do
99
+ connection mysql_connection_info
100
+ action :create
101
+ end
102
+ sql_server_database 'foo' do
103
+ connection sql_server_connection_info
104
+ action :create
105
+ end
106
+ postgresql_database 'foo' do
107
+ connection postgresql_connection_info
108
+ action :create
109
+ end
110
+
111
+ # create database, set provider in resource parameter
112
+ database 'bar' do
113
+ connection mysql_connection_info
114
+ provider Chef::Provider::Database::Mysql
115
+ action :create
116
+ end
117
+ database 'bar' do
118
+ connection sql_server_connection_info
119
+ provider Chef::Provider::Database::SqlServer
120
+ action :create
121
+ end
122
+ database 'bar' do
123
+ connection postgresql_connection_info
124
+ provider Chef::Provider::Database::Postgresql
125
+ action :create
126
+ end
127
+
128
+ # drop a database
129
+ mysql_database "baz" do
130
+ connection mysql_connection_info
131
+ action :drop
132
+ end
133
+
134
+ # query a database
135
+ mysql_database "flush the privileges" do
136
+ connection mysql_connection_info
137
+ sql "flush privileges"
138
+ action :query
139
+ end
140
+
141
+ # vacuum a postgres database
142
+ postgres_database "vacuum databases" do
143
+ connection postgresql_connection_info
144
+ database_table "template1"
145
+ sql "VACUUM FULL VERBOSE ANALYZE"
146
+ action :query
147
+ end
148
+
149
+ `database_user`
150
+ ---------------
151
+
152
+ Manage users and user privileges in a RDBMS. Use the proper shortcut resource depending on your RDBMS: `mysql_database_user` or `sql_server_database_user`.
153
+
154
+ ### Actions
155
+
156
+ - :create: create a user
157
+ - :drop: drop a user
158
+ - :grant: manipulate user privileges on database objects
159
+
160
+ ### Attribute Parameters
161
+
162
+ - username: name attribute. Name of the database user
163
+ - password: password for the user account
164
+ - database_name: Name of the database to interact with
165
+ - connection: hash of connection info. valid keys include :host, :port, :username, :password
166
+ - privileges: array of database privileges to grant user. used by the :grant action. default is :all
167
+ - host: host where user connections are allowed from. used by MySQL provider only. default is 'localhost'
168
+ - table: table to grant privileges on. used by :grant action and MySQL provider only. default is '*' (all tables)
169
+
170
+ ### Providers
171
+
172
+ - **Chef::Provider::Database::MysqlUser**: shortcut resource `mysql_database_user`
173
+ - **Chef::Provider::Database::SqlServerUser**: shortcut resource `sql_server_database_user`
174
+
175
+ ### Examples
176
+
177
+ # create connection info as an external ruby hash
178
+ mysql_connection_info = {:host => "localhost", :username => 'root', :password => node['mysql']['server_root_password']}
179
+ sql_server_connection_info = {:host => "localhost", :port => node['sql_server']['port'], :username => 'sa', :password => node['sql_server']['server_sa_password']}
180
+
181
+ # create a mysql user but grant no priveleges
182
+ mysql_database_user 'disenfranchised' do
183
+ connection mysql_connection_info
184
+ password 'super_secret'
185
+ action :create
186
+ end
187
+
188
+ # do the same but pass the provider to the database resource
189
+ database_user 'disenfranchised' do
190
+ connection mysql_connection_info
191
+ password 'super_secret'
192
+ provider Chef::Provider::Database::MysqlUser
193
+ action :create
194
+ end
195
+
196
+ # create a sql server user but grant no priveleges
197
+ sql_server_database_user 'disenfranchised' do
198
+ connection sql_server_connection_info
199
+ password 'super_secret'
200
+ action :create
201
+ end
202
+
203
+ # drop a mysql user
204
+ mysql_database_user "foo_user" do
205
+ connection mysql_connection_info
206
+ action :drop
207
+ ends
208
+
209
+ # bulk drop sql server users
210
+ %w{ disenfranchised foo_user }.each do |user|
211
+ sql_server_database_user user do
212
+ connection sql_server_connection_info
213
+ action :drop
214
+ end
215
+ end
216
+
217
+ # grant select,update,insert privileges to all tables in foo db from all hosts
218
+ mysql_database_user 'foo_user' do
219
+ connection mysql_connection_info
220
+ password 'super_secret'
221
+ database_name 'foo'
222
+ host '%'
223
+ privileges [:select,:update,:insert]
224
+ action :grant
225
+ end
226
+
227
+ # grant all privelages on all databases/tables from localhost
228
+ mysql_database_user 'super_user' do
229
+ connection mysql_connection_info
230
+ password 'super_secret'
231
+ action :grant
232
+ end
233
+
234
+ # grant select,update,insert privileges to all tables in foo db
235
+ sql_server_database_user 'foo_user' do
236
+ connection sql_server_connection_info
237
+ password 'super_secret'
238
+ database_name 'foo'
239
+ privileges [:select,:update,:insert]
240
+ action :grant
241
+ end
242
+
243
+ Recipes
244
+ =======
245
+
246
+ ebs\_volume
247
+ -----------
248
+
249
+ Loads the aws information from the data bag. Searches the applications data bag for the database master or slave role and checks that role is applied to the node. Loads the EBS information and the master information from data bags. Uses the aws cookbook LWRP, `aws_ebs_volume` to manage the volume.
250
+
251
+ On a master node:
252
+ * if we have an ebs volume already as stored in a data bag, attach it.
253
+ * if we don't have the ebs information then create a new one and attach it.
254
+ * store the volume information in a data bag via a ruby block.
255
+
256
+ On a slave node:
257
+ * use the master volume information to generate a snapshot.
258
+ * create the new volume from the snapshot and attach it.
259
+
260
+ Also on a master node, generate some configuration for running a snapshot via `chef-solo` from cron.
261
+
262
+ On a new filesystem volume, create as XFS, then mount it in /mnt, and also bind-mount it to the mysql data directory (default /var/lib/mysql).
263
+
264
+ master
265
+ ------
266
+
267
+ This recipe no longer loads AWS specific information, and the database position for replication is no longer stored in a databag because the client might not have permission to write to the databag item. This may be handled in a different way at a future date.
268
+
269
+ Searches the apps databag for applications, and for each one it will check that the specified database master role is set in both the databag and applied to the node's run list. Then, retrieves the passwords for `root`, `repl` and `debian` users and saves them to the node attributes. If the passwords are not found in the databag, it prints a message that they'll be generated by the mysql cookbook.
270
+
271
+ Then it adds the application databag database settings to a hash, to use later.
272
+
273
+ Then it will iterate over the databases and create them with the `mysql_database` resource while adding privileges for application specific database users using the `mysql_database_user` resource.
274
+
275
+ slave
276
+ -----
277
+
278
+ _TODO_: Retrieve the master status from a data bag, then start replication using a ruby block. The replication status needs to be handled in some other way for now since the master recipe above doesn't actually set it in the databag anymore.
279
+
280
+ snapshot
281
+ --------
282
+
283
+ Run via Chef Solo. Retrieves the db snapshot configuration from the specified JSON file. Uses the `mysql_database` resource to lock and unlock tables, and does a filesystem freeze and EBS snapshot.
284
+
285
+ Deprecated Recipes
286
+ ==================
287
+
288
+ The following recipe is considered deprecated. It is kept for reference purposes.
289
+
290
+ ebs\_backup
291
+ -----------
292
+
293
+ Older style of doing mysql snapshot and replication using Adam Jacob's [ec2_mysql](http://github.com/adamhjk/ec2_mysql) script and library.
294
+
295
+ Data Bags
296
+ =========
297
+
298
+ This cookbook uses the apps data bag item for the specified application; see the `application` cookbook's README.md. It also creates data bag items in a bag named 'aws' for storing volume information. In order to interact with EC2, it expects aws to have a main item:
299
+
300
+ {
301
+ "id": "main",
302
+ "ec2_private_key": "private key as a string",
303
+ "ec2_cert": "certificate as a string",
304
+ "aws_account_id": "",
305
+ "aws_secret_access_key": "",
306
+ "aws_access_key_id": ""
307
+ }
308
+
309
+ Note: with the Open Source Chef Server, the server using the database recipes must be an admin client or it will not be able to create data bag items. You can modify whether the client is admin by editing it with knife.
310
+
311
+ knife client edit <client_name>
312
+ {
313
+ ...
314
+ "admin": true
315
+ ...
316
+ }
317
+
318
+ This is not required if the Chef Server is the Opscode Platform, instead use the ACL feature to modify access for the node to be able to update the data bag.
319
+
320
+ Usage
321
+ =====
322
+
323
+ Aside from the application data bag (see the README in the application cookbook), create a role for the database master. Use a role.rb in your chef-repo, or create the role directly with knife.
324
+
325
+ % knife role show my_app_database_master -Fj
326
+ {
327
+ "name": "my_app_database_master",
328
+ "chef_type": "role",
329
+ "json_class": "Chef::Role",
330
+ "default_attributes": {
331
+ },
332
+ "description": "",
333
+ "run_list": [
334
+ "recipe[mysql::server]",
335
+ "recipe[database::master]"
336
+ ],
337
+ "override_attributes": {
338
+ }
339
+ }
340
+
341
+ Create a `production` environment. This is also used in the `application` cookbook.
342
+
343
+ % knife environment show production -Fj
344
+ {
345
+ "name": "production",
346
+ "description": "",
347
+ "cookbook_versions": {
348
+ },
349
+ "json_class": "Chef::Environment",
350
+ "chef_type": "environment",
351
+ "default_attributes": {
352
+ },
353
+ "override_attributes": {
354
+ }
355
+ }
356
+
357
+
358
+ The cookbook `my_app_database` is recommended to set up any application specific database resources such as configuration templates, trending monitors, etc. It is not required, but you would need to create it separately in `site-cookbooks`. Add it to the `my_app_database_master` role.
359
+
360
+ Changes/Roadmap
361
+ ===============
362
+
363
+ ## Future
364
+
365
+ * update `database::master` to work with any RDBMS provider (most likely keying off database adapter)
366
+
367
+ ## v1.1.0
368
+
369
+ * [COOK-716] providers for PostgreSQL
370
+
371
+ ## v1.0.0
372
+
373
+ * [COOK-683] added `database` and `database_user` resources
374
+ * [COOK-684] MySQL providers
375
+ * [COOK-685] SQL Server providers
376
+ * refactored `database::master` and `database::snapshot` recipes to leverage new resources
377
+
378
+ ## v0.99.1
379
+
380
+ * Use Chef 0.10's `node.chef_environment` instead of `node['app_environment']`.
381
+
382
+ License and Author
383
+ ==================
384
+
385
+ Author:: Adam Jacob (<adam@opscode.com>)
386
+ Author:: Joshua Timberman (<joshua@opscode.com>)
387
+ Author:: AJ Christensen (<aj@opscode.com>)
388
+ Author:: Seth Chisamore (<schisamo@opscode.com>)
389
+ Author:: Lamont Granquist (<lamont@opscode.com>)
390
+
391
+ Copyright 2009-2011, Opscode, Inc.
392
+
393
+ Licensed under the Apache License, Version 2.0 (the "License");
394
+ you may not use this file except in compliance with the License.
395
+ You may obtain a copy of the License at
396
+
397
+ http://www.apache.org/licenses/LICENSE-2.0
398
+
399
+ Unless required by applicable law or agreed to in writing, software
400
+ distributed under the License is distributed on an "AS IS" BASIS,
401
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
402
+ See the License for the specific language governing permissions and
403
+ limitations under the License.