server_maint 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (126) hide show
  1. data/.gitmodules +21 -0
  2. data/lib/cookbooks/aws/CHANGELOG.md +11 -0
  3. data/lib/cookbooks/aws/CONTRIBUTING +29 -0
  4. data/lib/cookbooks/aws/LICENSE +201 -0
  5. data/lib/cookbooks/aws/README.md +271 -0
  6. data/lib/cookbooks/aws/attributes/default.rb +20 -0
  7. data/lib/cookbooks/aws/libraries/ec2.rb +58 -0
  8. data/lib/cookbooks/aws/metadata.rb +7 -0
  9. data/lib/cookbooks/aws/providers/ebs_volume.rb +236 -0
  10. data/lib/cookbooks/aws/providers/elastic_ip.rb +90 -0
  11. data/lib/cookbooks/aws/providers/elastic_lb.rb +24 -0
  12. data/lib/cookbooks/aws/providers/resource_tag.rb +93 -0
  13. data/lib/cookbooks/aws/recipes/default.rb +25 -0
  14. data/lib/cookbooks/aws/resources/ebs_volume.rb +17 -0
  15. data/lib/cookbooks/aws/resources/elastic_ip.rb +11 -0
  16. data/lib/cookbooks/aws/resources/elastic_lb.rb +10 -0
  17. data/lib/cookbooks/aws/resources/resource_tag.rb +11 -0
  18. data/lib/cookbooks/database/.gitignore +1 -0
  19. data/lib/cookbooks/database/CHANGELOG.md +51 -0
  20. data/lib/cookbooks/database/CONTRIBUTING +29 -0
  21. data/lib/cookbooks/database/LICENSE +201 -0
  22. data/lib/cookbooks/database/README.md +468 -0
  23. data/lib/cookbooks/database/libraries/provider_database_mysql.rb +103 -0
  24. data/lib/cookbooks/database/libraries/provider_database_mysql_user.rb +76 -0
  25. data/lib/cookbooks/database/libraries/provider_database_postgresql.rb +131 -0
  26. data/lib/cookbooks/database/libraries/provider_database_postgresql_user.rb +83 -0
  27. data/lib/cookbooks/database/libraries/provider_database_sql_server.rb +109 -0
  28. data/lib/cookbooks/database/libraries/provider_database_sql_server_user.rb +106 -0
  29. data/lib/cookbooks/database/libraries/resource_database.rb +119 -0
  30. data/lib/cookbooks/database/libraries/resource_database_user.rb +90 -0
  31. data/lib/cookbooks/database/libraries/resource_mysql_database.rb +34 -0
  32. data/lib/cookbooks/database/libraries/resource_mysql_database_user.rb +34 -0
  33. data/lib/cookbooks/database/libraries/resource_postgresql_database.rb +35 -0
  34. data/lib/cookbooks/database/libraries/resource_postgresql_database_user.rb +35 -0
  35. data/lib/cookbooks/database/libraries/resource_sql_server_database.rb +34 -0
  36. data/lib/cookbooks/database/libraries/resource_sql_server_database_user.rb +34 -0
  37. data/lib/cookbooks/database/metadata.rb +22 -0
  38. data/lib/cookbooks/database/recipes/default.rb +20 -0
  39. data/lib/cookbooks/database/recipes/ebs_backup.rb +89 -0
  40. data/lib/cookbooks/database/recipes/ebs_volume.rb +204 -0
  41. data/lib/cookbooks/database/recipes/master.rb +78 -0
  42. data/lib/cookbooks/database/recipes/mysql.rb +20 -0
  43. data/lib/cookbooks/database/recipes/postgresql.rb +20 -0
  44. data/lib/cookbooks/database/recipes/snapshot.rb +62 -0
  45. data/lib/cookbooks/database/templates/default/app_grants.sql.erb +8 -0
  46. data/lib/cookbooks/database/templates/default/aws_config.erb +3 -0
  47. data/lib/cookbooks/database/templates/default/chef-solo-database-snapshot.cron.erb +6 -0
  48. data/lib/cookbooks/database/templates/default/chef-solo-database-snapshot.json.erb +1 -0
  49. data/lib/cookbooks/database/templates/default/chef-solo-database-snapshot.rb.erb +6 -0
  50. data/lib/cookbooks/database/templates/default/ebs-backup-cron.erb +2 -0
  51. data/lib/cookbooks/database/templates/default/ebs-db-backup.sh.erb +8 -0
  52. data/lib/cookbooks/database/templates/default/ebs-db-restore.sh.erb +10 -0
  53. data/lib/cookbooks/database/templates/default/s3cfg.erb +27 -0
  54. data/lib/cookbooks/mysql/.gitignore +5 -0
  55. data/lib/cookbooks/mysql/CHANGELOG.md +86 -0
  56. data/lib/cookbooks/mysql/CONTRIBUTING +29 -0
  57. data/lib/cookbooks/mysql/Gemfile +8 -0
  58. data/lib/cookbooks/mysql/LICENSE +201 -0
  59. data/lib/cookbooks/mysql/README.md +227 -0
  60. data/lib/cookbooks/mysql/attributes/client.rb +50 -0
  61. data/lib/cookbooks/mysql/attributes/server.rb +153 -0
  62. data/lib/cookbooks/mysql/files/default/tests/minitest/server_test.rb +36 -0
  63. data/lib/cookbooks/mysql/files/default/tests/minitest/support/helpers.rb +11 -0
  64. data/lib/cookbooks/mysql/libraries/helpers.rb +33 -0
  65. data/lib/cookbooks/mysql/metadata.rb +140 -0
  66. data/lib/cookbooks/mysql/recipes/client.rb +59 -0
  67. data/lib/cookbooks/mysql/recipes/default.rb +20 -0
  68. data/lib/cookbooks/mysql/recipes/ruby.rb +36 -0
  69. data/lib/cookbooks/mysql/recipes/server.rb +216 -0
  70. data/lib/cookbooks/mysql/recipes/server_ec2.rb +51 -0
  71. data/lib/cookbooks/mysql/templates/default/debian.cnf.erb +12 -0
  72. data/lib/cookbooks/mysql/templates/default/grants.sql.erb +15 -0
  73. data/lib/cookbooks/mysql/templates/default/my.cnf.erb +211 -0
  74. data/lib/cookbooks/mysql/templates/default/mysql-server.seed.erb +10 -0
  75. data/lib/cookbooks/mysql/templates/default/port_mysql.erb +3 -0
  76. data/lib/cookbooks/mysql/templates/windows/my.cnf.erb +61 -0
  77. data/lib/cookbooks/mysql/test/features/query_database.feature +26 -0
  78. data/lib/cookbooks/mysql/test/features/step_definitions/mysql_steps.rb +47 -0
  79. data/lib/cookbooks/mysql/test/features/support/env.rb +3 -0
  80. data/lib/cookbooks/mysql/test/features/support/mysql_helpers.rb +51 -0
  81. data/lib/cookbooks/mysql/test/kitchen/Kitchenfile +5 -0
  82. data/lib/cookbooks/mysql/test/kitchen/cookbooks/mysql_test/.gitignore +1 -0
  83. data/lib/cookbooks/mysql/test/kitchen/cookbooks/mysql_test/README.md +63 -0
  84. data/lib/cookbooks/mysql/test/kitchen/cookbooks/mysql_test/attributes/default.rb +27 -0
  85. data/lib/cookbooks/mysql/test/kitchen/cookbooks/mysql_test/metadata.rb +10 -0
  86. data/lib/cookbooks/mysql/test/kitchen/cookbooks/mysql_test/recipes/client.rb +20 -0
  87. data/lib/cookbooks/mysql/test/kitchen/cookbooks/mysql_test/recipes/server.rb +72 -0
  88. data/lib/cookbooks/openssl/CHANGELOG.md +0 -0
  89. data/lib/cookbooks/openssl/CONTRIBUTING +29 -0
  90. data/lib/cookbooks/openssl/LICENSE +201 -0
  91. data/lib/cookbooks/openssl/README.md +37 -0
  92. data/lib/cookbooks/openssl/libraries/secure_password.rb +37 -0
  93. data/lib/cookbooks/openssl/metadata.rb +8 -0
  94. data/lib/cookbooks/openssl/recipes/default.rb +19 -0
  95. data/lib/cookbooks/postgresql/CHANGELOG.md +35 -0
  96. data/lib/cookbooks/postgresql/CONTRIBUTING +29 -0
  97. data/lib/cookbooks/postgresql/LICENSE +201 -0
  98. data/lib/cookbooks/postgresql/README.md +148 -0
  99. data/lib/cookbooks/postgresql/attributes/default.rb +103 -0
  100. data/lib/cookbooks/postgresql/metadata.rb +21 -0
  101. data/lib/cookbooks/postgresql/recipes/client.rb +26 -0
  102. data/lib/cookbooks/postgresql/recipes/default.rb +20 -0
  103. data/lib/cookbooks/postgresql/recipes/ruby.rb +40 -0
  104. data/lib/cookbooks/postgresql/recipes/server.rb +64 -0
  105. data/lib/cookbooks/postgresql/recipes/server_debian.rb +64 -0
  106. data/lib/cookbooks/postgresql/recipes/server_redhat.rb +77 -0
  107. data/lib/cookbooks/postgresql/templates/default/debian.postgresql.conf.erb +499 -0
  108. data/lib/cookbooks/postgresql/templates/default/pg_hba.conf.erb +83 -0
  109. data/lib/cookbooks/postgresql/templates/default/redhat.postgresql.conf.erb +501 -0
  110. data/lib/cookbooks/sqlite/.gitignore +4 -0
  111. data/lib/cookbooks/sqlite/CHANGELOG.md +3 -0
  112. data/lib/cookbooks/sqlite/CONTRIBUTING +29 -0
  113. data/lib/cookbooks/sqlite/Gemfile +2 -0
  114. data/lib/cookbooks/sqlite/LICENSE +201 -0
  115. data/lib/cookbooks/sqlite/README.md +36 -0
  116. data/lib/cookbooks/sqlite/metadata.rb +12 -0
  117. data/lib/cookbooks/sqlite/recipes/default.rb +30 -0
  118. data/lib/cookbooks/sqlite/test/kitchen/Kitchenfile +1 -0
  119. data/lib/cookbooks/xfs/CHANGELOG.md +0 -0
  120. data/lib/cookbooks/xfs/CONTRIBUTING +29 -0
  121. data/lib/cookbooks/xfs/LICENSE +201 -0
  122. data/lib/cookbooks/xfs/README.md +30 -0
  123. data/lib/cookbooks/xfs/metadata.rb +12 -0
  124. data/lib/cookbooks/xfs/recipes/default.rb +26 -0
  125. data/lib/server_maint/version.rb +1 -1
  126. metadata +127 -4
@@ -0,0 +1,211 @@
1
+ #
2
+ # Generated by Chef for <%= node['hostname'] %>
3
+ #
4
+ # Local modifications will be overwritten.
5
+ #
6
+ # The MySQL database server configuration file.
7
+ #
8
+ # You can copy this to one of:
9
+ # - "/etc/mysql/my.cnf" to set global options,
10
+ # - "~/.my.cnf" to set user-specific options.
11
+ #
12
+ # One can use all long options that the program supports.
13
+ # Run program with --help to get a list of available options and with
14
+ # --print-defaults to see which it would actually understand and use.
15
+ #
16
+ # For explanations see
17
+ # http://dev.mysql.com/doc/mysql/en/server-system-variables.html
18
+
19
+ # This will be passed to all mysql clients
20
+ # It has been reported that passwords should be enclosed with ticks/quotes
21
+ # escpecially if they contain "#" chars...
22
+ # Remember to edit /etc/mysql/debian.cnf when changing the socket location.
23
+ [client]
24
+ port = <%= node['mysql']['port'] %>
25
+ socket = <%= node['mysql']['socket'] %>
26
+
27
+ # Here is entries for some specific programs
28
+ # The following values assume you have at least 32M ram
29
+
30
+ # This was formally known as [safe_mysqld]. Both versions are currently parsed.
31
+ [mysqld_safe]
32
+ socket = <%= node['mysql']['socket'] %>
33
+ nice = 0
34
+
35
+ [mysqld]
36
+ #
37
+ # * Basic Settings
38
+ #
39
+
40
+ #
41
+ # * IMPORTANT
42
+ # If you make changes to these settings and your system uses apparmor, you may
43
+ # also need to also adjust /etc/apparmor.d/usr.sbin.mysqld.
44
+ #
45
+
46
+ user = mysql
47
+ pid-file = <%= node['mysql']['pid_file'] %>
48
+ socket = <%= node['mysql']['socket'] %>
49
+ port = <%= node['mysql']['port'] %>
50
+ basedir = <%= node['mysql']['basedir'] %>
51
+ datadir = <%= node['mysql']['data_dir'] %>
52
+ tmpdir = /tmp
53
+ skip-external-locking
54
+ #
55
+ # Instead of skip-networking the default is now to listen only on
56
+ # localhost which is more compatible and is not less secure.
57
+ bind-address = <%= node['mysql']['bind_address'] %>
58
+ #
59
+ # * Fine Tuning
60
+ #
61
+ key_buffer = <%= node['mysql']['tunable']['key_buffer'] %>
62
+ max_allowed_packet = <%= node['mysql']['tunable']['max_allowed_packet'] %>
63
+ thread_stack = <%= node['mysql']['tunable']['thread_stack'] %>
64
+ thread_cache_size = <%= node['mysql']['tunable']['thread_cache_size'] %>
65
+
66
+ auto-increment-increment = <%= node['mysql']['auto-increment-increment'] %>
67
+ auto-increment-offset = <%= node['mysql']['auto-increment-offset'] %>
68
+
69
+ # This replaces the startup script and checks MyISAM tables if needed
70
+ # the first time they are touched
71
+ myisam-recover = BACKUP
72
+ #max_connections = 100
73
+ #table_cache = 64
74
+ #thread_concurrency = 10
75
+ max_connections = <%= node['mysql']['tunable']['max_connections'] %>
76
+ wait_timeout = <%= node['mysql']['tunable']['wait_timeout'] %>
77
+ net_read_timeout = <%= node['mysql']['tunable']['net_read_timeout'] %>
78
+ net_write_timeout = <%= node['mysql']['tunable']['net_write_timeout'] %>
79
+ back_log = <%= node['mysql']['tunable']['back_log'] %>
80
+ table_cache = <%= node['mysql']['tunable']['table_cache'] %>
81
+ max_heap_table_size = <%= node['mysql']['tunable']['max_heap_table_size'] %>
82
+
83
+ #
84
+ # * Query Cache Configuration
85
+ #
86
+ query_cache_limit = <%= node['mysql']['tunable']['query_cache_limit'] %>
87
+ query_cache_size = <%= node['mysql']['tunable']['query_cache_size'] %>
88
+ #
89
+ # * Logging and Replication
90
+ #
91
+ # Both location gets rotated by the cronjob.
92
+ # Be aware that this log type is a performance killer.
93
+ #log = /var/log/mysql/mysql.log
94
+ #
95
+ # Error logging goes to syslog. This is a Debian improvement :)
96
+ <%- if node['mysql']['tunable']['log_error'] %>
97
+ log-error = <%= node['mysql']['tunable']['log_error'] %>
98
+ <%- end %>
99
+ #
100
+ # Here you can see queries with especially long duration
101
+ log_slow_queries = <%= node['mysql']['tunable']['log_slow_queries'] %>
102
+ long_query_time = <%= node['mysql']['tunable']['long_query_time'] %>
103
+ <%- if node['mysql']['tunable']['log_queries_not_using_index'] %>
104
+ log-queries-not-using-indexes
105
+ <%- end %>
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
+ #server-id = 1
111
+ <%- if node['mysql']['tunable']['log_bin'] %>
112
+ log_bin = <%= node['mysql']['tunable']['log_bin'] %>
113
+ log_slave_updates = <%= node['mysql']['tunable']['log_slave_updates'] %>
114
+ <%- end %>
115
+ <%- if node['mysql']['tunable']['log_bin_trust_function_creators'] %>
116
+ log_bin_trust_function_creators
117
+ <%- end %>
118
+ expire_logs_days = <%= node['mysql']['tunable']['expire_logs_days'] %>
119
+ max_binlog_size = <%= node['mysql']['tunable']['max_binlog_size'] %>
120
+ #binlog_do_db = include_database_name
121
+ #binlog_ignore_db = include_database_name
122
+ <%- if node['mysql']['tunable']['relay_log'] %>
123
+ relay-log = <%= node['mysql']['tunable']['relay_log'] %>
124
+ <%- end %>
125
+ sync_binlog = <%= node['mysql']['tunable']['sync_binlog'] %>
126
+ <%- if node['mysql']['tunable']['skip_slave_start'] %>
127
+ skip_slave_start
128
+ <%- end %>
129
+
130
+ #
131
+ # * InnoDB
132
+ #
133
+ # InnoDB is enabled by default with a 10MB datafile in /var/lib/mysql/.
134
+ # Read the manual for more InnoDB related options. There are many!
135
+ # You might want to disable InnoDB to shrink the mysqld process by circa 100MB.
136
+ #skip-innodb
137
+ innodb_buffer_pool_size = <%= node['mysql']['tunable']['innodb_buffer_pool_size'] %>
138
+ innodb_log_file_size = <%= node['mysql']['tunable']['innodb_log_file_size'] %>
139
+ innodb_additional_mem_pool_size = <%= node['mysql']['tunable']['innodb_additional_mem_pool_size'] %>
140
+ innodb_data_file_path = <%= node['mysql']['tunable']['innodb_data_file_path'] %>
141
+ innodb_file_per_table
142
+ innodb_flush_log_at_trx_commit = <%= node['mysql']['tunable']['innodb_flush_log_at_trx_commit'] %>
143
+ <%- if node['mysql']['tunable']['innodb_flush_method'] %>
144
+ innodb_flush_method = <%= node['mysql']['tunable']['innodb_flush_method'] %>
145
+ <%- end %>
146
+ innodb_log_buffer_size = <%= node['mysql']['tunable']['innodb_log_buffer_size'] %>
147
+ <%- if node['mysql']['tunable']['innodb_adaptive_flushing'] %>
148
+ innodb_adaptive_flushing = <%= node['mysql']['tunable']['innodb_adaptive_flushing'] %>
149
+ <%- end %>
150
+
151
+ <% if @skip_federated %>
152
+ #
153
+ # * Federated
154
+ #
155
+ # The FEDERATED storage engine is disabled since 5.0.67 by default in the .cnf files
156
+ # shipped with MySQL distributions (my-huge.cnf, my-medium.cnf, and so forth).
157
+ #
158
+ skip-federated
159
+ <% end %>
160
+ #
161
+ # * Security Features
162
+ #
163
+ # Read the manual, too, if you want chroot!
164
+ # chroot = /var/lib/mysql/
165
+ #
166
+ # For generating SSL certificates I recommend the OpenSSL GUI "tinyca".
167
+ #
168
+ # ssl-ca=/etc/mysql/cacert.pem
169
+ # ssl-cert=/etc/mysql/server-cert.pem
170
+ # ssl-key=/etc/mysql/server-key.pem
171
+
172
+ [mysqldump]
173
+ quick
174
+ quote-names
175
+ max_allowed_packet = <%= node['mysql']['tunable']['max_allowed_packet'] %>
176
+
177
+ [mysql]
178
+ #no-auto-rehash # faster start of mysql but no tab completition
179
+
180
+ [isamchk]
181
+ key_buffer = <%= node['mysql']['tunable']['max_allowed_packet'] %>
182
+
183
+ #
184
+ # * NDB Cluster
185
+ #
186
+ # See /usr/share/doc/mysql-server-*/README.Debian for more information.
187
+ #
188
+ # The following configuration is read by the NDB Data Nodes (ndbd processes)
189
+ # not from the NDB Management Nodes (ndb_mgmd processes).
190
+ #
191
+ # [MYSQL_CLUSTER]
192
+ # ndb-connectstring=127.0.0.1
193
+
194
+ <% case node['platform'] -%>
195
+ <% when "centos", "redhat", "fedora", "suse", "scientific", "amazon"-%>
196
+ #
197
+ # * BerkeleyDB
198
+ #
199
+ # Using BerkeleyDB is now discouraged as its support will cease in 5.1.12.
200
+ skip-bdb
201
+ # Default to using old password format for compatibility with mysql 3.x
202
+ # clients (those using the mysqlclient10 compatibility package).
203
+ old_passwords = <%= node['mysql']['old_passwords'] %>
204
+
205
+ <% else -%>
206
+ #
207
+ # * IMPORTANT: Additional settings that can override those from this file!
208
+ # The files must end with '.cnf', otherwise they'll be ignored.
209
+ #
210
+ !includedir <%= node['mysql']['confd_dir'] %>/
211
+ <% end -%>
@@ -0,0 +1,10 @@
1
+ mysql-server-5.0 mysql-server/root_password_again select <%= node['mysql']['server_root_password'] %>
2
+ mysql-server-5.0 mysql-server/root_password select <%= node['mysql']['server_root_password'] %>
3
+ mysql-server-5.0 mysql-server-5.0/really_downgrade boolean false
4
+ mysql-server-5.0 mysql-server-5.0/need_sarge_compat boolean false
5
+ mysql-server-5.0 mysql-server-5.0/start_on_boot boolean true
6
+ mysql-server-5.0 mysql-server/error_setting_password boolean false
7
+ mysql-server-5.0 mysql-server-5.0/nis_warning note
8
+ mysql-server-5.0 mysql-server-5.0/postrm_remove_databases boolean false
9
+ mysql-server-5.0 mysql-server/password_mismatch boolean false
10
+ mysql-server-5.0 mysql-server-5.0/need_sarge_compat_done boolean true
@@ -0,0 +1,3 @@
1
+ # MySQL
2
+ -A FWR -p tcp -m tcp --dport 3306 -j ACCEPT
3
+ -A FWR -p udp -m udp --dport 3306 -j ACCEPT
@@ -0,0 +1,61 @@
1
+ #
2
+ # Generated by Chef for <%= node['hostname'] %>
3
+ #
4
+ # Local modifications will be overwritten.
5
+ #
6
+ # The MySQL database server configuration file.
7
+ #
8
+ # One can use all long options that the program supports.
9
+ # Run program with --help to get a list of available options and with
10
+ # --print-defaults to see which it would actually understand and use.
11
+ #
12
+ # For explanations see
13
+ # http://dev.mysql.com/doc/mysql/en/server-system-variables.html
14
+
15
+ # This will be passed to all mysql clients
16
+ # It has been reported that passwords should be enclosed with ticks/quotes
17
+ # escpecially if they contain "#" chars...
18
+ [client]
19
+ port = 3306
20
+
21
+ [mysql]
22
+ default-character-set = latin1
23
+
24
+ [mysqld]
25
+ #
26
+ # * Basic Settings
27
+ #
28
+ port = 3306
29
+ basedir = <%= node['mysql']['basedir'] %>
30
+ datadir = <%= node['mysql']['data_dir'] %>
31
+ character-set-server = latin1
32
+ default-storage-engine = INNODB
33
+ sql-mode = "STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
34
+
35
+ #
36
+ # * Fine Tuning
37
+ #
38
+ thread_cache_size = <%= node['mysql']['tunable']['thread_cache_size'] %>
39
+ max_connections = <%= node['mysql']['tunable']['max_connections'] %>
40
+ table_cache = <%= node['mysql']['tunable']['table_cache'] %>
41
+ query_cache_size = <%= node['mysql']['tunable']['query_cache_size'] %>
42
+ tmp_table_size = 5M
43
+ myisam_max_sort_file_size = 100G
44
+ myisam_sort_buffer_size = 8M
45
+ key_buffer_size = 8M
46
+ read_buffer_size = 64K
47
+ read_rnd_buffer_size = 256K
48
+ sort_buffer_size = 212K
49
+
50
+ #
51
+ # * InnoDB
52
+ #
53
+ # Read the manual for more InnoDB related options. There are many!
54
+ # You might want to disable InnoDB to shrink the mysqld process by circa 100MB.
55
+ #
56
+ innodb_additional_mem_pool_size = 2M
57
+ innodb_flush_log_at_trx_commit = 1
58
+ innodb_log_buffer_size = 1M
59
+ innodb_buffer_pool_size = <%= node['mysql']['tunable']['innodb_buffer_pool_size'] %>
60
+ innodb_log_file_size = 10M
61
+ innodb_thread_concurrency = 8
@@ -0,0 +1,26 @@
1
+ @server
2
+ Feature: Query database
3
+
4
+ In order to persist and retrieve my application data
5
+ As a developer
6
+ I want to be able to query the database
7
+
8
+ Scenario: Query database
9
+ Given a new database server with some example data
10
+ When I query the database
11
+ Then the expected data should be returned
12
+
13
+ Scenario: Update a row
14
+ Given a new database server with some example data
15
+ When I update a row in a database table
16
+ Then the updated data should be returned for subsequent queries
17
+
18
+ Scenario: Insert a row
19
+ Given a new database server with some example data
20
+ When I insert a new row into a database table
21
+ Then the inserted data should be returned for subsequent queries
22
+
23
+ Scenario: Delete a row
24
+ Given a new database server with some example data
25
+ When I delete a row from a database table
26
+ Then the deleted data should not be returned for subsequent queries
@@ -0,0 +1,47 @@
1
+ Given 'a new database server with some example data' do
2
+
3
+ end
4
+
5
+ When 'I delete a row from a database table' do
6
+ delete_chef 'Alison Holst'
7
+ end
8
+
9
+ When 'I query the database' do
10
+ select_tv_chefs
11
+ end
12
+
13
+ When 'I insert a new row into a database table' do
14
+ insert_chef 'Ainsley Harriott'
15
+ end
16
+
17
+ When 'I update a row in a database table' do
18
+ update_chef_name('Paula Deen', 'Paula Hiers Deen')
19
+ end
20
+
21
+ Then 'the expected data should be returned' do
22
+ tv_chefs.must_equal(['Alison Holst', 'Nigella Lawson', 'Paula Deen'])
23
+ end
24
+
25
+ Then 'the inserted data should be returned for subsequent queries' do
26
+ begin
27
+ select_tv_chefs.must_include 'Ainsley Harriott'
28
+ ensure
29
+ delete_chef 'Ainsley Harriott'
30
+ end
31
+ end
32
+
33
+ Then 'the deleted data should not be returned for subsequent queries' do
34
+ begin
35
+ select_tv_chefs.must_equal(['Nigella Lawson', 'Paula Deen'])
36
+ ensure
37
+ insert_chef 'Alison Holst'
38
+ end
39
+ end
40
+
41
+ Then 'the updated data should be returned for subsequent queries' do
42
+ begin
43
+ select_tv_chefs.must_equal(['Alison Holst', 'Nigella Lawson', 'Paula Hiers Deen'])
44
+ ensure
45
+ update_chef_name('Paula Hiers Deen', 'Paula Deen')
46
+ end
47
+ end
@@ -0,0 +1,3 @@
1
+ require 'minitest/spec'
2
+ World(MiniTest::Assertions)
3
+ MiniTest::Spec.new(nil)
@@ -0,0 +1,51 @@
1
+ def query(sql)
2
+ cmd_prefix = test_client_host ? "ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no root@#{test_client_host}" : ''
3
+ result = %x{echo "#{sql}" | #{cmd_prefix} mysql --host=#{test_server_host} --user=#{test_user} --password=#{test_password} --skip-column-names #{test_database}}
4
+ assert $?.success?
5
+ result
6
+ end
7
+ alias :insert :query
8
+ alias :update :query
9
+ alias :delete :query
10
+
11
+ def delete_chef(name)
12
+ delete("DELETE FROM tv_chef WHERE name = '#{name}'")
13
+ end
14
+
15
+ def insert_chef(name)
16
+ insert("INSERT INTO tv_chef (name) VALUES('#{name}')")
17
+ end
18
+
19
+ def select_tv_chefs
20
+ @tv_chefs = query('SELECT name FROM tv_chef ORDER BY name').split("\n")
21
+ @tv_chefs
22
+ end
23
+
24
+ def test_client_host
25
+ ENV['TEST_CLIENT_HOST']
26
+ end
27
+
28
+ def test_database
29
+ 'mysql_test'
30
+ end
31
+
32
+ def test_server_host
33
+ ENV['TEST_SERVER_HOST'] || 'localhost'
34
+ end
35
+
36
+ def test_password
37
+ 'neshFiapog'
38
+ end
39
+
40
+ def test_user
41
+ 'test_user'
42
+ end
43
+
44
+ def tv_chefs
45
+ @tv_chefs
46
+ end
47
+
48
+ def update_chef_name(old_name, new_name)
49
+ update("UPDATE tv_chef SET name = '#{new_name}' WHERE name = '#{old_name}'")
50
+ end
51
+
@@ -0,0 +1,5 @@
1
+ cookbook "mysql" do
2
+ configuration "client"
3
+ configuration "ruby"
4
+ configuration "server"
5
+ end
@@ -0,0 +1,63 @@
1
+ Description
2
+ ===========
3
+
4
+ This cookbook defines acceptance tests for MySQL. It includes:
5
+
6
+ * A `features` sub-directory where the Cucumber features for the database
7
+ are defined.
8
+
9
+ * Creation of a simple test database for the tests to run against.
10
+
11
+ Usage
12
+ =====
13
+
14
+ Set environment variable `TEST_SERVER_HOST` to specify the MySQL server to
15
+ connect to. You can optionally set `TEST_CLIENT_HOST` which will test a client
16
+ install by running the same features from a remote client.
17
+
18
+ Requirements
19
+ ============
20
+
21
+ ## Cookbooks:
22
+
23
+ This cookbook depends on the `mysql` cookbook. It also uses the `database`
24
+ cookbook to create the test database and relies on the `yum` cookbook in order
25
+ to add the EPEL repository on RHEL-derived distributions.
26
+
27
+ ## Platforms:
28
+
29
+ * Ubuntu
30
+ * CentOS
31
+
32
+ Attributes
33
+ ==========
34
+
35
+ * `node['mysql_test']['database']` - The name of the test database to create.
36
+ * `node['mysql_test']['username']` - The username of the datbase user.
37
+ * `node['mysql_test']['password']` - The password of the database user.
38
+
39
+ Recipes
40
+ =======
41
+
42
+ * `client` - Simply includes `mysql::client` for a vanilla mysql client install.
43
+ * `server` - Includes `mysql::server` to install the server and configures a
44
+ test database.
45
+
46
+ License and Authors
47
+ ===================
48
+
49
+ Author:: Andrew Crump <andrew@kotirisoftware.com>
50
+
51
+ Copyright:: 2012, Opscode, Inc
52
+
53
+ Licensed under the Apache License, Version 2.0 (the "License");
54
+ you may not use this file except in compliance with the License.
55
+ You may obtain a copy of the License at
56
+
57
+ http://www.apache.org/licenses/LICENSE-2.0
58
+
59
+ Unless required by applicable law or agreed to in writing, software
60
+ distributed under the License is distributed on an "AS IS" BASIS,
61
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
62
+ See the License for the specific language governing permissions and
63
+ limitations under the License.
@@ -0,0 +1,27 @@
1
+ #
2
+ # Cookbook Name:: mysql_test
3
+ # Attributes:: default
4
+ #
5
+ # Copyright 2012, Opscode, Inc.
6
+ #
7
+ # Licensed under the Apache License, Version 2.0 (the "License");
8
+ # you may not use this file except in compliance with the License.
9
+ # You may obtain a copy of the License at
10
+ #
11
+ # http://www.apache.org/licenses/LICENSE-2.0
12
+ #
13
+ # Unless required by applicable law or agreed to in writing, software
14
+ # distributed under the License is distributed on an "AS IS" BASIS,
15
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ # See the License for the specific language governing permissions and
17
+ # limitations under the License.
18
+ #
19
+
20
+ # Must be specified for chef-solo for successful re-converge
21
+ override['mysql']['server_root_password'] = 'ebrilvOpCethHienRoj7'
22
+
23
+ default['mysql_test']['database'] = 'mysql_test'
24
+ default['mysql_test']['username'] = 'test_user'
25
+ default['mysql_test']['password'] = 'neshFiapog'
26
+
27
+ override['mysql']['bind_address'] = 'localhost'
@@ -0,0 +1,10 @@
1
+ maintainer "Andrew Crump"
2
+ maintainer_email "andrew@kotirisoftware.com"
3
+ license "Apache 2.0"
4
+ description "Acceptance tests for mysql"
5
+ long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
6
+ version "0.1.0"
7
+
8
+ depends "database"
9
+ depends "mysql"
10
+ depends "yum"
@@ -0,0 +1,20 @@
1
+ #
2
+ # Cookbook Name:: mysql_test
3
+ # Recipe:: client
4
+ #
5
+ # Copyright 2012, Opscode, Inc.
6
+ #
7
+ # Licensed under the Apache License, Version 2.0 (the "License");
8
+ # you may not use this file except in compliance with the License.
9
+ # You may obtain a copy of the License at
10
+ #
11
+ # http://www.apache.org/licenses/LICENSE-2.0
12
+ #
13
+ # Unless required by applicable law or agreed to in writing, software
14
+ # distributed under the License is distributed on an "AS IS" BASIS,
15
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ # See the License for the specific language governing permissions and
17
+ # limitations under the License.
18
+ #
19
+
20
+ include_recipe "yum::epel" if platform?('centos')
@@ -0,0 +1,72 @@
1
+ #
2
+ # Cookbook Name:: mysql_test
3
+ # Recipe:: server
4
+ #
5
+ # Copyright 2012, Opscode, Inc.
6
+ #
7
+ # Licensed under the Apache License, Version 2.0 (the "License");
8
+ # you may not use this file except in compliance with the License.
9
+ # You may obtain a copy of the License at
10
+ #
11
+ # http://www.apache.org/licenses/LICENSE-2.0
12
+ #
13
+ # Unless required by applicable law or agreed to in writing, software
14
+ # distributed under the License is distributed on an "AS IS" BASIS,
15
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ # See the License for the specific language governing permissions and
17
+ # limitations under the License.
18
+ #
19
+
20
+ case node.platform
21
+ when 'ubuntu'
22
+ %w{mysql-client libmysqlclient-dev}
23
+ when 'centos'
24
+ %w{mysql mysql-devel}
25
+ end.each do |pkg|
26
+ package pkg do
27
+ action :nothing
28
+ end.run_action(:install)
29
+ end
30
+
31
+ gem_package "mysql" do
32
+ action :nothing
33
+ end.run_action(:install)
34
+
35
+ include_recipe "yum::epel" if platform?('centos')
36
+
37
+ file "/etc/sysconfig/network" do
38
+ content "NETWORKING=yes"
39
+ action :create_if_missing
40
+ only_if { platform?('amazon', 'centos', 'fedora', 'redhat', 'scientific') }
41
+ end
42
+
43
+ include_recipe 'mysql::server'
44
+
45
+ mysql_connection = {:host => "localhost", :username => 'root',
46
+ :password => node['mysql']['server_root_password']}
47
+
48
+ mysql_database node['mysql_test']['database'] do
49
+ connection mysql_connection
50
+ action :create
51
+ end
52
+
53
+ mysql_database_user node['mysql_test']['username'] do
54
+ connection mysql_connection
55
+ password node['mysql_test']['password']
56
+ database_name node['mysql_test']['database']
57
+ host 'localhost'
58
+ privileges [:select,:update,:insert, :delete]
59
+ action [:create, :grant]
60
+ end
61
+
62
+ mysql_conn_args = "--user=root --password=#{node['mysql']['server_root_password']}"
63
+
64
+ execute 'create-sample-data' do
65
+ command %Q{mysql #{mysql_conn_args} #{node['mysql_test']['database']} <<EOF
66
+ CREATE TABLE tv_chef (name VARCHAR(32) PRIMARY KEY);
67
+ INSERT INTO tv_chef (name) VALUES ('Alison Holst');
68
+ INSERT INTO tv_chef (name) VALUES ('Nigella Lawson');
69
+ INSERT INTO tv_chef (name) VALUES ('Paula Deen');
70
+ EOF}
71
+ not_if "echo 'SELECT count(name) FROM tv_chef' | mysql #{mysql_conn_args} --skip-column-names #{node['mysql_test']['database']} | grep '^3$'"
72
+ end
File without changes
@@ -0,0 +1,29 @@
1
+ If you would like to contribute, please open a ticket in JIRA:
2
+
3
+ * http://tickets.opscode.com
4
+
5
+ Create the ticket in the COOK project and use the cookbook name as the
6
+ component.
7
+
8
+ For all code contributions, we ask that contributors sign a
9
+ contributor license agreement (CLA). Instructions may be found here:
10
+
11
+ * http://wiki.opscode.com/display/chef/How+to+Contribute
12
+
13
+ When contributing changes to individual cookbooks, please do not
14
+ modify the version number in the metadata.rb. Also please do not
15
+ update the CHANGELOG.md for a new version. Not all changes to a
16
+ cookbook may be merged and released in the same versions. Opscode will
17
+ handle the version updates during the release process. You are welcome
18
+ to correct typos or otherwise make updates to documentation in the
19
+ README.
20
+
21
+ If a contribution adds new platforms or platform versions, indicate
22
+ such in the body of the commit message(s), and update the relevant
23
+ COOK ticket. When writing commit messages, it is helpful for others if
24
+ you indicate the COOK ticket. For example:
25
+
26
+ git commit -m '[COOK-1041] Updated pool resource to correctly delete.'
27
+
28
+ In the ticket itself, it is also helpful if you include log output of
29
+ a successful Chef run, but this is not absolutely required.