Skip to content

Commit

Permalink
Merge pull request #1 from sinfomicien/0.2.x
Browse files Browse the repository at this point in the history
0.2.x
  • Loading branch information
sinfomicien committed Sep 8, 2014
2 parents a488901 + 496baa0 commit 418ad5b
Show file tree
Hide file tree
Showing 25 changed files with 351 additions and 225 deletions.
5 changes: 3 additions & 2 deletions .kitchen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ platforms:
- name: debian-7.6
driver_config:
box: chef/debian-7.6
- name: ubuntu-12.04
- name: centos-6.4

suites:
- name: default
run_list:
- recipe[mariadb::default]
attributes:
mariadb:
apt:
use_default_repository: true
use_default_repository: true
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@ mariadb CHANGELOG

This file is used to list changes made in each version of the mariadb cookbook.

0.2.0
-----
- [nicolas.blanc] - Add rpm/yum management
- [nicolas.blanc] - Refactor the whole recipes list and management to ease it
- [nicolas.blanc] - Correct the Documentation
- [nicolas.blanc] - Rename the provider (from extraconf to configuration), and add matchers to it
- [nicolas.blanc] - Add a recipe to manage client only installation
- [nicolas.blanc] - Refactor all tests to manage new platform (centos/redhat/fedora)

0.1.8
-----
- [nicolas.blanc] - Add ignore-failure to debian grants correct, as it can break on initial setup
Expand Down
23 changes: 12 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ MariaDB Cookbook
Description
-----------

This cookbook contains all the stuffs to install and configure a mariadb server on a dpkg compliant system (typically debian)
This cookbook contains all the stuffs to install and configure a mariadb server on a dpkg/apt compliant system (typically debian), or a rpm/yum compliant system (typically centos)


Requirements
------------

#### repository
- `mariadb` - This cookbook need that you have a valid apt repository installed with th mariadn official package
- `mariadb` - This cookbook need that you have a valid apt repository installed with the mariadb official packages

#### packages
- `percona-xtrabackup` - if you want to use the xtrabckup SST Auth for galera cluster.
Expand All @@ -22,7 +22,8 @@ Requirements

#### operating system
- `debian` - this cookbook is fully tested on debian
- `ubuntu` - not tested on ubuntu, but should work
- `ubuntu` - not fully tested on ubuntu, but should work
- `centos` - not fully tested on centos, but should work

Attributes
----------
Expand All @@ -36,10 +37,10 @@ Attributes
<th>Default</th>
</tr>
<tr>
<td><tt>['mariadb']['bacon']</tt></td>
<td>Boolean</td>
<td>whether to include bacon</td>
<td><tt>true</tt></td>
<td><tt>['mariadb']['install']['version']</tt></td>
<td>String</td>
<td>Version to install (currently 10.0 et 5.5)</td>
<td><tt>10.0</tt></td>
</tr>
</table>

Expand All @@ -50,10 +51,10 @@ To install a default server for mariadb choose the version you want (MariaDB 5.5

List of availables recipes:

- mariadb::10
- mariadb::55
- mariadb::galera10
- mariadb::galera55
- mariadb::default (just call server recipe with default options)
- mariadb::server
- mariadb::galera
- mariadb::client

Contributing
------------
Expand Down
36 changes: 24 additions & 12 deletions attributes/default.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,24 @@
# platform dependent attributes
case node['platform']
when 'redhat', 'centos', 'fedora'
default['mariadb']['configuration']['path'] = '/etc'
default['mariadb']['configuration']['includedir'] = '/etc/my.cnf.d'
default['mariadb']['mysqld']['socket'] = '/var/lib/mysql/mysql.sock'
default['mariadb']['client']['socket'] = '/var/lib/mysql/mysql.sock'
default['mariadb']['mysqld_safe']['socket'] = '/var/lib/mysql/mysql.sock'
else
default['mariadb']['configuration']['path'] = '/etc/mysql'
default['mariadb']['configuration']['includedir'] = '/etc/mysql/conf.d'
default['mariadb']['mysqld']['socket'] = '/var/run/mysqld/mysqld.sock'
default['mariadb']['mysqld']['pid_file'] = '/var/run/mysqld/mysqld.pid'
default['mariadb']['client']['socket'] = '/var/run/mysqld/mysqld.sock'
default['mariadb']['mysqld_safe']['socket'] = '/var/run/mysqld/mysqld.sock'
end

#
# mysqld default configuration
#
default['mariadb']['mysqld']['user'] = 'mysql'
default['mariadb']['mysqld']['pid_file'] = '/var/run/mysqld' + \
'/mysqld.pid'
default['mariadb']['mysqld']['socket'] = '/var/run/mysqld' + \
'/mysqld.sock'
default['mariadb']['mysqld']['port'] = '3306'
default['mariadb']['mysqld']['basedir'] = '/usr'
default['mariadb']['mysqld']['datadir'] = '/var/lib/mysql'
Expand Down Expand Up @@ -87,18 +100,16 @@
#
# mysqld_safe default configuration
#
default['mariadb']['mysqld_safe']['socket'] = '/var/run/mysqld/mysqld.sock'
default['mariadb']['mysqld_safe']['options'] = {}

#
# client default configuration
#
default['mariadb']['client']['port'] = 3306
default['mariadb']['client']['socket'] = '/var/run/mysqld/mysqld.sock'
default['mariadb']['client']['options'] = {}

#
# debian specific conficguration
# debian specific configuration
#
default['mariadb']['debian']['user'] = 'debian-sys-maint'
default['mariadb']['debian']['password'] = 'please-change-me'
Expand All @@ -107,11 +118,12 @@
#
# mariadb default install configuration
#
# install valid values are 'apt'
# (only apt for now, and 'yum' or 'from_source' in the future)
default['mariadb']['install'] = 'apt'
# install valid value is 'package',
# hope to have 'from_source' in the near future
default['mariadb']['install']['type'] = 'package'
default['mariadb']['install']['version'] = '10.0'

#
# apt default configuration
# package(apt or yum) default configuration
#
default['mariadb']['apt']['use_default_repository'] = false
default['mariadb']['use_default_repository'] = false
11 changes: 11 additions & 0 deletions libraries/matchers.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
if defined?(ChefSpec)
def add_mariadb_configuration(resource_name)
ChefSpec::Matchers::ResourceMatcher
.new(:mariadb_configuration, :add, resource_name)
end

def remove_mariadb_configuration(resource_name)
ChefSpec::Matchers::ResourceMatcher
.new(:mariadb_configuration, :remove, resource_name)
end
end
7 changes: 6 additions & 1 deletion metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
license 'Apache 2.0'
description 'Installs/Configures MariaDB'
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version '0.1.8'
version '0.2.0'

supports 'ubuntu'
supports 'debian', '~> 7'
supports 'centos', '~> 6'

depends 'apt'
depends 'yum'
14 changes: 9 additions & 5 deletions providers/extraconf.rb → providers/configuration.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#
# Cookbook Name:: mariadb
# Provider:: extraconf
# Provider:: configuration
#

use_inline_resources if defined?(use_inline_resources)
Expand All @@ -14,7 +14,9 @@ def whyrun_supported?
section: new_resource.section,
options: new_resource.option
}
template "/etc/mysql/conf.d/#{new_resource.name}.cnf" do
template node['mariadb']['configuration']['includedir'] + \
'/' + new_resource.name + '.cnf' do
source 'conf.d.generic.erb'
owner 'root'
group 'mysql'
mode '0640'
Expand All @@ -23,10 +25,12 @@ def whyrun_supported?
end

action :remove do
if ::File.exist?("/etc/mysql/conf.d/#{new_resource.name}.cnf")
if ::File.exist?(node['mariadb']['configuration']['includedir'] + \
'/' + new_resource.name + '.cnf')
Chef::Log.info "Removing #{new_resource.name} repository from " + \
'/etc/mysql/conf.d/'
file "/etc/mysql/conf.d/#{new_resource.name}.cnf" do
node['mariadb']['configuration']['includedir']
file node['mariadb']['configuration']['includedir'] + \
'/' + new_resource.name + '.cnf' do
action :delete
end
end
Expand Down
26 changes: 0 additions & 26 deletions recipes/55.rb

This file was deleted.

22 changes: 16 additions & 6 deletions recipes/galera55.rb → recipes/client.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#
# Cookbook Name:: mariadb
# Recipe:: default
# Recipe:: client
#
# Copyright 2014, blablacar.com
#
Expand All @@ -17,10 +17,20 @@
# limitations under the License.
#

include_recipe "#{cookbook_name}::repository55"
case node['mariadb']['install']['type']
when 'package'
include_recipe "#{cookbook_name}::repository"

package 'mariadb-galera-server-5.5' do
action :install
case node['platform']
when 'debian', 'ubuntu'
package "mariadb-client-#{node['mariadb']['install']['version']}" do
action :install
end
when 'redhat', 'centos', 'fedora'
package 'MariaDB-client' do
action :install
end
end
when 'from_source'
# To be filled as soon as possible
end

include_recipe "#{cookbook_name}::galera"
33 changes: 12 additions & 21 deletions recipes/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# limitations under the License.
#

template '/etc/mysql/my.cnf' do
template node['mariadb']['configuration']['path'] + '/my.cnf' do
source 'my.cnf.erb'
owner 'root'
group 'root'
Expand Down Expand Up @@ -56,7 +56,7 @@
node['mariadb']['innodb']['log_buffer_size']
innodb_options['innodb_file_per_table'] = \
node['mariadb']['innodb']['file_per_table']
innodb_options['innodb_open_files'] = node['mariadb']['innodb']['open_files']
innodb_options['innodb_open_files'] = node['mariadb']['innodb']['open_files']
innodb_options['innodb_io_capacity'] = \
node['mariadb']['innodb']['io_capacity']
innodb_options['innodb_flush_method'] = \
Expand All @@ -65,19 +65,14 @@
innodb_options[key] = value
end

template '/etc/mysql/conf.d/innodb.cnf' do
source 'conf.d.generic.erb'
variables(
section: 'mysqld',
options: innodb_options
)
owner 'root'
group 'mysql'
mode '0640'
mariadb_configuration 'innodb' do
section 'mysqld'
option innodb_options
action :add
end

replication_opts = {}
replication_opts['log_bin'] = node['mariadb']['replication']['log_bin']
replication_opts['log_bin'] = node['mariadb']['replication']['log_bin']
replication_opts['log_bin_index'] = \
node['mariadb']['replication']['log_bin_index']
replication_opts['expire_logs_days'] = \
Expand All @@ -92,13 +87,9 @@
replication_opts[key] = value
end
end
template '/etc/mysql/conf.d/replication.cnf' do
source 'conf.d.generic.erb'
variables(
section: 'mysqld',
options: replication_opts
)
owner 'root'
group 'mysql'
mode '0640'

mariadb_configuration 'replication' do
section 'mysqld'
option replication_opts
action :add
end
2 changes: 1 addition & 1 deletion recipes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@
# limitations under the License.
#

include_recipe "#{cookbook_name}::10"
include_recipe "#{cookbook_name}::server"
Loading

0 comments on commit 418ad5b

Please sign in to comment.