forked from till/easybib-cookbooks
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request till#783 from till/t/mysql-improvements
T/mysql improvements
- Loading branch information
Showing
211 changed files
with
23,469 additions
and
491 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
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
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
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
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,3 @@ | ||
# ies-mysql | ||
|
||
A wrapper cookbook to setup MySQL Server & Client in development environments. |
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,24 @@ | ||
default['ies-mysql'] = {} | ||
default['ies-mysql']['version'] = '5.6' | ||
|
||
default['ies-mysql']['server-config'] = { | ||
'user' => 'root', | ||
'password' => '', | ||
'port' => 3306, | ||
'bind-address' => '0.0.0.0', | ||
'instance-name' => 'vagrant' | ||
} | ||
|
||
default['ies-mysql']['mysqld-config'] = { | ||
'interactive_timeout' => 300, | ||
'slow_query_log' => '1', | ||
'slow_query_log_file' => '/var/log/mysql/log-slow-queries.log', | ||
'log_queries_not_using_indexes' => '1', | ||
'log_slow_admin_statements' => '1', | ||
'long_query_time' => 5, | ||
'wait_timeout' => 60, | ||
'innodb_buffer_pool_size' => '512M', | ||
'innodb_flush_log_at_trx_commit' => 0, | ||
'innodb_flush_method' => 'O_DIRECT', | ||
'skip_name_resolve' => '1' | ||
} |
File renamed without changes.
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,8 @@ | ||
name 'ies-mysql' | ||
|
||
description 'A wrapper recipe to install and configure MySQL Server and client.' | ||
|
||
supports 'ubuntu' | ||
|
||
depends 'mysql' | ||
depends 'easybib' |
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,4 @@ | ||
mysql_client node['ies-mysql']['server-config']['instance-name'] do | ||
version node['ies-mysql'].fetch('version', '5.6') | ||
action :create | ||
end |
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,41 @@ | ||
mysql_version = node['ies-mysql'].fetch('version', '5.6') | ||
|
||
server_config = node['ies-mysql']['server-config'] | ||
|
||
mysql_service server_config['instance-name'] do | ||
version mysql_version | ||
bind_address server_config['bind-address'] | ||
port server_config['port'] | ||
initial_root_password server_config['password'] | ||
provider Chef::Provider::MysqlServiceUpstart | ||
action [:create, :start] | ||
end | ||
|
||
mysql_client server_config['instance-name'] do | ||
version mysql_version | ||
action :create | ||
end | ||
|
||
include_recipe 'ies-mysql::client' | ||
|
||
config = node['ies-mysql']['mysqld-config'] | ||
|
||
file config['slow_query_log_file'] do | ||
owner 'mysql' | ||
group 'mysql' | ||
action :create_if_missing | ||
only_if do | ||
config['slow_query_log_file'] | ||
end | ||
end | ||
|
||
instance = node['ies-mysql']['server-config']['instance-name'] | ||
|
||
mysql_config 'vagrant-settings' do | ||
instance instance | ||
source 'vagrant.cnf.erb' | ||
variables( | ||
:config => config | ||
) | ||
notifies :restart, "mysql_service[#{instance}]" | ||
end |
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,22 @@ | ||
Chef::Resource.send(:include, EasyBib) | ||
|
||
# Grant root access from *! | ||
# Obviously not a good idea in production. | ||
|
||
cookbook_file '/tmp/grant.sql' do | ||
source 'grant.sql' | ||
mode '0600' | ||
not_if { is_aws(node) } | ||
end | ||
|
||
server_config = node['ies-mysql']['server-config'] | ||
|
||
mysql_command = "mysql -u #{server_config['user']}" | ||
mysql_command += " -p#{server_config['password']}" unless server_config['password'].empty? | ||
mysql_command += ' -h 127.0.0.1' | ||
mysql_command += ' < /tmp/grant.sql' | ||
|
||
execute 'open mysql to the world' do | ||
command mysql_command | ||
not_if { is_aws(node) } | ||
end |
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 @@ | ||
require 'chefspec' | ||
|
||
describe 'ies-mysql::client' do | ||
let(:runner) do | ||
ChefSpec::Runner.new(:log_level => :error) | ||
end | ||
|
||
let(:chef_run) { runner.converge(described_recipe) } | ||
|
||
it 'the client' do | ||
expect(chef_run).to create_mysql_client('vagrant') | ||
end | ||
end |
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 @@ | ||
require 'chefspec' | ||
|
||
describe 'ies-mysql::default' do | ||
let(:runner) do | ||
ChefSpec::Runner.new(:log_level => :error) | ||
end | ||
|
||
let(:chef_run) { runner.converge(described_recipe) } | ||
|
||
it 'it installs the server and the client' do | ||
expect(chef_run).to create_mysql_service('vagrant') | ||
|
||
expect(chef_run).to include_recipe 'ies-mysql::client' | ||
end | ||
|
||
it 'it configures mysql' do | ||
expect(chef_run).to create_file_if_missing('/var/log/mysql/log-slow-queries.log') | ||
expect(chef_run).to create_mysql_config('vagrant-settings') | ||
end | ||
end |
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,28 @@ | ||
require 'chefspec' | ||
|
||
describe 'ies-mysql::dev' do | ||
let(:runner) do | ||
ChefSpec::Runner.new(:log_level => :error) | ||
end | ||
|
||
let(:chef_run) { runner.converge(described_recipe) } | ||
let(:node) { runner.node } | ||
|
||
describe 'local/vagrant' do | ||
it 'it does execute the recipe' do | ||
expect(chef_run).to create_cookbook_file('/tmp/grant.sql') | ||
expect(chef_run).to run_execute('open mysql to the world') | ||
end | ||
end | ||
|
||
describe 'AWS' do | ||
before do | ||
node.set['opsworks'] = {} | ||
end | ||
|
||
it 'it does not execute the recipe' do | ||
expect(chef_run).not_to create_cookbook_file('/tmp/grant.sql') | ||
expect(chef_run).not_to run_execute('open mysql to the world') | ||
end | ||
end | ||
end |
File renamed without changes.
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,5 @@ | ||
engines: | ||
foodcritic: | ||
enabled: true | ||
rubocop: | ||
enabled: true |
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,46 @@ | ||
*.gem | ||
.zero-knife.rb | ||
*.rbc | ||
.bundle | ||
.config | ||
coverage | ||
InstalledFiles | ||
lib/bundler/man | ||
pkg | ||
rdoc | ||
spec/reports | ||
test/tmp | ||
test/version_tmp | ||
tmp | ||
Gemfile.lock | ||
_Store | ||
*~ | ||
*# | ||
.#* | ||
\#*# | ||
.*.sw[a-z] | ||
*.un~ | ||
*.tmp | ||
*.bk | ||
*.bkup | ||
.ruby-version | ||
.ruby-gemset | ||
.rvmrc | ||
|
||
# YARD artifacts | ||
.yardoc | ||
_yardoc | ||
doc/ | ||
.idea | ||
|
||
#chef stuff | ||
Berksfile.lock | ||
.kitchen | ||
.kitchen.local.yml | ||
vendor/ | ||
.coverage/ | ||
|
||
#vagrant stuff | ||
.vagrant/ | ||
.vagrant.d/ | ||
.kitchen/ |
Oops, something went wrong.