Skip to content

Commit

Permalink
Add 2 importants new attributes
Browse files Browse the repository at this point in the history
- The first to be able to choose the apt mirro base url (issue #6)
- The second to avoid installing development files within client recipe byt setting an attribute (issue #17)
- Correct documentation
- Add rspec tests to the issue #17 implementation
  • Loading branch information
sinfomicien committed Oct 1, 2014
1 parent 62e1970 commit 7bc0fc3
Show file tree
Hide file tree
Showing 6 changed files with 96 additions and 12 deletions.
21 changes: 20 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,18 @@ Attributes
<td>Wether to allow the recipe to change root password after the first install</td>
<td><tt>false</tt></td>
</tr>
<tr>
<td><tt>['mariadb']['client']['development_files']</tt></td>
<td>Boolean</td>
<td>Wether to install development files in client recipe</td>
<td><tt>true</tt></td>
</tr>
<tr>
<td><tt>['mariadb']['apt_repository']['base_url']</tt></td>
<td>String</td>
<td>The http base url to use when installing from default repository</td>
<td><tt>'ftp.igh.cnrs.fr/pub/mariadb/repo'</tt></td>
</tr>
</table>

Usage
Expand All @@ -83,12 +95,19 @@ List of availables recipes:

Please be ware that by default, the root password is empty! If you want have changed it use the `node['mariadb']['server_root_password']` attribute to put a correct value. And by default the remote root access is not activated. Use `node['mariadb']['forbid_remote_root']` attribute to change it.

Sometimes, the default apt repository used for apt does not work (see issue #6). In this case, you need to choose another mirror which worki (pick it from mariadb website), and put the http base url in the attribute `node['mariadb']['apt_repository']['base_url']`.

#### mariadb::galera

When installing the mariadb::galera on debian recipe, You have to take care of one specific attribute:
`default['mariadb']['debian']['password']` which default to 'please-change-me'
`node['mariadb']['debian']['password']` which default to 'please-change-me'
As wee need to have the same password for this user on the whole cluster nodes... We will change the default install one by the content of this attribute.

#### mariadb::client

By default this recipe install the client, and all needed packages to develop client application. If you do not want to install development files when installing client package,
set the attribute `node['mariadb']['client']['development_files']` to false.

Contributing
------------

Expand Down
3 changes: 3 additions & 0 deletions attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@
#
default['mariadb']['client']['port'] = 3306
default['mariadb']['client']['options'] = {}
default['mariadb']['client']['development_files'] = true

#
# debian specific configuration
Expand All @@ -130,3 +131,5 @@
# package(apt or yum) default configuration
#
default['mariadb']['use_default_repository'] = false
default['mariadb']['apt_repository']['base_url'] = \
'ftp.igh.cnrs.fr/pub/mariadb/repo'
40 changes: 30 additions & 10 deletions recipes/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,43 @@

case node['platform_family']
when 'rhel'
node.default['mariadb']['client']['packages'] = \
%w(MariaDB-client MariaDB-devel)

# On CentOS at least, there's a conflict between MariaDB and mysql-libs
package 'mysql-libs' do
action :remove
end

if node['mariadb']['client']['development_files']
node.default['mariadb']['client']['packages'] = \
%w(MariaDB-client MariaDB-devel)
else
node.default['mariadb']['client']['packages'] = \
%w(MariaDB-client)
end
when 'fedora'
node.default['mariadb']['client']['packages'] = \
%w(mariadb mariadb-devel)
if node['mariadb']['client']['development_files']
node.default['mariadb']['client']['packages'] = \
%w(mariadb mariadb-devel)
else
node.default['mariadb']['client']['packages'] = \
%w(mariadb)
end
when 'suse'
node.default['mariadb']['client']['packages'] = \
%w(mariadb-community-server-client libmariadbclient-devel)
if node['mariadb']['client']['development_files']
node.default['mariadb']['client']['packages'] = \
%w(mariadb-community-server-client libmariadbclient-devel)
else
node.default['mariadb']['client']['packages'] = \
%w(mariadb-community-server-client)
end
when 'debian'
node.default['mariadb']['client']['packages'] = \
%W(mariadb-client-#{node['mariadb']['install']['version']}
libmariadbclient-dev)
if node['mariadb']['client']['development_files']
node.default['mariadb']['client']['packages'] = \
%W(mariadb-client-#{node['mariadb']['install']['version']}
libmariadbclient-dev)
else
node.default['mariadb']['client']['packages'] = \
%W(mariadb-client-#{node['mariadb']['install']['version']})
end
end

node['mariadb']['client']['packages'].each do |name|
Expand Down
2 changes: 1 addition & 1 deletion recipes/repository.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
include_recipe 'apt::default'

apt_repository "mariadb-#{node['mariadb']['install']['version']}" do
uri 'http://ftp.igh.cnrs.fr/pub/mariadb/repo/' + \
uri 'http://' + node['mariadb']['apt_repository']['base_url'] + '/' + \
node['mariadb']['install']['version'] + '/' + node['platform']
distribution node['lsb']['codename']
components ['main']
Expand Down
21 changes: 21 additions & 0 deletions spec/centos_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,25 @@
it 'Install MariaDB Client Devel Package' do
expect(chef_run).to install_package('MariaDB-devel')
end
context 'Without development files' do
let(:chef_run) do
runner = ChefSpec::Runner.new(
platform: 'centos', version: '6.4',
step_into: ['mariadb_configuration']
) do |node|
node.automatic['memory']['total'] = '2048kB'
node.automatic['ipaddress'] = '1.1.1.1'
node.set['mariadb']['client']['development_files'] = false
end
runner.converge('mariadb::client')
end

it 'Install MariaDB Client Package' do
expect(chef_run).to install_package('MariaDB-client')
end

it 'Don t install MariaDB Client Devel Package' do
expect(chef_run).to_not install_package('MariaDB-devel')
end
end
end
21 changes: 21 additions & 0 deletions spec/debian_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,25 @@
it 'Install MariaDB Client Devel Package' do
expect(chef_run).to install_package('libmariadbclient-dev')
end
context 'Without development files' do
let(:chef_run) do
runner = ChefSpec::Runner.new(
platform: 'debian', version: '7.4',
step_into: ['mariadb_configuration']
) do |node|
node.automatic['memory']['total'] = '2048kB'
node.automatic['ipaddress'] = '1.1.1.1'
node.set['mariadb']['client']['development_files'] = false
end
runner.converge('mariadb::client')
end

it 'Install MariaDB Client Package' do
expect(chef_run).to install_package('mariadb-client-10.0')
end

it 'Don t install MariaDB Client Devel Package' do
expect(chef_run).to_not install_package('libmariadbclient-dev')
end
end
end

0 comments on commit 7bc0fc3

Please sign in to comment.