Skip to content

Commit

Permalink
Add percona support, add kitchen and tests with serverspec and integr…
Browse files Browse the repository at this point in the history
…ate pull request /pull/13 with some changes to include percona and versions of databases. Use cookstyle instead of rubocop. (https://github.com/chef/cookstyle)
  • Loading branch information
Adrian Almenar committed Nov 7, 2016
1 parent 3ffe92f commit 8a1c508
Show file tree
Hide file tree
Showing 21 changed files with 367 additions and 40 deletions.
22 changes: 21 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,21 @@
.bundle
.vagrant
# Berksfile.lock
*~
*#
.#*
\#*#
.*.sw[a-z]
*.un~
/cookbooks

# Bundler
# Gemfile.lock
bin/*
.bundle/*

.kitchen/
.kitchen.local.yml

test/nodes

Berksfile.lock
65 changes: 65 additions & 0 deletions .kitchen.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
---
driver:
name: vagrant
require_chef_omnibus: true

platforms:
- name: ubuntu-16.04
driver_config:
box: bento/ubuntu-16.04
- name: debian-8
driver_config:
box: bento/debian-8.6

suites:
- name: mariadb-10.1
run_list:
- recipe[mysqld::mariadb_repository]
- recipe[mysqld::default]
attributes:
mysqld:
db_install: 'mariadb'
root_password: 'abcdef01234567890'
repository:
mariadb:
version: '10.1'
- name: mariadb-10.2
run_list:
- recipe[mysqld::mariadb_repository]
- recipe[mysqld::default]
attributes:
mysqld:
db_install: 'mariadb'
root_password: 'abcdef01234567890'
repository:
mariadb:
version: '10.2'
- name: percona-5.6
run_list:
- recipe[mysqld::percona_repository]
- recipe[mysqld::default]
attributes:
mysqld:
db_install: 'percona'
root_password: 'abcdef01234567890'
repository:
percona:
version: '5.6'
- name: percona-5.7
run_list:
- recipe[mysqld::percona_repository]
- recipe[mysqld::default]
attributes:
mysqld:
db_install: 'percona'
root_password: 'abcdef01234567890'
repository:
percona:
version: '5.7'
- name: mysql-from-packages
run_list:
- recipe[mysqld::default]
attributes:
mysqld:
db_install: 'mysql'
root_password: 'abcdef01234567890'
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ cache: bundler
rvm:
- 2.3.1
script:
- bundle exec rubocop
- bundle exec cookstyle
- cd spec/recipes && bundle exec rspec *.rb; cd -
3 changes: 3 additions & 0 deletions Berksfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
source 'https://supermarket.chef.io'

metadata
3 changes: 2 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
source 'https://rubygems.org'

gem 'rubocop'
gem 'cookstyle'
gem 'foodcritic'
gem 'rspec'
gem 'chefspec'
gem 'berkshelf'
57 changes: 41 additions & 16 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ GEM
specs:
addressable (2.4.0)
ast (2.3.0)
backports (3.6.8)
berkshelf (5.1.0)
addressable (~> 2.3, >= 2.3.4)
berkshelf-api-client (>= 2.0.2, < 4.0)
Expand Down Expand Up @@ -37,10 +38,10 @@ GEM
celluloid-io (0.16.2)
celluloid (>= 0.16.0)
nio4r (>= 1.1.0)
chef (12.14.89)
chef (12.15.19)
addressable
bundler (>= 1.10)
chef-config (= 12.14.89)
chef-config (= 12.15.19)
chef-zero (>= 4.8)
diff-lcs (~> 1.2, >= 1.2.4)
erubis (~> 2.7)
Expand All @@ -66,7 +67,7 @@ GEM
specinfra (~> 2.10)
syslog-logger (~> 1.6)
uuidtools (~> 2.1.5)
chef-config (12.14.89)
chef-config (12.15.19)
addressable
fuzzyurl
mixlib-config (~> 2.0)
Expand All @@ -77,21 +78,35 @@ GEM
mixlib-log (~> 1.3)
rack (~> 2.0)
uuidtools (~> 2.1)
chefspec (5.2.0)
chefspec (5.3.0)
chef (>= 12.0)
fauxhai (~> 3.6)
rspec (~> 3.0)
cleanroom (1.0.0)
cookstyle (0.0.1)
rubocop (= 0.39.0)
cucumber-core (2.0.0)
backports (~> 3.6)
gherkin (~> 4.0)
diff-lcs (1.2.5)
erubis (2.7.0)
faraday (0.9.2)
multipart-post (>= 1.2, < 3)
fauxhai (3.9.0)
fauxhai (3.10.0)
net-ssh
ffi (1.9.14)
ffi-yajl (2.3.0)
libyajl2 (~> 1.2)
foodcritic (8.1.0)
cucumber-core (>= 1.3)
erubis
nokogiri (>= 1.5, < 2.0)
rake
rufus-lru (~> 1.0)
treetop (~> 1.4)
yajl-ruby (~> 1.1)
fuzzyurl (0.9.0)
gherkin (4.0.0)
hashie (3.4.6)
highline (1.7.8)
hitimes (1.2.4)
Expand All @@ -100,6 +115,7 @@ GEM
ipaddress (0.8.3)
json (2.0.2)
libyajl2 (1.2.0)
mini_portile2 (2.1.0)
minitar (0.5.4)
mixlib-archive (0.2.0)
mixlib-log
Expand All @@ -109,7 +125,7 @@ GEM
mixlib-config (2.2.4)
mixlib-log (1.7.1)
mixlib-shellout (2.2.7)
molinillo (0.5.1)
molinillo (0.5.3)
multi_json (1.12.1)
multipart-post (2.0.0)
net-scp (1.2.1)
Expand All @@ -124,9 +140,11 @@ GEM
net-ssh-gateway (>= 1.2.0)
net-telnet (0.1.1)
nio4r (1.2.1)
octokit (4.3.0)
nokogiri (1.6.8.1)
mini_portile2 (~> 2.1.0)
octokit (4.4.1)
sawyer (~> 0.7.0, >= 0.5.3)
ohai (8.20.0)
ohai (8.21.0)
chef-config (>= 12.5.0.alpha.1, < 13)
ffi (~> 1.9)
ffi-yajl (~> 2.2)
Expand All @@ -141,10 +159,12 @@ GEM
parser (2.3.1.4)
ast (~> 2.2)
plist (3.2.0)
polyglot (0.3.5)
powerpack (0.1.1)
proxifier (1.0.3)
rack (2.0.1)
rainbow (2.1.0)
rake (11.3.0)
retryable (2.0.4)
ridley (5.1.0)
addressable
Expand All @@ -168,7 +188,7 @@ GEM
rspec-core (~> 3.5.0)
rspec-expectations (~> 3.5.0)
rspec-mocks (~> 3.5.0)
rspec-core (3.5.3)
rspec-core (3.5.4)
rspec-support (~> 3.5.0)
rspec-expectations (3.5.0)
diff-lcs (>= 1.2.0, < 2.0)
Expand All @@ -183,27 +203,28 @@ GEM
rspec_junit_formatter (0.2.3)
builder (< 4)
rspec-core (>= 2, < 4, != 2.12.0)
rubocop (0.43.0)
parser (>= 2.3.1.1, < 3.0)
rubocop (0.39.0)
parser (>= 2.3.0.7, < 3.0)
powerpack (~> 0.1)
rainbow (>= 1.99.1, < 3.0)
ruby-progressbar (~> 1.7)
unicode-display_width (~> 1.0, >= 1.0.1)
ruby-progressbar (1.8.1)
rufus-lru (1.1.0)
sawyer (0.7.0)
addressable (>= 2.3.5, < 2.5)
faraday (~> 0.8, < 0.10)
semverse (2.0.0)
serverspec (2.36.1)
serverspec (2.37.2)
multi_json
rspec (~> 3.0)
rspec-its
specinfra (~> 2.53)
sfl (2.2)
sfl (2.3)
solve (3.0.1)
molinillo (~> 0.4)
semverse (>= 1.1, < 3.0)
specinfra (2.63.1)
specinfra (2.66.0)
net-scp
net-ssh (>= 2.7, < 4.0)
net-telnet
Expand All @@ -213,21 +234,25 @@ GEM
thor (0.19.1)
timers (4.0.4)
hitimes
treetop (1.6.8)
polyglot (~> 0.3)
unicode-display_width (1.1.1)
uuidtools (2.1.5)
varia_model (0.6.0)
buff-extensions (~> 2.0)
hashie (>= 2.0.2, < 4.0.0)
wmi-lite (1.0.0)
yajl-ruby (1.3.0)

PLATFORMS
ruby

DEPENDENCIES
berkshelf
chefspec
cookstyle
foodcritic
rspec
rubocop

BUNDLED WITH
1.12.5
1.13.2
26 changes: 26 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env rake

require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:unit) do |t|
t.pattern = ['test/unit/**/*_spec.rb']
end

require 'foodcritic'
FoodCritic::Rake::LintTask.new do |t|
t.options = { fail_tags: ['any'] }
end

require 'cookstyle'
require 'rubocop/rake_task'
RuboCop::RakeTask.new do |task|
task.options << '--display-cop-names'
end

begin
require 'kitchen/rake_tasks'
Kitchen::RakeTasks.new
rescue LoadError
puts '>>>>> Kitchen gem not loaded, omitting tasks' unless ENV['CI']
end

task default: [:foodcritic, :rubocop]
46 changes: 38 additions & 8 deletions attributes/defaults.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,29 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#

# Attribute that defines whether MariaDB or MySQL should be used
default['mysqld']['use_mariadb'] = true
# Attribute that defines whether MariaDB, MySQL or Percona should be used
default['mysqld']['db_install'] = 'mariadb'

# Default packages to install
default['mysqld']['mysql_packages'] = %w(mysql-server)
default['mysqld']['mariadb_packages'] = %w(mariadb-server)
default['mysqld']['mariadb_galera_packages'] = %w(mariadb-galera-server)
default['mysqld']['mysql']['packages'] = %w(mysql-server)
default['mysqld']['mariadb']['packages'] = %w(mariadb-server)
default['mysqld']['mariadb']['galera_packages'] = %w(mariadb-galera-server)

# MariaDB repository configuration
default['mysqld']['repository']['version'] = '10.1'
default['mysqld']['repository']['mirror'] = 'http://ftp.hosteurope.de/mirror/mariadb.org/repo'
default['mysqld']['repository']['mariadb']['version'] = '10.1'
default['mysqld']['repository']['mariadb']['mirror'] = 'http://ftp.hosteurope.de/mirror/mariadb.org/repo'

# Percona repository configuration
default['mysqld']['repository']['percona']['version'] = '5.7'
default['mysqld']['repository']['percona']['mirror'] = 'http://repo.percona.com/apt'

if node['mysqld']['repository']['percona']['version'] == '5.7'
default['mysqld']['percona']['packages'] = %w(percona-server-server-5.7)
elsif node['mysqld']['repository']['percona']['version'] == '5.6'
default['mysqld']['percona']['packages'] = %w(percona-server-server-5.6)
else
default['mysqld']['percona']['packages'] = %w(percona-server-server)
end

# Configure services
default['mysqld']['my.cnf_path'] = '/etc/mysql/my.cnf'
Expand All @@ -42,7 +54,7 @@
default['mysqld']['auth'] = '--defaults-file=/etc/mysql/debian.cnf'

# Options, only set by default/ available on MariaDB
if node['mysqld']['use_mariadb']
if node['mysqld']['db_install'] == 'mariadb'
# Charset options are only set on MariaDB by default
default['mysqld']['my.cnf']['client']['default-character-set'] = 'utf8mb4'
default['mysqld']['my.cnf']['mysql']['default-character-set'] = 'utf8mb4'
Expand All @@ -54,6 +66,24 @@
default['mysqld']['my.cnf']['mysqld_safe']['skip_log_error'] = true
end

# Password columns for user passwords
case node['mysqld']['db_install']
when 'mariadb'
default['mysqld']['pwd_col'] = 'Password'
when 'percona'
if node['mysqld']['repository']['percona']['version'] == '5.6'
default['mysqld']['pwd_col'] = 'Password'
else
default['mysqld']['pwd_col'] = 'authentication_string'
end
when 'mysql'
if node['platform'] == 'debian' && node['platform_version'].to_f < 9.0
default['mysqld']['pwd_col'] = 'Password'
else
default['mysqld']['pwd_col'] = 'authentication_string'
end
end

default['mysqld']['my.cnf']['mysqld']['user'] = 'mysql'
default['mysqld']['my.cnf']['mysqld']['port'] = 3306
default['mysqld']['my.cnf']['mysqld']['lc-messages-dir'] = '/usr/share/mysql'
Expand Down
3 changes: 3 additions & 0 deletions metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,7 @@
description 'Installs/Configures mysqld'
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version '2.1.0'
issues_url 'https://github.com/chr4-cookbooks/mysqld/issues'
source_url 'https://github.com/chr4-cookbooks/mysqld/'

depends 'apt'
Loading

0 comments on commit 8a1c508

Please sign in to comment.