diff --git a/.kitchen.yml b/.kitchen.yml index 33cf28e..ac546d2 100644 --- a/.kitchen.yml +++ b/.kitchen.yml @@ -11,8 +11,25 @@ provisioner: platforms: - name: ubuntu-12.04 + run_list: + - recipe[apt] + attributes: + apt: + compile_time_update: true + - name: ubuntu-14.04 + run_list: + - recipe[apt] + attributes: + apt: + compile_time_update: true - name: debian-7.8 + run_list: + - recipe[apt] + attributes: + apt: + compile_time_update: true - name: centos-6.6 + - name: centos-7.2 - name: oel-6.6 driver: box: rafacas/oel66-plain @@ -26,7 +43,6 @@ suites: driver: vm_hostname: mongo3 run_list: - - recipe[apt] - recipe[mongodb3::default] attributes: chef_client: @@ -35,8 +51,6 @@ suites: log_level: info build-essential: compile_time: false - apt: - compile_time_update: true provisioner: client_rb: environment: dev @@ -44,26 +58,23 @@ suites: - oel-6.6 - ami-2014.03 - - name: default-305 + - name: chef-client-11 driver: vm_hostname: mongo3 + driver_config: + require_chef_omnibus: 11.18.12 run_list: - - recipe[apt] - recipe[mongodb3::default] + excludes: + - debian-7.8 + - oel-6.6 + - ami-2014.03 + - ubuntu-14.04 + + - name: default-30x + run_list: + - recipe[mongodb3-test::default-30x] attributes: - mongodb3: - version: 3.0.5 - chef_client: - config: - force_logger: true - log_level: info - build-essential: - compile_time: false - apt: - compile_time_update: true - provisioner: - client_rb: - environment: dev excludes: - oel-6.6 - ami-2014.03 @@ -72,7 +83,6 @@ suites: driver: vm_hostname: replica run_list: - - recipe[apt] - role[replset] attributes: chef_client: @@ -81,8 +91,6 @@ suites: log_level: info build-essential: compile_time: false - apt: - compile_time_update: true provisioner: client_rb: environment: dev @@ -94,7 +102,6 @@ suites: driver: vm_hostname: configsvr run_list: - - recipe[apt] - role[configsvr] attributes: chef_client: @@ -103,8 +110,6 @@ suites: log_level: info build-essential: compile_time: false - apt: - compile_time_update: true provisioner: client_rb: environment: dev @@ -116,7 +121,6 @@ suites: driver: vm_hostname: mongos run_list: - - recipe[apt] - role[mongos] attributes: chef_client: @@ -125,30 +129,26 @@ suites: log_level: info build-essential: compile_time: false - apt: - compile_time_update: true provisioner: client_rb: environment: dev excludes: - - oel-6.6 - ami-2014.03 - name: wired-tiger driver: vm_hostname: wired-tiger run_list: - - recipe[apt] - role[wired_tiger] attributes: + mongodb3: + version: '3.0.9' chef_client: config: force_logger: true log_level: info build-essential: compile_time: false - apt: - compile_time_update: true provisioner: client_rb: environment: dev @@ -160,7 +160,6 @@ suites: driver: vm_hostname: mms-automation-agent run_list: - - recipe[apt] - role[mms_automation_agent] attributes: chef_client: @@ -169,8 +168,6 @@ suites: log_level: info build-essential: compile_time: false - apt: - compile_time_update: true provisioner: client_rb: environment: dev @@ -178,12 +175,24 @@ suites: - oel-6.6 - ami-2014.03 - debian-7.8 + - centos-7.2 + + - name: mms-automation-agent-with-databag + driver: + vm_hostname: mms-automation-agent + encrypted_data_bag_secret_key_path: "test/data_bags/encrypted_data_bag_secret" + run_list: + - recipe[mongodb3-test::mms_automation_agent_with_data_bag] + provisioner: + client_rb: + environment: dev + includes: + - ubuntu-12.04 - name: mms-monitoring-agent driver: vm_hostname: mms-monitoring-agent run_list: - - recipe[apt] - role[mms_monitoring_agent] attributes: chef_client: @@ -192,8 +201,6 @@ suites: log_level: info build-essential: compile_time: false - apt: - compile_time_update: true provisioner: client_rb: environment: dev @@ -201,6 +208,7 @@ suites: - oel-6.6 - ami-2014.03 - debian-7.8 + - centos-7.2 - name: ami-default driver: @@ -219,8 +227,5 @@ suites: provisioner: client_rb: environment: dev - excludes: - - ubuntu-12.04 - - centos-6.6 - - oel-6.6 - - debian-7.8 + includes: + - ami-2014.03 diff --git a/Berksfile b/Berksfile index 967b9a7..12752b4 100644 --- a/Berksfile +++ b/Berksfile @@ -1,3 +1,7 @@ source "https://supermarket.chef.io" metadata + +group :integration do + cookbook 'mongodb3-test', :path => './test/cookbooks/mongodb3-test' +end diff --git a/CHANGELOG.md b/CHANGELOG.md index c7e208e..1796b47 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,10 +1,21 @@ # mongodb3 Cookbook CHANGELOG -## Next +## 5.0.0 + * Fixed Chef::Mixin::Template::TemplateError: Node attributes are read-only when you do not specify which precedence level to set with Chef 11.10 - Daniel Doubrovkine([@dblock](https://github.com/dblock)) #21. +* Adding test for chef client 11.18.12 as 11.x : testing for #21 +* Adding kitchen test for ubuntu 14.04 : #13 +* Using `/var/run/mongodb/mongod.pid` for centos7 : #25 +* Moving attribute setter to recipe in order to support install 3.0.x in wrapper cookbook. : #23 +* Adding the mongodb 3.0.x version testing in test wrapper cookbook : #23 +* Adding key file directory creation +* Fixing for yum and apt repo name +* Update default version as 3.2.1 : #24 ## 4.0.0 + Thank you so much for your contribution! + * Allowed overrides of mongo repo name for debian/ubuntu packages - Dave Augustus([@daugustus](https://github.com/daugustus)) * Added support for MongoDB 3.2.0 - Constantin Guay([@Cog-g](https://github.com/Cog-g)) * Support for both MongoDB 3.0.x and 3.2.x - Julien Pervillé([@jperville](https://github.com/jperville)) @@ -18,6 +29,7 @@ Thank you so much for your contribution! * Removing kitchen test of mongos for oel-6.6 : There was no 3.0.7-1.el6 of mongos package for Oracle Linux 6.6 (Test failure). I'll keep testing and bring it back later. NOTICE : + * Current version 3.0.0 is not supporting mongos 3.0.7 for Oracle Linux 6.6. The package version 3.0.7-1.el6 of mongodb-org-shell package wasn't existing (Test failure). * Current version 3.0.0 is not supporting automation and monitoring mms agent installation for Debian 7.8 @@ -29,7 +41,6 @@ WARNING : `mms-agent` recipe has been deprecated at this version. * Removing `mms-agent` recipe and divide it as `mms-automation-agent` and `mms-monitoring-agent` recipe * PR #3 : Bump up the runit dependency version to 1.7.0. Thank you for your contribution @dherges - ## 1.0.0 mongodb3 Chef Cookbook 1.0.0 release. diff --git a/README.md b/README.md index e6e74de..3236300 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [](https://travis-ci.org/sunggun-yu/chef-mongodb3) -Install and configure the MongoDB 3 +## Install and configure the MongoDB 3 * Install and configure the mongod (or configure the config server for shard cluster) * Install and configure the mongos @@ -10,24 +10,28 @@ Install and configure the MongoDB 3 * Install the MMS Automation Agent * Install the MMS Monitoring Agent -NOTICE : -* Current version 4.0.0 is not supporting mongos 3.0.7 for Oracle Linux 6.6. The package version 3.0.7-1.el6 of mongodb-org-shell package wasn't existing (Test failure). -* Current version 4.0.0 is not supporting automation and monitoring mms agent installation for Debian 7.8 -* MongoDB 3.2.0 is default version of mongodb3 cookbook - by [@Cog_g](https://github.com/Cog-g) +### NOTICE : + +* Current version 5.0.0 is not supporting automation and monitoring mms agent installation for Debian 7.8 +* MongoDB 3.2.1 is default version of mongodb3 cookbook + +### Contributors -Contributors * David Herges - [@dherges](https://github.com/dherges) * Joe Passavanti - [@gottaloveit](https://github.com/gottaloveit) * MEGA MOnolithic meTHod - [@megamoth](https://github.com/megamoth) * Dave Augustus - [@daugustus](https://github.com/daugustus) * Constantin Guay - [@Cog-g](https://github.com/Cog-g) * Julien Pervillé - [@jperville](https://github.com/jperville) +* Daniel Doubrov - [@dblock](https://github.com/dblock) ## Supported Platforms +The following platforms have been tested with Test Kitchen + * Ubuntu 12.04, 14.04 * Debian 7.8 -* CentOS 6.6 +* CentOS 6.6, 7.2 * Oralce 6.6 * Amazon Linux @@ -40,16 +44,17 @@ WARNING : Please do not set the user and group attribute on your side. This cook ``` # MongoDB version to install -default['mongodb3']['version'] = '3.2.0' +default['mongodb3']['version'] = '3.2.1' default['mongodb3']['package']['version'] = Actual package version to install. It builds from version attribute. # Package repository url default['mongodb3']['package']['repo']['url'] = Package repository url # Attribute for apt_repository -default['mongodb3']['package']['repo']['apt']['keyserver'] = key server url for ubuntu or debian -default['mongodb3']['package']['repo']['apt']['key'] = 'EA312927' -default['mongodb3']['package']['repo']['apt']['components'] = `multiverse` for ubuntu. `main` for debian +default['mongodb3']['package']['repo']['apt']['name'] = nil # eg. 3.0, 3.2 +default['mongodb3']['package']['repo']['apt']['keyserver'] = nil # eg. hkp://keyserver.ubuntu.com:80 +default['mongodb3']['package']['repo']['apt']['key'] = nil # eg. 3.2 : 'EA312927', 3.0 : '7F0CEB10' +default['mongodb3']['package']['repo']['apt']['components'] = nil # `multiverse` for ubuntu. `main` for debian # MongoDB user:group : PLEASE DO NOT SET THE USER AND GROUP ATTRIBUTE default['mongodb3']['user'] = 'mongod' | 'mongodb' diff --git a/attributes/default.rb b/attributes/default.rb index 0804f1e..630e80e 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -18,40 +18,24 @@ # # MongoDB version to install -default['mongodb3']['version'] = '3.2.0' +default['mongodb3']['version'] = '3.2.1' -# Setup default package version attribute to install -pkg_version = node['mongodb3']['version'] -case node['platform_family'] - when 'rhel', 'fedora' - pkg_version = "#{node['mongodb3']['version']}-1.el#{node.platform_version.to_i}" # ~FC019 - if node['platform'] == 'amazon' - pkg_version = "#{node['mongodb3']['version']}-1.amzn1" # ~FC019 - end -end -pkg_major_version = pkg_version.to_f # eg. 3.0, 3.2 - -# Setup default package repo url attribute for each platform family or platform -case node['platform'] - when 'redhat', 'oracle','centos', 'fedora' - pkg_repo = "https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/#{pkg_major_version}/#{node['kernel']['machine'] =~ /x86_64/ ? 'x86_64' : 'i686'}" - when 'amazon' - pkg_repo = "https://repo.mongodb.org/yum/amazon/2013.03/mongodb-org/#{pkg_major_version}/x86_64/" - when 'ubuntu' - pkg_repo = 'http://repo.mongodb.org/apt/ubuntu' - when 'debian' - pkg_repo = 'http://repo.mongodb.org/apt/debian' -end +# Please note : The default values for ['mongodb3']['package'] attributes will be set in `package_repo` recipe. +# but, You can set custom values for yum/apt repo url, yum package version or apt related in your wrapper -# Setup apt variables -case node['platform'] - when 'ubuntu' - apt_repo_keyserver = 'hkp://keyserver.ubuntu.com:80' - apt_repo_component = ['multiverse'] - when 'debian' - apt_repo_keyserver = 'keyserver.ubuntu.com' - apt_repo_component = ['main'] -end +# MongoDB package version to install : eg. 3.0.8, 3.2.1, 3.2.1-1.el6 or 3.2.1-1.amzn1 +default['mongodb3']['package']['version'] = nil + +# MongoDB package repo url +# eg. ubuntu : 'http://repo.mongodb.org/apt/ubuntu' +# eg. centos : 'https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/3.2/x86_64/' +default['mongodb3']['package']['repo']['url'] = nil + +# MongoDB repository info for apt +default['mongodb3']['package']['repo']['apt']['name'] = nil # eg. 3.0, 3.2 +default['mongodb3']['package']['repo']['apt']['keyserver'] = nil # eg. hkp://keyserver.ubuntu.com:80 +default['mongodb3']['package']['repo']['apt']['key'] = nil # eg. 3.2 : 'EA312927', 3.0 : '7F0CEB10' +default['mongodb3']['package']['repo']['apt']['components'] = nil # eg. ['multiverse'] # Default attribute for MongoDB installation case node['platform_family'] @@ -59,7 +43,12 @@ mongo_user = 'mongod' mongo_group = 'mongod' mongo_dbpath = '/var/lib/mongo' - mongo_pid_file = '/var/run/mongodb/mongodb.pid' + # To guarantee the compatibility for centos 6 in previous version of mongodb3 cookbook + if node['platform_version'].to_i >= 7 + mongo_pid_file = '/var/run/mongodb/mongod.pid' + else + mongo_pid_file = '/var/run/mongodb/mongodb.pid' + end config_processManagement_fork = true when 'debian' mongo_user = 'mongodb' @@ -69,24 +58,6 @@ config_processManagement_fork = nil end -# MongoDB package repo url -default['mongodb3']['package']['repo']['url'] = pkg_repo - -# MongoDB repository name -default['mongodb3']['package']['repo']['apt']['name'] = pkg_major_version.to_s - -# MongoDB apt keyserver and key -default['mongodb3']['package']['repo']['apt']['keyserver'] = apt_repo_keyserver -if pkg_major_version >= 3.2 - default['mongodb3']['package']['repo']['apt']['key'] = 'EA312927' -else - default['mongodb3']['package']['repo']['apt']['key'] = '7F0CEB10' -end -default['mongodb3']['package']['repo']['apt']['components'] = apt_repo_component - -# MongoDB package version to install -default['mongodb3']['package']['version'] = pkg_version - # MongoDB user:group default['mongodb3']['user'] = mongo_user default['mongodb3']['group'] = mongo_group @@ -187,11 +158,7 @@ default['mongodb3']['config']['mongod']['storage']['journal']['enabled'] = true default['mongodb3']['config']['mongod']['storage']['directoryPerDB'] = nil # default : false default['mongodb3']['config']['mongod']['storage']['syncPeriodSecs'] = nil # default : 60 -if pkg_major_version >= 3.2 - default['mongodb3']['config']['mongod']['storage']['engine'] = 'wiredTiger' # default since 3.2 : wiredTiger -else - default['mongodb3']['config']['mongod']['storage']['engine'] = 'mmapv1' # default until 3.2 : mmapv1 -end +default['mongodb3']['config']['mongod']['storage']['engine'] = nil # default - since 3.2 : wiredTiger, until 3.2 : mmapv1 # storage.mmapv1 Options : http://docs.mongodb.org/manual/reference/configuration-options/#storage-mmapv1-options default['mongodb3']['config']['mongod']['storage']['mmapv1']['preallocDataFiles'] = nil # default : true diff --git a/recipes/default.rb b/recipes/default.rb index cfeac40..a4890d2 100644 --- a/recipes/default.rb +++ b/recipes/default.rb @@ -41,6 +41,15 @@ unless node['mongodb3']['config']['key_file_content'].to_s.empty? # Create the key file if it is not exist key_file = node['mongodb3']['config']['mongod']['security']['keyFile'] + + # Create the directory for key file + directory File.dirname(key_file).to_s do + action :create + owner node['mongodb3']['user'] + group node['mongodb3']['group'] + recursive true + end + file key_file do content node['mongodb3']['config']['key_file_content'] mode '0600' diff --git a/recipes/package_repo.rb b/recipes/package_repo.rb index c7a46d3..ed6705c 100644 --- a/recipes/package_repo.rb +++ b/recipes/package_repo.rb @@ -17,10 +17,76 @@ # limitations under the License. # -# Add the MongoDB 3.0 Package repository +pkg_major_version = node['mongodb3']['version'].to_f # eg. 3.0, 3.2 + +# Setup default package version attribute to install +pkg_version = node['mongodb3']['version'] +case node['platform_family'] + when 'rhel', 'fedora' + pkg_version = "#{node['mongodb3']['version']}-1.el#{node.platform_version.to_i}" # ~FC019 + if node['platform'] == 'amazon' + pkg_version = "#{node['mongodb3']['version']}-1.amzn1" # ~FC019 + end +end + +# Setup default package repo url attribute for each platform family or platform +case node['platform'] + when 'redhat', 'oracle','centos', 'fedora' # ~FC024 + pkg_repo = "https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/#{pkg_major_version}/#{node['kernel']['machine'] =~ /x86_64/ ? 'x86_64' : 'i686'}" + when 'amazon' + pkg_repo = "https://repo.mongodb.org/yum/amazon/2013.03/mongodb-org/#{pkg_major_version}/x86_64/" + when 'ubuntu' + pkg_repo = 'http://repo.mongodb.org/apt/ubuntu' + when 'debian' + pkg_repo = 'http://repo.mongodb.org/apt/debian' +end + +# Setup apt variables +case node['platform'] + when 'ubuntu' + apt_repo_keyserver = 'hkp://keyserver.ubuntu.com:80' + apt_repo_component = ['multiverse'] + when 'debian' + apt_repo_keyserver = 'keyserver.ubuntu.com' + apt_repo_component = ['main'] +end + +# MongoDB package version to install +if node['mongodb3']['package']['version'].nil? + node.set['mongodb3']['package']['version'] = pkg_version +end + +# MongoDB package repo url +if node['mongodb3']['package']['repo']['url'].nil? + node.set['mongodb3']['package']['repo']['url'] = pkg_repo +end + +# MongoDB repository name +if node['mongodb3']['package']['repo']['apt']['name'].nil? + node.set['mongodb3']['package']['repo']['apt']['name'] = pkg_major_version.to_s +end + +# MongoDB apt keyserver and key +if node['mongodb3']['package']['repo']['apt']['keyserver'].nil? + node.set['mongodb3']['package']['repo']['apt']['keyserver'] = apt_repo_keyserver +end + +if node['mongodb3']['package']['repo']['apt']['key'].nil? + if pkg_major_version >= 3.2 + node.set['mongodb3']['package']['repo']['apt']['key'] = 'EA312927' + else + node.set['mongodb3']['package']['repo']['apt']['key'] = '7F0CEB10' + end +end + +if node['mongodb3']['package']['repo']['apt']['components'].nil? + node.set['mongodb3']['package']['repo']['apt']['components'] = apt_repo_component +end + +# Add the MongoDB Package repository case node['platform_family'] when 'rhel', 'fedora' - yum_repository 'mongodb-org-3.0' do + yum_repository "mongodb-org-#{pkg_major_version}" do description 'MongoDB Repository' baseurl node['mongodb3']['package']['repo']['url'] action :create @@ -29,7 +95,7 @@ sslverify false end when 'debian' - apt_repository 'mongodb' do + apt_repository "mongodb-org-#{pkg_major_version}" do uri node['mongodb3']['package']['repo']['url'] distribution "#{node['lsb']['codename']}/mongodb-org/#{node['mongodb3']['package']['repo']['apt']['name']}" components node['mongodb3']['package']['repo']['apt']['components'] diff --git a/test/.foodcritic b/test/.foodcritic new file mode 100644 index 0000000..b381b38 --- /dev/null +++ b/test/.foodcritic @@ -0,0 +1,3 @@ +~FC011 +~FC031 +~FC045 \ No newline at end of file diff --git a/test/cookbooks/mongodb3-test/CHANGELOG.md b/test/cookbooks/mongodb3-test/CHANGELOG.md new file mode 100644 index 0000000..47c1af6 --- /dev/null +++ b/test/cookbooks/mongodb3-test/CHANGELOG.md @@ -0,0 +1,13 @@ +mongodb3-test CHANGELOG +======================= + +This file is used to list changes made in each version of the mongodb3-test cookbook. + +0.1.0 +----- +- [your_name] - Initial release of mongodb3-test + +- - - +Check the [Markdown Syntax Guide](http://daringfireball.net/projects/markdown/syntax) for help with Markdown. + +The [Github Flavored Markdown page](http://github.github.com/github-flavored-markdown/) describes the differences between markdown on github and standard markdown. diff --git a/test/cookbooks/mongodb3-test/README.md b/test/cookbooks/mongodb3-test/README.md new file mode 100644 index 0000000..80cafb6 --- /dev/null +++ b/test/cookbooks/mongodb3-test/README.md @@ -0,0 +1,68 @@ +mongodb3-test Cookbook +====================== +TODO: Enter the cookbook description here. + +e.g. +This cookbook makes your favorite breakfast sandwich. + +Requirements +------------ +TODO: List your cookbook requirements. Be sure to include any requirements this cookbook has on platforms, libraries, other cookbooks, packages, operating systems, etc. + +e.g. +#### packages +- `toaster` - mongodb3-test needs toaster to brown your bagel. + +Attributes +---------- +TODO: List your cookbook attributes here. + +e.g. +#### mongodb3-test::default +
Key | +Type | +Description | +Default | +
---|---|---|---|
['mongodb3-test']['bacon'] | +Boolean | +whether to include bacon | +true | +