diff --git a/Gemfile b/Gemfile index 6ffa3b35..11c670ac 100644 --- a/Gemfile +++ b/Gemfile @@ -2,7 +2,7 @@ source 'https://rubygems.org' group :development, :test do gem 'puppetlabs_spec_helper' - gem 'puppet-lint-param-docs' + gem 'puppet-lint-param-docs', '1.1.0' gem 'metadata-json-lint' gem 'json' gem 'webmock' diff --git a/Puppetfile b/Puppetfile index 1aacad81..98aa39d6 100644 --- a/Puppetfile +++ b/Puppetfile @@ -74,6 +74,9 @@ mod 'cloud', mod 'common', :git => 'git://github.com/enovance/puppet-module-common.git', :ref => '2d0606fce1078222dd483e731ec32807f5b4ca53' +mod 'cassandra', + :git => 'git://github.com/enovance/cassandra.git', + :ref => '124f472128d178f52e2233d6aa8a0f1285f73c49' mod 'concat', :git => 'git://github.com/enovance/puppet-concat.git', :ref => 'ab06c2b8c09d9da82b53a62a5389427720519cd5' @@ -113,6 +116,9 @@ mod 'haproxy', mod 'inifile', :git => 'git://github.com/enovance/puppetlabs-inifile.git', :ref => 'ae23a4db97d2815ec305d0529912685f07746d3c' +mod 'kafka', + :git => 'git://github.com/enovance/puppet-kafka.git', + :ref => '9ed9993ef53e4c1f2897e5191ee7fccfac866dfe' mod 'keepalived', :git => 'git://github.com/enovance/puppet-module-keepalived.git', :ref => 'eb345b6d3b25106cbe166028f2b8dd9974a10230' @@ -224,3 +230,6 @@ mod 'openstack_extras', mod 'staging', :git => 'git://github.com/enovance/puppet-staging.git', :ref => 'bc434a71e19aae54223d57c274e2e1a7f9546d5e' +mod 'zookeeper', + :git => 'git://github.com/enovance/puppet-zookeeper-1.git', + :ref => '2617a4e5e01aaa7b597c533a3229cba71db4517b' diff --git a/manifests/database/nosql/cassandra.pp b/manifests/database/nosql/cassandra.pp new file mode 100644 index 00000000..abcacd38 --- /dev/null +++ b/manifests/database/nosql/cassandra.pp @@ -0,0 +1,40 @@ +# +# Copyright (C) 2015 eNovance SAS +# +# 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. +# +# == Class: cloud::database::nosql::cassandra +# +# Install a Cassandra node +# +# === Parameters: +# +# [*firewall_settings*] +# (optional) Allow to add custom parameters to firewall rules +# Should be an hash. +# Default to {} +# +class cloud::database::nosql::cassandra ( + $firewall_settings = {}, +){ + + include ::cassandra + + if $::cloud::manage_firewall { + cloud::firewall::rule{ '100 allow cassandra access': + port => '7000', + extras => $firewall_settings, + } + } + +} diff --git a/manifests/database/nosql/kafka.pp b/manifests/database/nosql/kafka.pp new file mode 100644 index 00000000..490a7f72 --- /dev/null +++ b/manifests/database/nosql/kafka.pp @@ -0,0 +1,40 @@ +# +# Copyright (C) 2015 eNovance SAS +# +# 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. +# +# == Class: cloud::database::nosql::kafka +# +# Install a Kafka broket +# +# === Parameters: +# +# [*firewall_settings*] +# (optional) Allow to add custom parameters to firewall rules +# Should be an hash. +# Default to {} +# +class cloud::database::nosql::kafka ( + $firewall_settings = {}, +){ + + include ::kafka::broker + + if $::cloud::manage_firewall { + cloud::firewall::rule{ '100 allow kafka access': + port => '9092', + extras => $firewall_settings, + } + } + +} diff --git a/manifests/database/nosql/zookeeper.pp b/manifests/database/nosql/zookeeper.pp new file mode 100644 index 00000000..843579f7 --- /dev/null +++ b/manifests/database/nosql/zookeeper.pp @@ -0,0 +1,40 @@ +# +# Copyright (C) 2015 eNovance SAS +# +# 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. +# +# == Class: cloud::database::nosql::zookeeper +# +# Install a Zookeeper node +# +# === Parameters: +# +# [*firewall_settings*] +# (optional) Allow to add custom parameters to firewall rules +# Should be an hash. +# Default to {} +# +class cloud::database::nosql::zookeeper ( + $firewall_settings = {}, +){ + + include ::zookeeper + + if $::cloud::manage_firewall { + cloud::firewall::rule{ '100 allow zookeeper access': + port => '2181', + extras => $firewall_settings, + } + } + +} diff --git a/spec/classes/cloud_database_nosql_cassandra_spec.rb b/spec/classes/cloud_database_nosql_cassandra_spec.rb new file mode 100644 index 00000000..1445eccd --- /dev/null +++ b/spec/classes/cloud_database_nosql_cassandra_spec.rb @@ -0,0 +1,79 @@ +# +# Copyright (C) 2015 eNovance SAS +# +# 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. +# +# Unit tests for cloud::cache::cassandra +# + +require 'spec_helper' + +describe 'cloud::database::nosql::cassandra' do + + shared_examples_for 'cassandra server' do + + let :params do + { } + end + + it 'configure cassandra with some params' do + is_expected.to contain_class('cassandra') + end + + context 'with default firewall enabled' do + let :pre_condition do + "class { 'cloud': manage_firewall => true }" + end + it 'configure cassandra firewall rules' do + is_expected.to contain_firewall('100 allow cassandra access').with( + :port => '7000', + :proto => 'tcp', + :action => 'accept', + ) + end + end + + context 'with custom firewall enabled' do + let :pre_condition do + "class { 'cloud': manage_firewall => true }" + end + before :each do + params.merge!(:firewall_settings => { 'limit' => '50/sec' } ) + end + it 'configure cassandra firewall rules with custom parameter' do + is_expected.to contain_firewall('100 allow cassandra access').with( + :port => '7000', + :proto => 'tcp', + :action => 'accept', + :limit => '50/sec', + ) + end + end + + end + + context 'on Debian platforms' do + let :facts do + { :osfamily => 'Debian' } + end + end + + context 'on RedHat platforms' do + let :facts do + { :osfamily => 'RedHat' } + end + + it_configures 'cassandra server' + end + +end diff --git a/spec/classes/cloud_database_nosql_kafka_spec.rb b/spec/classes/cloud_database_nosql_kafka_spec.rb new file mode 100644 index 00000000..65e5ffa0 --- /dev/null +++ b/spec/classes/cloud_database_nosql_kafka_spec.rb @@ -0,0 +1,85 @@ +# Copyright (C) 2015 eNovance SAS +# +# 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. +# +# Unit tests for cloud::cache::kafka +# + +require 'spec_helper' + +describe 'cloud::database::nosql::kafka' do + + shared_examples_for 'kafka server' do + + let :params do + { } + end + + it 'configure kafka with some params' do + is_expected.to contain_class('kafka') + end + + context 'with default firewall enabled' do + let :pre_condition do + "class { 'cloud': manage_firewall => true }" + end + it 'configure kafka firewall rules' do + is_expected.to contain_firewall('100 allow kafka access').with( + :port => '9092', + :proto => 'tcp', + :action => 'accept', + ) + end + end + + context 'with custom firewall enabled' do + let :pre_condition do + "class { 'cloud': manage_firewall => true }" + end + before :each do + params.merge!(:firewall_settings => { 'limit' => '50/sec' } ) + end + it 'configure kafka firewall rules with custom parameter' do + is_expected.to contain_firewall('100 allow kafka access').with( + :port => '9092', + :proto => 'tcp', + :action => 'accept', + :limit => '50/sec', + ) + end + end + + end + + context 'on Debian platforms' do + let :facts do + { + :osfamily => 'Debian', + :operatingsystem => 'Debian' + + } + end + end + + context 'on RedHat platforms' do + let :facts do + { + :osfamily => 'RedHat', + :operatingsystem => 'RedHat' + } + end + + it_configures 'kafka server' + end + +end diff --git a/spec/classes/cloud_database_nosql_zookeeper_spec.rb b/spec/classes/cloud_database_nosql_zookeeper_spec.rb new file mode 100644 index 00000000..a70d8b27 --- /dev/null +++ b/spec/classes/cloud_database_nosql_zookeeper_spec.rb @@ -0,0 +1,80 @@ +# +# Copyright (C) 2015 eNovance SAS +# +# 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. +# +# Unit tests for cloud::cache::zookeeper +# + +require 'spec_helper' + +describe 'cloud::database::nosql::zookeeper' do + + shared_examples_for 'zookeeper server' do + + let :params do + { } + end + + it 'configure zookeeper with some params' do + is_expected.to contain_class('zookeeper') + end + + context 'with default firewall enabled' do + let :pre_condition do + "class { 'cloud': manage_firewall => true }" + end + it 'configure zookeeper firewall rules' do + is_expected.to contain_firewall('100 allow zookeeper access').with( + :port => '2181', + :proto => 'tcp', + :action => 'accept', + ) + end + end + + context 'with custom firewall enabled' do + let :pre_condition do + "class { 'cloud': manage_firewall => true }" + end + before :each do + params.merge!(:firewall_settings => { 'limit' => '50/sec' } ) + end + it 'configure zookeeper firewall rules with custom parameter' do + is_expected.to contain_firewall('100 allow zookeeper access').with( + :port => '2181', + :proto => 'tcp', + :action => 'accept', + :limit => '50/sec', + ) + end + end + + end + + context 'on Debian platforms' do + let :facts do + { :osfamily => 'Debian' } + end + + end + + context 'on RedHat platforms' do + let :facts do + { :osfamily => 'RedHat' } + end + + it_configures 'zookeeper server' + end + +end