forked from cdapio/hadoop_cookbook
-
Notifications
You must be signed in to change notification settings - Fork 0
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 cdapio#169 from caskdata/feature/sql-connectors-re…
…cipe Move SQL connectors to their own recipe
- Loading branch information
Showing
8 changed files
with
219 additions
and
159 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,70 @@ | ||
# | ||
# Cookbook Name:: hadoop | ||
# Recipe:: _sql_connectors | ||
# | ||
# Copyright © 2015 Cask Data, Inc. | ||
# | ||
# 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 'hadoop::repo' | ||
|
||
pkgs = [] | ||
jars = [] | ||
|
||
# rubocop: disable Metrics/BlockNesting | ||
if node['hadoop'].key?('sql_connector') | ||
case node['hadoop']['sql_connector'] | ||
when 'mysql' | ||
if node['platform_family'] == 'rhel' && node['platform_version'].to_i == '5' | ||
Chef::Log.warn('You must download and install JDBC connectors, manually') | ||
pkgs = nil | ||
else | ||
if node['platform_family'] == 'debian' && node['hadoop']['distribution'] != 'hdp' | ||
pkgs = ['libmysql-java'] | ||
else | ||
pkgs = ['mysql-connector-java'] | ||
end | ||
end | ||
jars = pkgs | ||
when 'postgresql' | ||
if node['platform_family'] == 'rhel' | ||
if node['platform_version'].to_i == '5' | ||
Chef::Log.warn('You must download and install JDBC connectors, manually') | ||
pkgs = nil | ||
else | ||
pkgs = ['postgresql-jdbc'] | ||
end | ||
jars = pkgs | ||
else # Assume debian | ||
pkgs = ['libpostgresql-jdbc-java'] | ||
jars = ['postgresql-jdbc4'] | ||
end | ||
### TODO: Oracle support | ||
when 'oracle' | ||
Chef::Log.warn('You must download and install JDBC connectors, manually') | ||
pkgs = nil | ||
jars = pkgs | ||
else | ||
Chef::Log.info('No JDBC driver necessary') | ||
end | ||
end | ||
# rubocop: enable Metrics/BlockNesting | ||
|
||
pkgs.each do |p| | ||
package p do | ||
action :install | ||
end | ||
end | ||
|
||
node.default['hadoop']['sql_jars'] = jars |
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,39 @@ | ||
require 'spec_helper' | ||
|
||
describe 'hadoop::_sql_connectors' do | ||
context 'Using MySQL on Centos 6.6 x86_64' do | ||
let(:chef_run) do | ||
ChefSpec::SoloRunner.new(platform: 'centos', version: 6.6) do |node| | ||
node.default['hadoop']['sql_connector'] = 'mysql' | ||
end.converge(described_recipe) | ||
end | ||
|
||
it 'install mysql-connector-java package' do | ||
expect(chef_run).to install_package('mysql-connector-java') | ||
end | ||
end | ||
|
||
context 'using PostgreSQL on CentOS 6.6 x86_64' do | ||
let(:chef_run) do | ||
ChefSpec::SoloRunner.new(platform: 'centos', version: 6.6) do |node| | ||
node.default['hadoop']['sql_connector'] = 'postgresql' | ||
end.converge(described_recipe) | ||
end | ||
|
||
it 'install postgresql-jdbc package' do | ||
expect(chef_run).to install_package('postgresql-jdbc') | ||
end | ||
end | ||
|
||
context 'Using PostgreSQL on Ubuntu 12.04' do | ||
let(:chef_run) do | ||
ChefSpec::SoloRunner.new(platform: 'ubuntu', version: 12.04) do |node| | ||
node.default['hadoop']['sql_connector'] = 'postgresql' | ||
end.converge(described_recipe) | ||
end | ||
|
||
it 'install libpostgresql-jdbc-java package' do | ||
expect(chef_run).to install_package('libpostgresql-jdbc-java') | ||
end | ||
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
Oops, something went wrong.