mysql cookbook added
This commit is contained in:
parent
3837ddcf09
commit
39cc1417c1
53
cookbooks/mysql/CHANGELOG.md
Normal file
53
cookbooks/mysql/CHANGELOG.md
Normal file
@ -0,0 +1,53 @@
|
||||
## v1.2.6:
|
||||
|
||||
* [COOK-1113] - Use an attribute to determine if upstart is used
|
||||
* [COOK-1121] - Add support for Windows
|
||||
* [COOK-1140] - Fix conf.d on Debian
|
||||
* [COOK-1151] - Fix server_ec2 handling /var/lib/mysql bind mount
|
||||
* [COOK-1321] - Document setting password attributes for solo
|
||||
|
||||
## v1.2.4
|
||||
|
||||
* [COOK-992] - fix FATAL nameerror
|
||||
* [COOK-827] - `mysql:server_ec2` recipe can't mount `data_dir`
|
||||
* [COOK-945] - FreeBSD support
|
||||
|
||||
## v1.2.2
|
||||
|
||||
* [COOK-826] mysql::server recipe doesn't quote password string
|
||||
* [COOK-834] Add 'scientific' and 'amazon' platforms to mysql cookbook
|
||||
|
||||
## v1.2.1
|
||||
|
||||
* [COOK-644] Mysql client cookbook 'package missing' error message is confusing
|
||||
* [COOK-645] RHEL6/CentOS6 - mysql cookbook contains 'skip-federated' directive which is unsupported on MySQL 5.1
|
||||
|
||||
## v1.2.0
|
||||
|
||||
* [COOK-684] remove mysql_database LWRP
|
||||
|
||||
## v1.0.8:
|
||||
|
||||
* [COOK-633] ensure "cloud" attribute is available
|
||||
|
||||
## v1.0.7:
|
||||
|
||||
* [COOK-614] expose all mysql tunable settings in config
|
||||
* [COOK-617] bind to private IP if available
|
||||
|
||||
## v1.0.6:
|
||||
|
||||
* [COOK-605] install mysql-client package on ubuntu/debian
|
||||
|
||||
## v1.0.5:
|
||||
|
||||
* [COOK-465] allow optional remote root connections to mysql
|
||||
* [COOK-455] improve platform version handling
|
||||
* externalize conf_dir attribute for easier cross platform support
|
||||
* change datadir attribute to data_dir for consistency
|
||||
|
||||
## v1.0.4:
|
||||
|
||||
* fix regressions on debian platform
|
||||
* [COOK-578] wrap root password in quotes
|
||||
* [COOK-562] expose all tunables in my.cnf
|
29
cookbooks/mysql/CONTRIBUTING
Normal file
29
cookbooks/mysql/CONTRIBUTING
Normal file
@ -0,0 +1,29 @@
|
||||
If you would like to contribute, please open a ticket in JIRA:
|
||||
|
||||
* http://tickets.opscode.com
|
||||
|
||||
Create the ticket in the COOK project and use the cookbook name as the
|
||||
component.
|
||||
|
||||
For all code contributions, we ask that contributors sign a
|
||||
contributor license agreement (CLA). Instructions may be found here:
|
||||
|
||||
* http://wiki.opscode.com/display/chef/How+to+Contribute
|
||||
|
||||
When contributing changes to individual cookbooks, please do not
|
||||
modify the version number in the metadata.rb. Also please do not
|
||||
update the CHANGELOG.md for a new version. Not all changes to a
|
||||
cookbook may be merged and released in the same versions. Opscode will
|
||||
handle the version updates during the release process. You are welcome
|
||||
to correct typos or otherwise make updates to documentation in the
|
||||
README.
|
||||
|
||||
If a contribution adds new platforms or platform versions, indicate
|
||||
such in the body of the commit message(s), and update the relevant
|
||||
COOK ticket. When writing commit messages, it is helpful for others if
|
||||
you indicate the COOK ticket. For example:
|
||||
|
||||
git commit -m '[COOK-1041] Updated pool resource to correctly delete.'
|
||||
|
||||
In the ticket itself, it is also helpful if you include log output of
|
||||
a successful Chef run, but this is not absolutely required.
|
201
cookbooks/mysql/LICENSE
Normal file
201
cookbooks/mysql/LICENSE
Normal file
@ -0,0 +1,201 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
113
cookbooks/mysql/README.md
Normal file
113
cookbooks/mysql/README.md
Normal file
@ -0,0 +1,113 @@
|
||||
Description
|
||||
===========
|
||||
|
||||
Installs and configures MySQL client or server.
|
||||
|
||||
Requirements
|
||||
============
|
||||
|
||||
Platform
|
||||
--------
|
||||
|
||||
* Debian, Ubuntu
|
||||
* CentOS, Red Hat, Fedora
|
||||
|
||||
Cookbooks
|
||||
---------
|
||||
|
||||
Requires Opscode's openssl cookbook for secure password generation.
|
||||
|
||||
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.
|
||||
|
||||
Resources and Providers
|
||||
=======================
|
||||
|
||||
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:
|
||||
|
||||
* `flush_tables_with_read_lock` - sends the sql command "flush tables with read lock", used for setting up mysql master/slave replication.
|
||||
* `unflush_tables` - sends the sql command "unflush tables", used for setting up master/slave replication.
|
||||
* `create_db` - specify a database to be created.
|
||||
* `query` - send an arbitrary query to the database, this should be used with care. Pass the SQL statement to use with the `sql` resource attribute.
|
||||
|
||||
For example see the USAGE section below.
|
||||
|
||||
Attributes
|
||||
==========
|
||||
|
||||
* `mysql[:server_root_password]` - Set the server's root password with this, default is a randomly generated password with `OpenSSL::Random.random_bytes`.
|
||||
* `mysql[:server_repl_password]` - Set the replication user 'repl' password with this, default is a randomly generated password with `OpenSSL::Random.random_bytes`.
|
||||
* `mysql[:server_debian_password]` - Set the debian-sys-maint user password with this, default is a randomly generated password with `OpenSSL::Random.random_bytes`.
|
||||
* `mysql[:bind_address]` - Listen address for MySQLd, default is node's ipaddress.
|
||||
* `mysql[:datadir]` - Location for mysql data directory, default is "/var/lib/mysql"
|
||||
* `mysql[:ec2_path]` - location of mysql datadir on EC2 nodes, default "/mnt/mysql"
|
||||
|
||||
Performance tuning attributes, each corresponds to the same-named parameter in my.cnf; default values listed
|
||||
|
||||
* `mysql[:tunable][:key_buffer]` = "250M"
|
||||
* `mysql[:tunable][:max_connections]` = "800"
|
||||
* `mysql[:tunable][:wait_timeout]` = "180"
|
||||
* `mysql[:tunable][:net_write_timeout]` = "30"
|
||||
* `mysql[:tunable][:net_write_timeout]` = "30"
|
||||
* `mysql[:tunable][:back_log]` = "128"
|
||||
* `mysql[:tunable][:table_cache]` = "128"
|
||||
* `mysql[:tunable][:max_heap_table_size]` = "32M"
|
||||
|
||||
Usage
|
||||
=====
|
||||
|
||||
On client nodes,
|
||||
|
||||
include_recipe "mysql::client"
|
||||
|
||||
This will install the MySQL client libraries and development headers on the system. It will also install the Ruby Gem `mysql`, so that the cookbook's LWRP (above) can be used. This is done during the compile-phase of the Chef run. On platforms that are known to have a native package (currently Debian, Ubuntu, Red hat, Centos, Fedora and SUSE), the package will be installed. Other platforms will use the RubyGem.
|
||||
|
||||
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:
|
||||
|
||||
mysql_database "create application_production database" do
|
||||
host "localhost"
|
||||
username "root"
|
||||
password node[:mysql][:server_root_password]
|
||||
database "application_production"
|
||||
action :create_db
|
||||
end
|
||||
|
||||
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.
|
||||
|
||||
On server nodes,
|
||||
|
||||
include_recipe "mysql::server"
|
||||
|
||||
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.
|
||||
|
||||
On EC2 nodes,
|
||||
|
||||
include_recipe "mysql::server_ec2"
|
||||
|
||||
When the `ec2_path` doesn't exist we look for a mounted filesystem (eg, EBS) and move the datadir there.
|
||||
|
||||
The client recipe is already included by server and 'default' recipes.
|
||||
|
||||
For more infromation on the compile vs execution phase of a Chef run:
|
||||
|
||||
* http://wiki.opscode.com/display/chef/Anatomy+of+a+Chef+Run
|
||||
|
||||
License and Author
|
||||
==================
|
||||
|
||||
Author:: Joshua Timberman (<joshua@opscode.com>)
|
||||
Author:: AJ Christensen (<aj@opscode.com>)
|
||||
Author:: Seth Chisamore (<schisamo@opscode.com>)
|
||||
|
||||
Copyright:: 2009-2011 Opscode, Inc
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
32
cookbooks/mysql/attributes/client.rb
Normal file
32
cookbooks/mysql/attributes/client.rb
Normal file
@ -0,0 +1,32 @@
|
||||
#
|
||||
# Cookbook Name:: mysql
|
||||
# Attributes:: server
|
||||
#
|
||||
# Copyright 2008-2009, Opscode, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
case node["platform"]
|
||||
when "windows"
|
||||
default['mysql']['client']['version'] = "6.0.2"
|
||||
default['mysql']['client']['arch'] = "win32" # force 32 bit to work with mysql gem
|
||||
default['mysql']['client']['package_file'] = "mysql-connector-c-#{mysql['client']['version']}-#{mysql['client']['arch']}.msi"
|
||||
default['mysql']['client']['url'] = "http://www.mysql.com/get/Downloads/Connector-C/#{mysql['client']['package_file']}/from/http://mysql.mirrors.pair.com/"
|
||||
default['mysql']['client']['package_name'] = "MySQL Connector C #{mysql['client']['version']}"
|
||||
|
||||
default['mysql']['client']['basedir'] = "#{ENV['SYSTEMDRIVE']}\\Program Files (x86)\\MySQL\\#{mysql['client']['package_name']}"
|
||||
default['mysql']['client']['lib_dir'] = "#{mysql['client']['basedir']}\\lib/opt"
|
||||
default['mysql']['client']['bin_dir'] = "#{mysql['client']['basedir']}\\bin"
|
||||
default['mysql']['client']['ruby_dir'] = RbConfig::CONFIG['bindir']
|
||||
end
|
77
cookbooks/mysql/attributes/server.rb
Normal file
77
cookbooks/mysql/attributes/server.rb
Normal file
@ -0,0 +1,77 @@
|
||||
#
|
||||
# Cookbook Name:: mysql
|
||||
# Attributes:: server
|
||||
#
|
||||
# Copyright 2008-2009, Opscode, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
default['mysql']['bind_address'] = ipaddress
|
||||
default['mysql']['storage_engine'] = "InnoDB"
|
||||
default['mysql']['datadir'] = "/var/lib/mysql"
|
||||
default['mysql']['tmpdir'] = "/var/lib/mysqltmp"
|
||||
default['mysql']['logdir'] = "/var/lib/mysqllogs"
|
||||
|
||||
case node["platform"]
|
||||
when "centos", "redhat", "fedora", "suse"
|
||||
set['mysql']['socket'] = "/var/lib/mysql/mysql.sock"
|
||||
set['mysql']['pid_file'] = "/var/run/mysqld/mysqld.pid"
|
||||
set['mysql']['old_passwords'] = 1
|
||||
else
|
||||
set['mysql']['socket'] = "/var/run/mysqld/mysqld.sock"
|
||||
set['mysql']['pid_file'] = "/var/run/mysqld/mysqld.pid"
|
||||
set['mysql']['old_passwords'] = 0
|
||||
end
|
||||
|
||||
if attribute?('ec2')
|
||||
default['mysql']['ec2_path'] = "/mnt/mysql"
|
||||
default['mysql']['ebs_vol_dev'] = "/dev/sdi"
|
||||
default['mysql']['ebs_vol_size'] = 50
|
||||
end
|
||||
|
||||
default['mysql']['tunable']['back_log'] = "128"
|
||||
default['mysql']['tunable']['key_buffer'] = "256M"
|
||||
default['mysql']['tunable']['max_allowed_packet'] = "16M"
|
||||
default['mysql']['tunable']['max_connections'] = "800"
|
||||
default['mysql']['tunable']['max_heap_table_size'] = "32M"
|
||||
default['mysql']['tunable']['myisam_recover'] = "BACKUP"
|
||||
default['mysql']['tunable']['net_read_timeout'] = "30"
|
||||
default['mysql']['tunable']['net_write_timeout'] = "30"
|
||||
default['mysql']['tunable']['table_cache'] = "128"
|
||||
default['mysql']['tunable']['table_open_cache'] = "128"
|
||||
default['mysql']['tunable']['thread_cache'] = "128"
|
||||
default['mysql']['tunable']['thread_cache_size'] = 8
|
||||
default['mysql']['tunable']['thread_concurrency'] = 10
|
||||
default['mysql']['tunable']['thread_stack'] = "256K"
|
||||
default['mysql']['tunable']['wait_timeout'] = "180"
|
||||
|
||||
default['mysql']['tunable']['query_cache_limit'] = "1M"
|
||||
default['mysql']['tunable']['query_cache_size'] = "32M"
|
||||
|
||||
default['mysql']['tunable']['log_slow_queries'] = "/var/log/mysql/slow.log"
|
||||
default['mysql']['tunable']['long_query_time'] = 2
|
||||
|
||||
# InnoDB Settings
|
||||
default['mysql']['tunable']['innodb_buffer_pool_size'] = "256M"
|
||||
default['mysql']['tunable']['innodb_log_buffer_size'] = "8M"
|
||||
default['mysql']['tunable']['innodb_log_file_size'] = "128M"
|
||||
default['mysql']['tunable']['innodb_file_per_table'] = 1
|
||||
default['mysql']['tunable']['innodb_open_files'] = 300
|
||||
|
||||
# Replication Settings
|
||||
default['mysql']['tunable']['server_id'] = "1"
|
||||
default['mysql']['tunable']['expire_logs_days'] = 10
|
||||
default['mysql']['tunable']['max_binlog_size'] = "100M"
|
||||
default['mysql']['tunable']['auto_increment_increment'] = 10
|
||||
default['mysql']['tunable']['auto_increment_offset'] = 1
|
19
cookbooks/mysql/libraries/database.rb
Normal file
19
cookbooks/mysql/libraries/database.rb
Normal file
@ -0,0 +1,19 @@
|
||||
begin
|
||||
require 'mysql'
|
||||
rescue LoadError
|
||||
Chef::Log.info("Missing gem 'mysql'")
|
||||
end
|
||||
|
||||
module Opscode
|
||||
module Mysql
|
||||
module Database
|
||||
def db
|
||||
@db ||= ::Mysql.new new_resource.host, new_resource.username, new_resource.password
|
||||
end
|
||||
def close
|
||||
@db.close rescue nil
|
||||
@db = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
33
cookbooks/mysql/libraries/helpers.rb
Normal file
33
cookbooks/mysql/libraries/helpers.rb
Normal file
@ -0,0 +1,33 @@
|
||||
#
|
||||
# Author:: Seth Chisamore (<schisamo@opscode.com>)
|
||||
# Copyright:: Copyright (c) 2011 Opscode, Inc.
|
||||
# License:: Apache License, Version 2.0
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
module Opscode
|
||||
module Mysql
|
||||
module Helpers
|
||||
|
||||
def debian_before_squeeze?
|
||||
platform?("debian") && (node.platform_version.to_f < 6.0)
|
||||
end
|
||||
|
||||
def ubuntu_before_lucid?
|
||||
platform?("ubuntu") && (node.platform_version.to_f < 10.0)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
401
cookbooks/mysql/metadata.json
Normal file
401
cookbooks/mysql/metadata.json
Normal file
File diff suppressed because one or more lines are too long
78
cookbooks/mysql/metadata.rb
Normal file
78
cookbooks/mysql/metadata.rb
Normal file
@ -0,0 +1,78 @@
|
||||
maintainer "Opscode, Inc."
|
||||
maintainer_email "cookbooks@opscode.com"
|
||||
license "Apache 2.0"
|
||||
description "Installs and configures mysql for client or server"
|
||||
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
|
||||
version "1.0.4"
|
||||
recipe "mysql", "Includes the client recipe to configure a client"
|
||||
recipe "mysql::client", "Installs packages required for mysql clients using run_action magic"
|
||||
recipe "mysql::server", "Installs packages required for mysql servers w/o manual intervention"
|
||||
recipe "mysql::server_ec2", "Performs EC2-specific mountpoint manipulation"
|
||||
recipe "mysql::test", "Sample Test recipe to confirm functionality"
|
||||
|
||||
%w{ debian ubuntu centos suse fedora redhat }.each do |os|
|
||||
supports os
|
||||
end
|
||||
|
||||
depends "openssl"
|
||||
|
||||
attribute "mysql/server_root_password",
|
||||
:display_name => "MySQL Server Root Password",
|
||||
:description => "Randomly generated password for the mysqld root user",
|
||||
:default => "randomly generated"
|
||||
|
||||
attribute "mysql/bind_address",
|
||||
:display_name => "MySQL Bind Address",
|
||||
:description => "Address that mysqld should listen on",
|
||||
:default => "ipaddress"
|
||||
|
||||
attribute "mysql/datadir",
|
||||
:display_name => "MySQL Data Directory",
|
||||
:description => "Location of mysql databases",
|
||||
:default => "/var/lib/mysql"
|
||||
|
||||
attribute "mysql/ec2_path",
|
||||
:display_name => "MySQL EC2 Path",
|
||||
:description => "Location of mysql directory on EC2 instance EBS volumes",
|
||||
:default => "/mnt/mysql"
|
||||
|
||||
attribute "mysql/tunable",
|
||||
:display_name => "MySQL Tunables",
|
||||
:description => "Hash of MySQL tunable attributes",
|
||||
:type => "hash"
|
||||
|
||||
attribute "mysql/tunable/key_buffer",
|
||||
:display_name => "MySQL Tuntable Key Buffer",
|
||||
:default => "250M"
|
||||
|
||||
attribute "mysql/tunable/max_connections",
|
||||
:display_name => "MySQL Tunable Max Connections",
|
||||
:default => "800"
|
||||
|
||||
attribute "mysql/tunable/wait_timeout",
|
||||
:display_name => "MySQL Tunable Wait Timeout",
|
||||
:default => "180"
|
||||
|
||||
attribute "mysql/tunable/net_read_timeout",
|
||||
:display_name => "MySQL Tunable Net Read Timeout",
|
||||
:default => "30"
|
||||
|
||||
attribute "mysql/tunable/net_write_timeout",
|
||||
:display_name => "MySQL Tunable Net Write Timeout",
|
||||
:default => "30"
|
||||
|
||||
attribute "mysql/tunable/back_log",
|
||||
:display_name => "MySQL Tunable Back Log",
|
||||
:default => "128"
|
||||
|
||||
attribute "mysql/tunable/table_cache",
|
||||
:display_name => "MySQL Tunable Table Cache for MySQL < 5.1.3",
|
||||
:default => "128"
|
||||
|
||||
attribute "mysql/tunable/table_open_cache",
|
||||
:display_name => "MySQL Tunable Table Cache for MySQL >= 5.1.3",
|
||||
:default => "128"
|
||||
|
||||
attribute "mysql/tunable/max_heap_table_size",
|
||||
:display_name => "MySQL Tunable Max Heap Table Size",
|
||||
:default => "32M"
|
81
cookbooks/mysql/providers/database.rb
Normal file
81
cookbooks/mysql/providers/database.rb
Normal file
@ -0,0 +1,81 @@
|
||||
#
|
||||
# Cookbook Name:: mysql
|
||||
# Provider:: database
|
||||
#
|
||||
# Copyright:: 2008-2011, Opscode, Inc <legal@opscode.com>
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
include Opscode::Mysql::Database
|
||||
|
||||
action :flush_tables_with_read_lock do
|
||||
if exists?
|
||||
begin
|
||||
Chef::Log.info "mysql_database: flushing tables with read lock"
|
||||
db.query "flush tables with read lock"
|
||||
new_resource.updated_by_last_action(true)
|
||||
ensure
|
||||
db.close
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
action :unflush_tables do
|
||||
if exists?
|
||||
begin
|
||||
Chef::Log.info "mysql_database: unlocking tables"
|
||||
db.query "unlock tables"
|
||||
new_resource.updated_by_last_action(true)
|
||||
ensure
|
||||
db.close
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
action :create_db do
|
||||
unless exists?
|
||||
begin
|
||||
Chef::Log.info "mysql_database: Creating database #{new_resource.database}"
|
||||
db.query("create database #{new_resource.database}")
|
||||
new_resource.updated_by_last_action(true)
|
||||
ensure
|
||||
db.close
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
action :query do
|
||||
if exists?
|
||||
begin
|
||||
Chef::Log.info "mysql_database: Performing Query: #{new_resource.sql}"
|
||||
db.query(new_resource.sql)
|
||||
new_resource.updated_by_last_action(true)
|
||||
ensure
|
||||
db.close
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def load_current_resource
|
||||
Gem.clear_paths
|
||||
require 'mysql'
|
||||
|
||||
@mysqldb = Chef::Resource::MysqlDatabase.new(new_resource.name)
|
||||
@mysqldb.database(new_resource.database)
|
||||
end
|
||||
|
||||
private
|
||||
def exists?
|
||||
db.list_dbs.include?(new_resource.database)
|
||||
end
|
54
cookbooks/mysql/recipes/client.rb
Normal file
54
cookbooks/mysql/recipes/client.rb
Normal file
@ -0,0 +1,54 @@
|
||||
#
|
||||
# Cookbook Name:: mysql
|
||||
# Recipe:: client
|
||||
#
|
||||
# Copyright 2008-2011, Opscode, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
package "mysql-devel" do
|
||||
package_name value_for_platform(
|
||||
[ "centos", "redhat", "suse", "fedora"] => { "default" => "mysql-devel" },
|
||||
["debian", "ubuntu"] => { "default" => 'libmysqlclient-dev' },
|
||||
"default" => 'libmysqlclient-dev'
|
||||
)
|
||||
action :install
|
||||
end
|
||||
|
||||
package "mysql-client" do
|
||||
package_name value_for_platform(
|
||||
[ "centos", "redhat", "suse", "fedora"] => { "default" => "mysql" },
|
||||
"default" => "mysql-client"
|
||||
)
|
||||
action :install
|
||||
end
|
||||
|
||||
if platform?(%w{debian ubuntu redhat centos fedora suse})
|
||||
|
||||
package "mysql-ruby" do
|
||||
package_name value_for_platform(
|
||||
[ "centos", "redhat", "suse", "fedora"] => { "default" => "ruby-mysql" },
|
||||
["debian", "ubuntu"] => { "default" => 'libmysql-ruby' },
|
||||
"default" => 'libmysql-ruby'
|
||||
)
|
||||
action :install
|
||||
end
|
||||
|
||||
else
|
||||
|
||||
gem_package "mysql" do
|
||||
action :install
|
||||
end
|
||||
|
||||
end
|
20
cookbooks/mysql/recipes/default.rb
Normal file
20
cookbooks/mysql/recipes/default.rb
Normal file
@ -0,0 +1,20 @@
|
||||
#
|
||||
# Cookbook Name:: mysql
|
||||
# Recipe:: default
|
||||
#
|
||||
# Copyright 2008-2009, Opscode, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
include_recipe "mysql::client"
|
206
cookbooks/mysql/recipes/server.rb
Normal file
206
cookbooks/mysql/recipes/server.rb
Normal file
@ -0,0 +1,206 @@
|
||||
#
|
||||
# Cookbook Name:: mysql
|
||||
# Recipe:: default
|
||||
#
|
||||
# Copyright 2008-2011, Opscode, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
|
||||
include_recipe "mysql::client"
|
||||
|
||||
if platform?(%w{debian ubuntu})
|
||||
|
||||
directory "/var/cache/local/preseeding" do
|
||||
owner "root"
|
||||
group "root"
|
||||
mode 0755
|
||||
recursive true
|
||||
end
|
||||
|
||||
template "/var/cache/local/preseeding/mysql-server.seed" do
|
||||
source "mysql-server.seed.erb"
|
||||
owner "root"
|
||||
group "root"
|
||||
mode "0600"
|
||||
end
|
||||
|
||||
template "/etc/mysql/debian.cnf" do
|
||||
source "debian.cnf.erb"
|
||||
owner "root"
|
||||
group "root"
|
||||
mode "0600"
|
||||
end
|
||||
|
||||
execute "preseed mysql-server" do
|
||||
command "debconf-set-selections /var/cache/local/preseeding/mysql-server.seed"
|
||||
only_if "test -f /var/cache/local/preseeding/mysql-server.seed"
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
# For Crowbar, we need to set the address to bind - default to admin node.
|
||||
addr = node['mysql']['bind_address'] || ""
|
||||
#newaddr = Chef::Recipe::Barclamp::Inventory.get_network_by_type(node, "admin").address
|
||||
#if addr != newaddr
|
||||
# node['mysql']['bind_address'] = newaddr
|
||||
# node.save
|
||||
#end
|
||||
|
||||
package "mysql-server" do
|
||||
action :install
|
||||
end
|
||||
|
||||
service "mysql" do
|
||||
service_name value_for_platform([ "centos", "redhat", "suse", "fedora" ] => {"default" => "mysqld"}, "default" => "mysql")
|
||||
if (platform?("ubuntu") && node.platform_version.to_f >= 10.04)
|
||||
restart_command "restart mysql"
|
||||
stop_command "stop mysql"
|
||||
start_command "start mysql"
|
||||
end
|
||||
supports :status => true, :restart => true, :reload => true
|
||||
action :nothing
|
||||
end
|
||||
|
||||
=begin
|
||||
link value_for_platform([ "centos", "redhat", "suse" , "fedora" ] => {"default" => "/etc/my.cnf"}, "default" => "/etc/mysql/my.cnf") do
|
||||
to "#{node[:mysql][:datadir]}/my.cnf"
|
||||
end
|
||||
=end
|
||||
|
||||
directory node[:mysql][:tmpdir] do
|
||||
owner "mysql"
|
||||
group "mysql"
|
||||
mode "0700"
|
||||
action :create
|
||||
end
|
||||
|
||||
directory node[:mysql][:logdir] do
|
||||
owner "mysql"
|
||||
group "mysql"
|
||||
mode "0700"
|
||||
action :create
|
||||
end
|
||||
|
||||
script "handle mysql restart" do
|
||||
interpreter "bash"
|
||||
action :nothing
|
||||
code <<EOC
|
||||
service mysql stop
|
||||
rm /var/lib/mysql/ib_logfile?
|
||||
service mysql start
|
||||
EOC
|
||||
end
|
||||
|
||||
template "#{node[:mysql][:datadir]}/my.cnf" do
|
||||
source "my.cnf.erb"
|
||||
owner "root"
|
||||
group "root"
|
||||
mode "0644"
|
||||
notifies :run, resources(:script => "handle mysql restart"), :immediately
|
||||
end
|
||||
|
||||
unless Chef::Config[:solo]
|
||||
ruby_block "save node data" do
|
||||
block do
|
||||
node.save
|
||||
end
|
||||
action :create
|
||||
end
|
||||
end
|
||||
|
||||
# set the root password on platforms
|
||||
# that don't support pre-seeding
|
||||
unless platform?(%w{debian ubuntu})
|
||||
|
||||
execute "assign-root-password" do
|
||||
command "/usr/bin/mysqladmin -u root password \"#{node['mysql']['server_root_password']}\""
|
||||
action :run
|
||||
only_if "/usr/bin/mysql -u root -e 'show databases;'"
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
# Super duper hackfest-o-rama 2011.
|
||||
# Under crowbar, for some reason, defaults aren't being set properly
|
||||
# for the mysql passwords. This is a nasty, nasty hack to
|
||||
# fix this until I understand the problem better:
|
||||
|
||||
template "/etc/mysql/conf.d/emergency_init_file" do
|
||||
source "emergency_init_file.erb"
|
||||
owner "root"
|
||||
group "root"
|
||||
mode "0600"
|
||||
action :create
|
||||
end
|
||||
|
||||
|
||||
script "fix_perms_hack" do
|
||||
interpreter "bash"
|
||||
user "root"
|
||||
cwd "/tmp"
|
||||
code <<-EOH
|
||||
/etc/init.d/mysql stop
|
||||
chmod 644 /etc/mysql/conf.d/emergency_init_file
|
||||
/usr/bin/mysqld_safe --init-file=/etc/mysql/conf.d/emergency_init_file &
|
||||
sleep 10
|
||||
killall mysqld
|
||||
chmod 600 /etc/mysql/conf.d/emergency_init_file
|
||||
/etc/init.d/mysql start
|
||||
EOH
|
||||
not_if "/usr/bin/mysql -u root #{node['mysql']['server_root_password'].empty? ? '' : '-p' }#{node['mysql']['server_root_password']} -e 'show databases;'"
|
||||
end
|
||||
|
||||
# End hackness
|
||||
|
||||
grants_path = value_for_platform(
|
||||
["centos", "redhat", "suse", "fedora" ] => {
|
||||
"default" => "/etc/mysql_grants.sql"
|
||||
},
|
||||
"default" => "/etc/mysql/grants.sql"
|
||||
)
|
||||
|
||||
grants_key = value_for_platform(
|
||||
["centos", "redhat", "suse", "fedora" ] => {
|
||||
"default" => "/etc/applied_grants"
|
||||
},
|
||||
"default" => "/etc/mysql/applied_grants"
|
||||
)
|
||||
|
||||
template grants_path do
|
||||
source "grants.sql.erb"
|
||||
owner "root"
|
||||
group "root"
|
||||
mode "0600"
|
||||
action :create
|
||||
not_if { File.exists?("#{grants_key}") }
|
||||
end
|
||||
|
||||
execute "mysql-install-privileges" do
|
||||
command "/usr/bin/mysql -u root #{node['mysql']['server_root_password'].empty? ? '' : '-p' }#{node['mysql']['server_root_password']} < #{grants_path}"
|
||||
action :nothing
|
||||
subscribes :run, resources("template[#{grants_path}]"), :immediately
|
||||
end
|
||||
|
||||
file grants_path do
|
||||
backup false
|
||||
action :delete
|
||||
end
|
||||
|
||||
file grants_key do
|
||||
owner "root"
|
||||
group "root"
|
||||
mode "0600"
|
||||
action :create_if_missing
|
||||
end
|
206
cookbooks/mysql/recipes/server.rb~
Normal file
206
cookbooks/mysql/recipes/server.rb~
Normal file
@ -0,0 +1,206 @@
|
||||
#
|
||||
# Cookbook Name:: mysql
|
||||
# Recipe:: default
|
||||
#
|
||||
# Copyright 2008-2011, Opscode, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
|
||||
include_recipe "mysql::client"
|
||||
|
||||
if platform?(%w{debian ubuntu})
|
||||
|
||||
directory "/var/cache/local/preseeding" do
|
||||
owner "root"
|
||||
group "root"
|
||||
mode 0755
|
||||
recursive true
|
||||
end
|
||||
|
||||
template "/var/cache/local/preseeding/mysql-server.seed" do
|
||||
source "mysql-server.seed.erb"
|
||||
owner "root"
|
||||
group "root"
|
||||
mode "0600"
|
||||
end
|
||||
|
||||
template "/etc/mysql/debian.cnf" do
|
||||
source "debian.cnf.erb"
|
||||
owner "root"
|
||||
group "root"
|
||||
mode "0600"
|
||||
end
|
||||
|
||||
execute "preseed mysql-server" do
|
||||
command "debconf-set-selections /var/cache/local/preseeding/mysql-server.seed"
|
||||
only_if "test -f /var/cache/local/preseeding/mysql-server.seed"
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
# For Crowbar, we need to set the address to bind - default to admin node.
|
||||
addr = node['mysql']['bind_address'] || ""
|
||||
#newaddr = Chef::Recipe::Barclamp::Inventory.get_network_by_type(node, "admin").address
|
||||
#if addr != newaddr
|
||||
# node['mysql']['bind_address'] = newaddr
|
||||
# node.save
|
||||
#end
|
||||
|
||||
package "mysql-server" do
|
||||
action :install
|
||||
end
|
||||
|
||||
service "mysql" do
|
||||
service_name value_for_platform([ "centos", "redhat", "suse", "fedora" ] => {"default" => "mysqld"}, "default" => "mysql")
|
||||
if (platform?("ubuntu") && node.platform_version.to_f >= 10.04)
|
||||
restart_command "restart mysql"
|
||||
stop_command "stop mysql"
|
||||
start_command "start mysql"
|
||||
end
|
||||
supports :status => true, :restart => true, :reload => true
|
||||
action :nothing
|
||||
end
|
||||
|
||||
=begin
|
||||
link value_for_platform([ "centos", "redhat", "suse" , "fedora" ] => {"default" => "/etc/my.cnf"}, "default" => "/etc/mysql/my.cnf") do
|
||||
to "#{node[:mysql][:datadir]}/my.cnf"
|
||||
end
|
||||
=end
|
||||
|
||||
directory node[:mysql][:tmpdir] do
|
||||
owner "mysql"
|
||||
group "mysql"
|
||||
mode "0700"
|
||||
action :create
|
||||
end
|
||||
|
||||
directory node[:mysql][:logdir] do
|
||||
owner "mysql"
|
||||
group "mysql"
|
||||
mode "0700"
|
||||
action :create
|
||||
end
|
||||
|
||||
script "handle mysql restart" do
|
||||
interpreter "bash"
|
||||
action :nothing
|
||||
code <<EOC
|
||||
service mysql stop
|
||||
rm /var/lib/mysql/ib_logfile?
|
||||
service mysql start
|
||||
EOC
|
||||
end
|
||||
|
||||
template "#{node[:mysql][:datadir]}/my.cnf" do
|
||||
source "my.cnf.erb"
|
||||
owner "root"
|
||||
group "root"
|
||||
mode "0644"
|
||||
notifies :run, resources(:script => "handle mysql restart"), :immediately
|
||||
end
|
||||
|
||||
unless Chef::Config[:solo]
|
||||
ruby_block "save node data" do
|
||||
block do
|
||||
node.save
|
||||
end
|
||||
action :create
|
||||
end
|
||||
end
|
||||
|
||||
# set the root password on platforms
|
||||
# that don't support pre-seeding
|
||||
unless platform?(%w{debian ubuntu})
|
||||
|
||||
execute "assign-root-password" do
|
||||
command "/usr/bin/mysqladmin -u root password \"#{node['mysql']['server_root_password']}\""
|
||||
action :run
|
||||
only_if "/usr/bin/mysql -u root -e 'show databases;'"
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
# Super duper hackfest-o-rama 2011.
|
||||
# Under crowbar, for some reason, defaults aren't being set properly
|
||||
# for the mysql passwords. This is a nasty, nasty hack to
|
||||
# fix this until I understand the problem better:
|
||||
|
||||
template "/etc/mysql/conf.d/emergency_init_file" do
|
||||
source "emergency_init_file.erb"
|
||||
owner "root"
|
||||
group "root"
|
||||
mode "0600"
|
||||
action :create
|
||||
end
|
||||
|
||||
|
||||
script "fix_perms_hack" do
|
||||
interpreter "bash"
|
||||
user "root"
|
||||
cwd "/tmp"
|
||||
code <<-EOH
|
||||
/etc/init.d/mysql stop
|
||||
chmod 644 /etc/mysql/conf.d/emergency_init_file
|
||||
/usr/bin/mysqld_safe --init-file=/etc/mysql/conf.d/emergency_init_file &
|
||||
sleep 10
|
||||
killall mysqld
|
||||
chmod 600 /etc/mysql/conf.d/emergency_init_file
|
||||
/etc/init.d/mysql start
|
||||
EOH
|
||||
not_if "/usr/bin/mysql -u root #{node['mysql']['server_root_password'].empty? ? '' : '-p' }#{node['mysql']['server_root_password']} -e 'show databases;'"
|
||||
end
|
||||
|
||||
# End hackness
|
||||
|
||||
grants_path = value_for_platform(
|
||||
["centos", "redhat", "suse", "fedora" ] => {
|
||||
"default" => "/etc/mysql_grants.sql"
|
||||
},
|
||||
"default" => "/etc/mysql/grants.sql"
|
||||
)
|
||||
|
||||
grants_key = value_for_platform(
|
||||
["centos", "redhat", "suse", "fedora" ] => {
|
||||
"default" => "/etc/applied_grants"
|
||||
},
|
||||
"default" => "/etc/mysql/applied_grants"
|
||||
)
|
||||
|
||||
template grants_path do
|
||||
source "grants.sql.erb"
|
||||
owner "root"
|
||||
group "root"
|
||||
mode "0600"
|
||||
action :create
|
||||
not_if { File.exists?("#{grants_key}") }
|
||||
end
|
||||
|
||||
execute "mysql-install-privileges" do
|
||||
command "/usr/bin/mysql -u root #{node['mysql']['server_root_password'].empty? ? '' : '-p' }#{node['mysql']['server_root_password']} < #{grants_path}"
|
||||
action :nothing
|
||||
subscribes :run, resources("template[#{grants_path}]"), :immediately
|
||||
end
|
||||
|
||||
file grants_path do
|
||||
backup false
|
||||
action :delete
|
||||
end
|
||||
|
||||
file grants_key do
|
||||
owner "root"
|
||||
group "root"
|
||||
mode "0600"
|
||||
action :create_if_missing
|
||||
end
|
49
cookbooks/mysql/recipes/server_ec2.rb
Normal file
49
cookbooks/mysql/recipes/server_ec2.rb
Normal file
@ -0,0 +1,49 @@
|
||||
#
|
||||
# Cookbook Name:: mysql
|
||||
# Recipe:: default
|
||||
#
|
||||
# Copyright 2008-2009, Opscode, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
|
||||
if (node.attribute?('ec2') && ! FileTest.directory?(node['mysql']['ec2_path']))
|
||||
|
||||
service "mysql" do
|
||||
action :stop
|
||||
end
|
||||
|
||||
execute "install-mysql" do
|
||||
command "mv #{node['mysql']['datadir']} #{node['mysql']['ec2_path']}"
|
||||
not_if do FileTest.directory?(node['mysql']['ec2_path']) end
|
||||
end
|
||||
|
||||
directory node['mysql']['ec2_path'] do
|
||||
owner "mysql"
|
||||
group "mysql"
|
||||
end
|
||||
|
||||
mount node['mysql']['datadir'] do
|
||||
device node['mysql']['ec2_path']
|
||||
fstype "none"
|
||||
options "bind,rw"
|
||||
action :mount
|
||||
end
|
||||
|
||||
service "mysql" do
|
||||
action :start
|
||||
end
|
||||
|
||||
end
|
||||
|
68
cookbooks/mysql/recipes/test.rb
Normal file
68
cookbooks/mysql/recipes/test.rb
Normal file
@ -0,0 +1,68 @@
|
||||
#
|
||||
# Cookbook Name:: mysql
|
||||
# Recipe:: test
|
||||
#
|
||||
# Copyright 2008-2011, Keith Hudgins.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# This is a proof of concept/example for how to create a remote database
|
||||
# Basically, you can use the snippets below
|
||||
|
||||
# Include OpenSSL Password so we can make a new password for our dbuser
|
||||
# (This example re-uses)
|
||||
::Chef::Recipe.send(:include, Opscode::OpenSSL::Password)
|
||||
|
||||
node.set_unless['testnamespace']['db_test_user_password']
|
||||
|
||||
include_recipe "mysql::client"
|
||||
|
||||
# Chef search query to pull your server. This returns an array
|
||||
# of nodes. In our example here, there's only ONE mysql-server node. If,
|
||||
# for some reason you have multiple notes with mysql-server role assigned
|
||||
# via your barclamp, you'll need to adjust this.
|
||||
# Because of this, we know it's the first one
|
||||
# Thus, the db_server[0] bit.
|
||||
db_server = search(:node, "fqdn:#{node['mysql-server']}")
|
||||
|
||||
# This saves the password so that we're idempotent.
|
||||
# Doesn't work on chef solo since there's no place to
|
||||
# save node data there.
|
||||
unless Chef::Config[:solo]
|
||||
ruby_block "save node data" do
|
||||
block do
|
||||
node.save
|
||||
end
|
||||
action :create
|
||||
end
|
||||
end
|
||||
|
||||
mysql_database "create test database" do
|
||||
host "#{db_server[0].ipaddress}"
|
||||
username "db_maker"
|
||||
password "#{db_server[0].mysql.db_maker_password}"
|
||||
database "test_db"
|
||||
action :create_db
|
||||
end
|
||||
|
||||
# This is a logging example of how to pull a password from the node's data space.
|
||||
Chef::Log.info "pwgimme: #{db_server[0].mysql.db_maker_password}"
|
||||
|
||||
mysql_database "create test database user" do
|
||||
host "#{db_server[0].ipaddress}"
|
||||
username "db_maker"
|
||||
password "#{db_server[0].mysql.db_maker_password}"
|
||||
database "test_db"
|
||||
action :query
|
||||
sql "GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON *.* TO 'test_user'@'%' IDENTIFIED BY '#{node[:testnamespace][:db_test_user_password]}' WITH GRANT OPTION;"
|
||||
end
|
27
cookbooks/mysql/resources/database.rb
Normal file
27
cookbooks/mysql/resources/database.rb
Normal file
@ -0,0 +1,27 @@
|
||||
#
|
||||
# Cookbook Name:: mysql
|
||||
# Resource:: database
|
||||
#
|
||||
# Copyright:: 2008-2011, Opscode, Inc <legal@opscode.com>
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
actions :flush_tables_with_read_lock, :unflush_tables, :create_db, :query
|
||||
|
||||
attribute :host, :kind_of => String
|
||||
attribute :username, :kind_of => String
|
||||
attribute :password, :kind_of => String
|
||||
attribute :database, :kind_of => String
|
||||
attribute :sql, :kind_of => String
|
||||
attribute :exists, :default => false
|
12
cookbooks/mysql/templates/default/debian.cnf.erb
Normal file
12
cookbooks/mysql/templates/default/debian.cnf.erb
Normal file
@ -0,0 +1,12 @@
|
||||
[client]
|
||||
host = localhost
|
||||
user = debian-sys-maint
|
||||
password = <%= node['mysql']['server_debian_password'] %>
|
||||
socket = <%= node['mysql']['socket'] %>
|
||||
|
||||
[mysql_upgrade]
|
||||
host = localhost
|
||||
user = debian-sys-maint
|
||||
password = <%= node['mysql']['server_debian_password'] %>
|
||||
socket = <%= node['mysql']['socket'] %>
|
||||
basedir = /usr
|
@ -0,0 +1,8 @@
|
||||
# Generated by Chef for <%= node['hostname'] %>.
|
||||
# Local modifications will be overwritten.
|
||||
|
||||
# Set the server root password. This should be preseeded by the package installation.
|
||||
SET PASSWORD FOR 'root'@'localhost' = PASSWORD('<%= node['mysql']['server_root_password'] %>');
|
||||
|
||||
#Flush privileges
|
||||
FLUSH PRIVILEGES;
|
17
cookbooks/mysql/templates/default/grants.sql.erb
Normal file
17
cookbooks/mysql/templates/default/grants.sql.erb
Normal file
@ -0,0 +1,17 @@
|
||||
# Generated by Chef for <%= node['hostname'] %>.
|
||||
# Local modifications will be overwritten.
|
||||
|
||||
<% case node['platform'] -%>
|
||||
<% when "debian","ubuntu" -%>
|
||||
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, SHUTDOWN, PROCESS, FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, SUPER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT ON *.* TO 'debian-sys-maint'@'localhost' IDENTIFIED BY '<%= node[:mysql][:server_debian_password] %>' WITH GRANT OPTION;
|
||||
<% end -%>
|
||||
# Grant replication for a slave user.
|
||||
GRANT REPLICATION SLAVE ON *.* TO 'repl'@'%' identified by '<%= node['mysql']['server_repl_password'] %>';
|
||||
|
||||
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER, SHOW DATABASES, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, CREATE USER, CREATE VIEW, SHOW VIEW, TRIGGER, EXECUTE, CREATE ROUTINE, ALTER ROUTINE ON *.* TO 'db_maker'@'%' IDENTIFIED BY '<%= node[:mysql][:db_maker_password] %>' WITH GRANT OPTION;
|
||||
|
||||
# Set the server root password. This should be preseeded by the package installation.
|
||||
SET PASSWORD FOR 'root'@'localhost' = PASSWORD('<%= node['mysql']['server_root_password'] %>');
|
||||
|
||||
#Flush privileges
|
||||
FLUSH PRIVILEGES;
|
195
cookbooks/mysql/templates/default/my.cnf.erb
Normal file
195
cookbooks/mysql/templates/default/my.cnf.erb
Normal file
@ -0,0 +1,195 @@
|
||||
#
|
||||
# Generated by Chef for <%= node['hostname'] %>
|
||||
#
|
||||
# Local modifications will be overwritten.
|
||||
#
|
||||
# The MySQL database server configuration file.
|
||||
#
|
||||
# You can copy this to one of:
|
||||
# - "/etc/mysql/my.cnf" to set global options,
|
||||
# - "~/.my.cnf" to set user-specific options.
|
||||
#
|
||||
# One can use all long options that the program supports.
|
||||
# Run program with --help to get a list of available options and with
|
||||
# --print-defaults to see which it would actually understand and use.
|
||||
#
|
||||
# For explanations see
|
||||
# http://dev.mysql.com/doc/mysql/en/server-system-variables.html
|
||||
|
||||
# This will be passed to all mysql clients
|
||||
# It has been reported that passwords should be enclosed with ticks/quotes
|
||||
# escpecially if they contain "#" chars...
|
||||
# Remember to edit /etc/mysql/debian.cnf when changing the socket location.
|
||||
[client]
|
||||
port = 3306
|
||||
socket = <%= node['mysql']['socket'] %>
|
||||
|
||||
# Here is entries for some specific programs
|
||||
# The following values assume you have at least 32M ram
|
||||
|
||||
# This was formally known as [safe_mysqld]. Both versions are currently parsed.
|
||||
[mysqld_safe]
|
||||
socket = <%= node['mysql']['socket'] %>
|
||||
nice = 0
|
||||
|
||||
[mysqld]
|
||||
#
|
||||
# * Basic Settings
|
||||
#
|
||||
|
||||
#
|
||||
# * IMPORTANT
|
||||
# If you make changes to these settings and your system uses apparmor, you may
|
||||
# also need to also adjust /etc/apparmor.d/usr.sbin.mysqld.
|
||||
#
|
||||
|
||||
user = mysql
|
||||
pid-file = <%= node['mysql']['pid_file'] %>
|
||||
socket = <%= node['mysql']['socket'] %>
|
||||
port = 3306
|
||||
basedir = /usr
|
||||
datadir = <%= node['mysql']['datadir'] %>
|
||||
tmpdir = <%= node['mysql']['tmpdir'] %>
|
||||
skip-external-locking
|
||||
|
||||
#
|
||||
# * Storage Engines
|
||||
#
|
||||
# Set this to force MySQL to use a particular engine / table-type
|
||||
# for new tables. This setting can still be overridden by specifying
|
||||
# the engine explicitly in the CREATE TABLE statement.
|
||||
default-storage-engine = <%= node['mysql']['storage_engine'] %>
|
||||
|
||||
#
|
||||
# Instead of skip-networking the default is now to listen only on
|
||||
# localhost which is more compatible and is not less secure.
|
||||
bind-address = <%= node['mysql']['bind_address'] %>
|
||||
#
|
||||
# * Fine Tuning
|
||||
#
|
||||
key_buffer = <%= node['mysql']['tunable']['key_buffer'] %>
|
||||
max_allowed_packet = <%= node['mysql']['tunable']['max_allowed_packet'] %>
|
||||
thread_stack = <%= node['mysql']['tunable']['thread_stack'] %>
|
||||
thread_cache_size = <%= node['mysql']['tunable']['thread_cache_size'] %>
|
||||
# This replaces the startup script and checks MyISAM tables if needed
|
||||
# the first time they are touched
|
||||
myisam-recover = <%= node['mysql']['tunable']['myisam_recover'] %>
|
||||
#thread_concurrency = <%= node['mysql']['tunable']['thread_concurrency'] %>
|
||||
max_connections = <%= node['mysql']['tunable']['max_connections'] %>
|
||||
wait_timeout = <%= node['mysql']['tunable']['wait_timeout'] %>
|
||||
net_read_timeout = <%= node['mysql']['tunable']['net_read_timeout'] %>
|
||||
net_write_timeout = <%= node['mysql']['tunable']['net_write_timeout'] %>
|
||||
back_log = <%= node['mysql']['tunable']['back_log'] %>
|
||||
table_cache = <%= node['mysql']['tunable']['table_cache'] %>
|
||||
max_heap_table_size = <%= node['mysql']['tunable']['max_heap_table_size'] %>
|
||||
|
||||
#
|
||||
# * Query Cache Configuration
|
||||
#
|
||||
# Generally, it is unwise to set the query cache to be larger than 64-128M
|
||||
# as the costs associated with maintaining the cache outweigh the performance
|
||||
# gains.
|
||||
query_cache_limit = <%= node['mysql']['tunable']['query_cache_limit'] %>
|
||||
query_cache_size = <%= node['mysql']['tunable']['query_cache_size'] %>
|
||||
|
||||
#
|
||||
# * Logging and Replication
|
||||
#
|
||||
# Both location gets rotated by the cronjob.
|
||||
# Be aware that this log type is a performance killer.
|
||||
#log = /var/log/mysql/mysql.log
|
||||
#
|
||||
# Error logging goes to syslog. This is a Debian improvement :)
|
||||
#
|
||||
# Here you can see queries with especially long duration
|
||||
log_slow_queries = <%= node['mysql']['tunable']['log_slow_queries'] %>
|
||||
long_query_time = <%= node['mysql']['tunable']['long_query_time'] %>
|
||||
log-queries-not-using-indexes
|
||||
|
||||
#
|
||||
# The following can be used as easy to replay backup logs or for replication.
|
||||
# note: if you are setting up a replication slave, see README.Debian about
|
||||
# other settings you may need to change.
|
||||
server-id = <%= node['mysql']['server_id'] %>
|
||||
log_bin = <%= node['mysql']['logdir'] %>/mysql-bin.log
|
||||
expire_logs_days = <%= node['mysql']['tunable']['expire_log_days'] %>
|
||||
max_binlog_size = <%= node['mysql']['tunable']['max_binlog_size'] %>
|
||||
#
|
||||
# Uncomment the auto_increment options for Multi-Master replication
|
||||
#
|
||||
#auto_increment_increment = <%= node['mysql']['tunable']['auto_increment_increment'] %>
|
||||
#auto_increment_offset = <%= node['mysql']['tunable']['auto_increment_offset'] %>
|
||||
#binlog_do_db = include_database_name
|
||||
#binlog_ignore_db = include_database_name
|
||||
|
||||
#
|
||||
# * InnoDB
|
||||
#
|
||||
# InnoDB is enabled by default with a 10MB datafile in /var/lib/mysql/.
|
||||
# Read the manual for more InnoDB related options. There are many!
|
||||
# You might want to disable InnoDB to shrink the mysqld process by circa 100MB.
|
||||
#skip-innodb
|
||||
innodb_buffer_pool_size = <%= node['mysql']['tunable']['innodb_buffer_pool_size'] %>
|
||||
innodb_log_buffer_size = <%= node['mysql']['tunable']['innodb_log_buffer_size'] %>
|
||||
innodb_log_file_size = <%= node['mysql']['tunable']['innodb_log_file_size'] %>
|
||||
innodb_file_per_table = <%= node['mysql']['tunable']['innodb_file_per_table'] %>
|
||||
innodb_open_files = <%= node['mysql']['tunable']['innodb_open_files'] %>
|
||||
#
|
||||
# * Federated
|
||||
#
|
||||
# The FEDERATED storage engine is disabled since 5.0.67 by default in the .cnf files
|
||||
# shipped with MySQL distributions (my-huge.cnf, my-medium.cnf, and so forth).
|
||||
#
|
||||
skip-federated
|
||||
#
|
||||
# * Security Features
|
||||
#
|
||||
# Read the manual, too, if you want chroot!
|
||||
# chroot = /var/lib/mysql/
|
||||
#
|
||||
# For generating SSL certificates I recommend the OpenSSL GUI "tinyca".
|
||||
#
|
||||
# ssl-ca=/etc/mysql/cacert.pem
|
||||
# ssl-cert=/etc/mysql/server-cert.pem
|
||||
# ssl-key=/etc/mysql/server-key.pem
|
||||
|
||||
[mysqldump]
|
||||
quick
|
||||
quote-names
|
||||
max_allowed_packet = <%= node['mysql']['tunable']['max_allowed_packet'] %>
|
||||
|
||||
[mysql]
|
||||
#no-auto-rehash # faster start of mysql but no tab completition
|
||||
|
||||
[isamchk]
|
||||
key_buffer = <%= node['mysql']['tunable']['key_buffer'] %>
|
||||
|
||||
#
|
||||
# * NDB Cluster
|
||||
#
|
||||
# See /usr/share/doc/mysql-server-*/README.Debian for more information.
|
||||
#
|
||||
# The following configuration is read by the NDB Data Nodes (ndbd processes)
|
||||
# not from the NDB Management Nodes (ndb_mgmd processes).
|
||||
#
|
||||
# [MYSQL_CLUSTER]
|
||||
# ndb-connectstring=127.0.0.1
|
||||
|
||||
<% case node['platform'] -%>
|
||||
<% when "centos", "redhat", "fedora", "suse" -%>
|
||||
#
|
||||
# * BerkeleyDB
|
||||
#
|
||||
# Using BerkeleyDB is now discouraged as its support will cease in 5.1.12.
|
||||
skip-bdb
|
||||
# Default to using old password format for compatibility with mysql 3.x
|
||||
# clients (those using the mysqlclient10 compatibility package).
|
||||
old_passwords = <%= node['mysql']['old_passwords'] %>
|
||||
|
||||
<% else -%>
|
||||
#
|
||||
# * IMPORTANT: Additional settings that can override those from this file!
|
||||
# The files must end with '.cnf', otherwise they'll be ignored.
|
||||
#
|
||||
!includedir /etc/mysql/conf.d/
|
||||
<% end -%>
|
9
cookbooks/mysql/templates/default/mysql-server.seed.erb
Normal file
9
cookbooks/mysql/templates/default/mysql-server.seed.erb
Normal file
@ -0,0 +1,9 @@
|
||||
mysql-server-5.1 mysql-server/root_password_again password <%= node[:mysql][:server_root_password] %>
|
||||
mysql-server-5.1 mysql-server/root_password password <%= node[:mysql][:server_root_password] %>
|
||||
mysql-server-5.1 mysql-server/error_setting_password error
|
||||
mysql-server-5.1 mysql-server-5.1/nis_warning note
|
||||
mysql-server-5.1 mysql-server-5.1/really_downgrade boolean false
|
||||
mysql-server-5.1 mysql-server-5.1/start_on_boot boolean true
|
||||
mysql-server-5.1 mysql-server-5.1/postrm_remove_databases boolean false
|
||||
mysql-server-5.1 mysql-server/password_mismatch error
|
||||
mysql-server-5.1 mysql-server/no_upgrade_when_using_ndb error
|
3
cookbooks/mysql/templates/default/port_mysql.erb
Normal file
3
cookbooks/mysql/templates/default/port_mysql.erb
Normal file
@ -0,0 +1,3 @@
|
||||
# MySQL
|
||||
-A FWR -p tcp -m tcp --dport 3306 -j ACCEPT
|
||||
-A FWR -p udp -m udp --dport 3306 -j ACCEPT
|
61
cookbooks/mysql/templates/windows/my.cnf.erb
Normal file
61
cookbooks/mysql/templates/windows/my.cnf.erb
Normal file
@ -0,0 +1,61 @@
|
||||
#
|
||||
# Generated by Chef for <%= node['hostname'] %>
|
||||
#
|
||||
# Local modifications will be overwritten.
|
||||
#
|
||||
# The MySQL database server configuration file.
|
||||
#
|
||||
# One can use all long options that the program supports.
|
||||
# Run program with --help to get a list of available options and with
|
||||
# --print-defaults to see which it would actually understand and use.
|
||||
#
|
||||
# For explanations see
|
||||
# http://dev.mysql.com/doc/mysql/en/server-system-variables.html
|
||||
|
||||
# This will be passed to all mysql clients
|
||||
# It has been reported that passwords should be enclosed with ticks/quotes
|
||||
# escpecially if they contain "#" chars...
|
||||
[client]
|
||||
port = 3306
|
||||
|
||||
[mysql]
|
||||
default-character-set = latin1
|
||||
|
||||
[mysqld]
|
||||
#
|
||||
# * Basic Settings
|
||||
#
|
||||
port = 3306
|
||||
basedir = <%= node['mysql']['basedir'] %>
|
||||
datadir = <%= node['mysql']['data_dir'] %>
|
||||
character-set-server = latin1
|
||||
default-storage-engine = INNODB
|
||||
sql-mode = "STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
|
||||
|
||||
#
|
||||
# * Fine Tuning
|
||||
#
|
||||
thread_cache_size = <%= node['mysql']['tunable']['thread_cache_size'] %>
|
||||
max_connections = <%= node['mysql']['tunable']['max_connections'] %>
|
||||
table_cache = <%= node['mysql']['tunable']['table_cache'] %>
|
||||
query_cache_size = <%= node['mysql']['tunable']['query_cache_size'] %>
|
||||
tmp_table_size = 5M
|
||||
myisam_max_sort_file_size = 100G
|
||||
myisam_sort_buffer_size = 8M
|
||||
key_buffer_size = 8M
|
||||
read_buffer_size = 64K
|
||||
read_rnd_buffer_size = 256K
|
||||
sort_buffer_size = 212K
|
||||
|
||||
#
|
||||
# * InnoDB
|
||||
#
|
||||
# Read the manual for more InnoDB related options. There are many!
|
||||
# You might want to disable InnoDB to shrink the mysqld process by circa 100MB.
|
||||
#
|
||||
innodb_additional_mem_pool_size = 2M
|
||||
innodb_flush_log_at_trx_commit = 1
|
||||
innodb_log_buffer_size = 1M
|
||||
innodb_buffer_pool_size = <%= node['mysql']['tunable']['innodb_buffer_pool_size'] %>
|
||||
innodb_log_file_size = 10M
|
||||
innodb_thread_concurrency = 8
|
@ -1,4 +1,7 @@
|
||||
{
|
||||
"recipes": [ "nailgun::deps", "devops::deps" ]
|
||||
"recipes": [ "nailgun::deps", "devops::deps" ],
|
||||
"mysql": {
|
||||
"server_root_password": "ololo"
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -16,7 +16,7 @@ class TestCobbler:
|
||||
token = server.login('cobbler', 'cobbler')
|
||||
found = server.find_system({'name':'default'}, token)
|
||||
assert found[0]['name'] == 'default'
|
||||
|
||||
|
||||
def test_cobbler_alive(self):
|
||||
assert True
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user