-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 7a0ac89
Showing
8 changed files
with
293 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
jku-mysql CHANGELOG | ||
====================== | ||
|
||
This file is used to list changes made in each version of the jku-mysql cookbook. | ||
|
||
0.1.0 | ||
----- | ||
- [your_name] - Initial release of jku-mysql | ||
|
||
- - - | ||
Check the [Markdown Syntax Guide](http://daringfireball.net/projects/markdown/syntax) for help with Markdown. | ||
|
||
The [Github Flavored Markdown page](http://github.github.com/github-flavored-markdown/) describes the differences between markdown on github and standard markdown. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
jku-mysql Cookbook | ||
===================== | ||
TODO: Enter the cookbook description here. | ||
|
||
e.g. | ||
This cookbook makes your favorite breakfast sandwich. | ||
|
||
Requirements | ||
------------ | ||
TODO: List your cookbook requirements. Be sure to include any requirements this cookbook has on platforms, libraries, other cookbooks, packages, operating systems, etc. | ||
|
||
e.g. | ||
#### packages | ||
- `toaster` - jku-mysql needs toaster to brown your bagel. | ||
|
||
Attributes | ||
---------- | ||
TODO: List your cookbook attributes here. | ||
|
||
e.g. | ||
#### jku-mysql::default | ||
<table> | ||
<tr> | ||
<th>Key</th> | ||
<th>Type</th> | ||
<th>Description</th> | ||
<th>Default</th> | ||
</tr> | ||
<tr> | ||
<td><tt>['jku-mysql']['bacon']</tt></td> | ||
<td>Boolean</td> | ||
<td>whether to include bacon</td> | ||
<td><tt>true</tt></td> | ||
</tr> | ||
</table> | ||
|
||
Usage | ||
----- | ||
#### jku-mysql::default | ||
TODO: Write usage instructions for each cookbook. | ||
|
||
e.g. | ||
Just include `jku-mysql` in your node's `run_list`: | ||
|
||
```json | ||
{ | ||
"name":"my_node", | ||
"run_list": [ | ||
"recipe[jku-mysql]" | ||
] | ||
} | ||
``` | ||
|
||
Contributing | ||
------------ | ||
TODO: (optional) If this is a public cookbook, detail the process for contributing. If this is a private cookbook, remove this section. | ||
|
||
e.g. | ||
1. Fork the repository on Github | ||
2. Create a named feature branch (like `add_component_x`) | ||
3. Write your change | ||
4. Write tests for your change (if applicable) | ||
5. Run the tests, ensuring they all pass | ||
6. Submit a Pull Request using Github | ||
|
||
License and Authors | ||
------------------- | ||
Authors: TODO: List authors |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
default['jku-mysql'] = { | ||
'mysql' => { | ||
'master' => { | ||
'root_password' => 'th1s1sm0r3s3cr3t-100!', | ||
'version' => '5.6', | ||
'port' => '3306', | ||
'host' => '127.0.0.1', | ||
'user' => 'default_user', | ||
'user_password' => 'd3f4ult_p455w0rd1982', | ||
'db_name' => 'db1', | ||
'db_dump' => 'file_from_the_recipe_to_be_imported' | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# ************************************************************ | ||
# Sequel Pro SQL dump | ||
# Version 4096 | ||
# | ||
# http://www.sequelpro.com/ | ||
# http://code.google.com/p/sequel-pro/ | ||
# | ||
# Host: 192.168.5.5 (MySQL 5.6.19-0ubuntu0.14.04.1) | ||
# Database: db1 | ||
# Generation Time: 2015-09-22 11:06:31 +0000 | ||
# ************************************************************ | ||
|
||
|
||
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; | ||
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; | ||
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; | ||
/*!40101 SET NAMES utf8 */; | ||
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; | ||
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; | ||
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; | ||
|
||
|
||
# Dump of table data | ||
# ------------------------------------------------------------ | ||
|
||
DROP TABLE IF EXISTS `data`; | ||
|
||
CREATE TABLE `data` ( | ||
`id` int(11) unsigned NOT NULL AUTO_INCREMENT, | ||
PRIMARY KEY (`id`) | ||
) ENGINE=InnoDB DEFAULT CHARSET=utf8; | ||
|
||
LOCK TABLES `data` WRITE; | ||
/*!40000 ALTER TABLE `data` DISABLE KEYS */; | ||
|
||
INSERT INTO `data` (`id`) | ||
VALUES | ||
(666), | ||
(1982); | ||
|
||
/*!40000 ALTER TABLE `data` ENABLE KEYS */; | ||
UNLOCK TABLES; | ||
|
||
|
||
|
||
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; | ||
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; | ||
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; | ||
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; | ||
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; | ||
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; | ||
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; | ||
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; | ||
/*!40101 SET NAMES utf8 */; | ||
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; | ||
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; | ||
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; | ||
|
||
# Dump of table data | ||
# ------------------------------------------------------------ | ||
|
||
DROP TABLE IF EXISTS `data`; | ||
|
||
CREATE TABLE `data` ( | ||
`id` int(11) unsigned NOT NULL AUTO_INCREMENT, | ||
PRIMARY KEY (`id`) | ||
) ENGINE=InnoDB DEFAULT CHARSET=utf8; | ||
|
||
LOCK TABLES `data` WRITE; | ||
/*!40000 ALTER TABLE `data` DISABLE KEYS */; | ||
|
||
INSERT INTO `data` (`id`) | ||
VALUES | ||
(666), | ||
(1982); | ||
|
||
/*!40000 ALTER TABLE `data` ENABLE KEYS */; | ||
UNLOCK TABLES; | ||
|
||
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; | ||
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; | ||
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; | ||
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; | ||
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; | ||
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
name 'jku-mysql' | ||
maintainer 'Jakub Kułak' | ||
maintainer_email 'jakub.kulak@gmail.com' | ||
license 'Apache 2.0' | ||
description 'Installs/Configures jku-mysql' | ||
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) | ||
version '0.1.0' | ||
|
||
depends 'mysql2_chef_gem', '~> 1.0.2' | ||
depends 'database', '~> 4.0.9' | ||
depends 'mysql', '~> 6.1.0' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# | ||
# Cookbook Name:: jku-mysql | ||
# Recipe:: default | ||
# | ||
# Copyright 2015, Jakub Kułak | ||
# | ||
# 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 'jku-mysql::mysql_server' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
# | ||
# Cookbook Name:: jku-mysql | ||
# Recipe:: default | ||
# | ||
# Copyright 2015, Jakub Kułak | ||
# | ||
# 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. | ||
# | ||
|
||
# Install required mysql2 gem to use mysql2 | ||
mysql2_chef_gem 'default' do | ||
gem_version '0.3.17' | ||
action :install | ||
end | ||
|
||
# Create a mysql_services | ||
node['jku-mysql']['mysql'].each do |server_data| | ||
|
||
name = server_data[0] | ||
server = server_data[1] | ||
|
||
mysql_service name do | ||
port server['port'] | ||
version server['version'] | ||
initial_root_password server['root_password'] | ||
action [:create, :start] | ||
end | ||
|
||
# Define server connection information | ||
mysql_connection_info = { | ||
:host => server['host'], | ||
:username => 'root', | ||
:password => server['root_password'] | ||
} | ||
|
||
# Grant privilages | ||
mysql_database_user 'root' do | ||
connection mysql_connection_info | ||
password server['root_password'] | ||
host '%' | ||
action :grant | ||
end | ||
|
||
# Create a mysql database | ||
mysql_database server['db_name'] do | ||
connection mysql_connection_info | ||
action :create | ||
end | ||
|
||
# Create user and grant privilages | ||
mysql_database_user server['user'] do | ||
connection mysql_connection_info | ||
password server['user_password'] | ||
database_name server['db_name'] | ||
host '%' | ||
privileges [:select, :insert, :update, :delete, :create, :drop, :index, :alter] | ||
action :grant | ||
end | ||
|
||
# Copy dump file | ||
cookbook_file "/tmp/#{server['db_dump']}" do | ||
mode 00755 | ||
end | ||
|
||
# Import an sql dump | ||
execute 'import' do | ||
command "mysql -h 127.0.0.1 -u root -p#{server['root_password']} #{server['db_name']} < /tmp/#{server['db_dump']}" | ||
action :run | ||
end | ||
|
||
end |