├── .gitignore ├── .kitchen.yml ├── .rubocop.yml ├── .travis.yml ├── Berksfile ├── CHANGELOG.md ├── Gemfile ├── LICENSE ├── README.md ├── Thorfile ├── Vagrantfile ├── attributes └── default.rb ├── chefignore ├── files └── default │ ├── disable-transparent-hugepages │ └── disable-transparent-hugepages.service ├── libraries └── mongodb3_helper.rb ├── metadata.rb ├── recipes ├── default.rb ├── mms_automation_agent.rb ├── mms_monitoring_agent.rb ├── mongos.rb └── package_repo.rb ├── templates └── default │ ├── automation-agent.config.erb │ ├── mongod.service.erb │ ├── mongodb.conf.erb │ ├── mongos.conf.erb │ ├── monitoring-agent.config.erb │ ├── sv-mongos-log-run.erb │ └── sv-mongos-run.erb └── test ├── .foodcritic ├── cookbooks └── mongodb3-test │ ├── CHANGELOG.md │ ├── README.md │ ├── attributes │ └── default.rb │ ├── metadata.rb │ └── recipes │ ├── amazon.rb │ ├── custom.rb │ ├── default-30x.rb │ ├── default.rb │ └── mms_automation_agent_with_data_bag.rb ├── data_bags ├── encrypted_data_bag_secret └── mongodb │ └── mms-agent.json ├── environments └── dev.json ├── integration ├── configsvr │ └── serverspec │ │ └── default_spec.rb ├── custom │ └── serverspec │ │ └── default_spec.rb ├── default-30x │ └── serverspec │ │ └── default_spec.rb ├── default │ └── serverspec │ │ └── default_spec.rb ├── helpers │ └── serverspec │ │ ├── Gemfile │ │ └── spec_helper.rb ├── mms-automation-agent-with-databag │ └── serverspec │ │ └── default_spec.rb ├── mms-automation-agent │ └── serverspec │ │ └── default_spec.rb ├── mms-monitoring-agent │ └── serverspec │ │ └── default_spec.rb ├── mongos │ └── serverspec │ │ └── default_spec.rb ├── replica │ └── serverspec │ │ └── default_spec.rb └── wired-tiger │ └── serverspec │ └── default_spec.rb ├── libraries └── mongodb3_helper_spec.rb └── roles ├── configsvr.json ├── mms_automation_agent.json ├── mms_monitoring_agent.json ├── mongos.json ├── replset.json └── wired_tiger.json /.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | *# 3 | .#* 4 | \#*# 5 | .*.sw[a-z] 6 | *.un~ 7 | pkg/ 8 | 9 | # Berkshelf 10 | .vagrant 11 | /cookbooks 12 | Berksfile.lock 13 | 14 | # Bundler 15 | Gemfile.lock 16 | bin/* 17 | .bundle/* 18 | 19 | .kitchen/ 20 | .kitchen.local.yml 21 | -------------------------------------------------------------------------------- /.kitchen.yml: -------------------------------------------------------------------------------- 1 | --- 2 | driver: 3 | name: vagrant 4 | 5 | provisioner: 6 | name: chef_zero 7 | require_chef_omnibus: true 8 | environments_path: 'test/environments' 9 | data_bags_path: 'test/data_bags' 10 | roles_path: 'test/roles' 11 | 12 | platforms: 13 | - name: ubuntu-12.04 14 | run_list: 15 | - recipe[apt] 16 | attributes: 17 | apt: 18 | compile_time_update: true 19 | - name: ubuntu-14.04 20 | run_list: 21 | - recipe[apt] 22 | attributes: 23 | apt: 24 | compile_time_update: true 25 | - name: ubuntu-15.04 26 | run_list: 27 | - recipe[apt] 28 | attributes: 29 | apt: 30 | compile_time_update: true 31 | - name: ubuntu-16.04 32 | run_list: 33 | - recipe[apt] 34 | attributes: 35 | apt: 36 | compile_time_update: true 37 | - name: debian-7.8 38 | run_list: 39 | - recipe[apt] 40 | attributes: 41 | apt: 42 | compile_time_update: true 43 | - name: centos-6.8 44 | driver: 45 | box: bento/centos-6.8 46 | - name: centos-7.2 47 | driver: 48 | box: bento/centos-7.2 49 | - name: oel-6.6 50 | driver: 51 | box: rafacas/oel66-plain 52 | box_url: https://atlas.hashicorp.com/rafacas/boxes/oel66-plain/versions/1.0.0/providers/virtualbox.box 53 | - name: ami-2014.03 54 | driver: 55 | box_url: http://images.geekandi.com/amazon-linux/vagrant-amazon-linux64-2014.03-public-virtualbox.box 56 | 57 | suites: 58 | - name: default 59 | driver: 60 | vm_hostname: mongo3 61 | run_list: 62 | - recipe[mongodb3::default] 63 | attributes: 64 | chef_client: 65 | config: 66 | force_logger: true 67 | log_level: info 68 | build-essential: 69 | compile_time: false 70 | mongodb3: 71 | mongod: 72 | disable-transparent-hugepages: true 73 | provisioner: 74 | client_rb: 75 | environment: dev 76 | excludes: 77 | - oel-6.6 78 | - ami-2014.03 79 | 80 | - name: custom 81 | run_list: 82 | - recipe[mongodb3-test::custom] 83 | attributes: 84 | chef_client: 85 | config: 86 | force_logger: true 87 | log_level: info 88 | build-essential: 89 | compile_time: false 90 | provisioner: 91 | client_rb: 92 | environment: dev 93 | includes: 94 | - ubuntu-14.04 95 | - centos-7.2 96 | 97 | - name: default-30x 98 | run_list: 99 | - recipe[mongodb3-test::default-30x] 100 | attributes: 101 | excludes: 102 | - oel-6.6 103 | - ami-2014.03 104 | - ubuntu-15.04 105 | - ubuntu-16.04 106 | 107 | - name: replica 108 | driver: 109 | vm_hostname: replica 110 | run_list: 111 | - role[replset] 112 | attributes: 113 | chef_client: 114 | config: 115 | force_logger: true 116 | log_level: info 117 | build-essential: 118 | compile_time: false 119 | provisioner: 120 | client_rb: 121 | environment: dev 122 | excludes: 123 | - oel-6.6 124 | - ami-2014.03 125 | 126 | - name: configsvr 127 | driver: 128 | vm_hostname: configsvr 129 | run_list: 130 | - role[configsvr] 131 | attributes: 132 | chef_client: 133 | config: 134 | force_logger: true 135 | log_level: info 136 | build-essential: 137 | compile_time: false 138 | provisioner: 139 | client_rb: 140 | environment: dev 141 | excludes: 142 | - oel-6.6 143 | - ami-2014.03 144 | 145 | - name: mongos 146 | driver: 147 | vm_hostname: mongos 148 | run_list: 149 | - role[mongos] 150 | attributes: 151 | chef_client: 152 | config: 153 | force_logger: true 154 | log_level: info 155 | build-essential: 156 | compile_time: false 157 | provisioner: 158 | client_rb: 159 | environment: dev 160 | excludes: 161 | - oel-6.6 162 | - ami-2014.03 163 | 164 | - name: wired-tiger 165 | driver: 166 | vm_hostname: wired-tiger 167 | run_list: 168 | - role[wired_tiger] 169 | attributes: 170 | mongodb3: 171 | version: '3.0.9' 172 | chef_client: 173 | config: 174 | force_logger: true 175 | log_level: info 176 | build-essential: 177 | compile_time: false 178 | provisioner: 179 | client_rb: 180 | environment: dev 181 | excludes: 182 | - oel-6.6 183 | - ami-2014.03 184 | - ubuntu-16.04 185 | 186 | - name: mms-automation-agent 187 | driver: 188 | vm_hostname: mms-automation-agent 189 | run_list: 190 | - role[mms_automation_agent] 191 | attributes: 192 | chef_client: 193 | config: 194 | force_logger: true 195 | log_level: info 196 | build-essential: 197 | compile_time: false 198 | provisioner: 199 | client_rb: 200 | environment: dev 201 | excludes: 202 | - oel-6.6 203 | - ami-2014.03 204 | - debian-7.8 205 | - centos-7.2 206 | 207 | - name: mms-automation-agent-with-databag 208 | driver: 209 | vm_hostname: mms-automation-agent 210 | encrypted_data_bag_secret_key_path: "test/data_bags/encrypted_data_bag_secret" 211 | run_list: 212 | - recipe[mongodb3-test::mms_automation_agent_with_data_bag] 213 | provisioner: 214 | client_rb: 215 | environment: dev 216 | includes: 217 | - ubuntu-12.04 218 | 219 | - name: mms-monitoring-agent 220 | driver: 221 | vm_hostname: mms-monitoring-agent 222 | run_list: 223 | - role[mms_monitoring_agent] 224 | attributes: 225 | chef_client: 226 | config: 227 | force_logger: true 228 | log_level: info 229 | build-essential: 230 | compile_time: false 231 | provisioner: 232 | client_rb: 233 | environment: dev 234 | excludes: 235 | - oel-6.6 236 | - ami-2014.03 237 | - debian-7.8 238 | - centos-7.2 239 | 240 | - name: amazon 241 | driver: 242 | vm_hostname: mongo3 243 | run_list: 244 | - recipe[mongodb3-test::amazon] 245 | - recipe[mongodb3::default] 246 | attributes: 247 | chef_client: 248 | config: 249 | force_logger: true 250 | log_level: info 251 | build-essential: 252 | compile_time: false 253 | provisioner: 254 | client_rb: 255 | environment: dev 256 | includes: 257 | - ami-2014.03 258 | -------------------------------------------------------------------------------- /.rubocop.yml: -------------------------------------------------------------------------------- 1 | AllCops: 2 | Exclude: 3 | - 'Berksfile' 4 | - 'Thorfile' 5 | - 'Vagrantfile' 6 | - 'Gemfile' 7 | - 'metadata.rb' 8 | 9 | AlignParameters: 10 | Enabled: false 11 | 12 | Encoding: 13 | Enabled: false 14 | 15 | LineLength: 16 | Max: 200 17 | 18 | HashSyntax: 19 | EnforcedStyle: hash_rockets 20 | 21 | AsciiComments: 22 | Enabled: false 23 | 24 | MethodLength: 25 | Max: 18 26 | 27 | Style/FileName: 28 | Enabled: false 29 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: ruby 2 | rvm: 3 | - 2.1.0 4 | bundler_args: --without integration 5 | gemfile: 6 | - Gemfile 7 | branches: 8 | only: 9 | - master 10 | - develop 11 | before_script: 12 | - bundle exec berks 13 | script: 14 | - bundle exec foodcritic . 15 | - bundle exec rspec test/libraries 16 | -------------------------------------------------------------------------------- /Berksfile: -------------------------------------------------------------------------------- 1 | source "https://supermarket.chef.io" 2 | 3 | metadata 4 | 5 | group :integration do 6 | cookbook 'mongodb3-test', :path => './test/cookbooks/mongodb3-test' 7 | end 8 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # mongodb3 Cookbook CHANGELOG 2 | 3 | ## 5.3.0 4 | 5 | Thank you so much for your huge contribution on this release! 6 | 7 | * PR #36 : The mongos service shall be restarted to pick the new config. Jose Olcese([@jolcese](https://github.com/jolcese)) 8 | * PR #38 : Enable/Disable Transparent Huge Pages if needed. Dennis Pattmann([@dpattmann](https://github.com/dpattmann)) 9 | * The cookbook disable the Transparent Huge Pages by default. 10 | * PR #39 : Adding support for ubuntu 15.04 and 16.04. Marcin Skurski([@mskurski](https://github.com/mskurski)) 11 | * Changing service provider to `Chef::Provider::Service::Systemd` for ubuntu >= 15.04 12 | * Fix #44 13 | * PR #40 : Allow override of the cookbook used for mongos runit templates. Popsikle([@popsikle](https://github.com/popsikle)) 14 | * PR #41 : Create and set ownership of data directory for mms-automation-agent. Amsdard([@amsdard](https://github.com/amsdard)) 15 | * Adding support Ubuntu 15.04 and 16.04 for MMS Automation and Monitoring Agent. 16 | * Testing in CentOS 6.8. 17 | * 6.6 was missing in bento. 18 | * No longer support Chef Client version 11. 19 | * Chef Client version issue related to Custom Resources 20 | * It is also decision for upcoming LWRP in mongodb3 cookbook. 21 | 22 | ## 5.2.0 23 | 24 | * PR #35 : bypass dpkg errors about pre-existing init or conf file. Damien Raude-Morvan([@drazzib](https://github.com/drazzib)) 25 | * Fix #34 : Supporting all the MMS Automation/Monitoring agent configuration options. 26 | * Updating default version of MongoDB package installation as 3.2.4 27 | 28 | ## 5.1.0 29 | 30 | * Feature request #31 : Creating sysLog directory for mongod 31 | * Fixing #30 : Changing service provider as `Chef::Provider::Service::Upstart` for ubuntu 14.04 32 | 33 | ## 5.0.0 34 | 35 | * 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. 36 | * Adding test for chef client 11.18.12 as 11.x : testing for #21 37 | * Adding kitchen test for ubuntu 14.04 : #13 38 | * Using `/var/run/mongodb/mongod.pid` for centos7 : #25 39 | * Moving attribute setter to recipe in order to support install 3.0.x in wrapper cookbook. : #23 40 | * Adding the mongodb 3.0.x version testing in test wrapper cookbook : #23 41 | * Adding key file directory creation 42 | * Fixing for yum and apt repo name 43 | * Update default version as 3.2.1 : #24 44 | 45 | ## 4.0.0 46 | 47 | Thank you so much for your contribution! 48 | 49 | * Allowed overrides of mongo repo name for debian/ubuntu packages - Dave Augustus([@daugustus](https://github.com/daugustus)) 50 | * Added support for MongoDB 3.2.0 - Constantin Guay([@Cog-g](https://github.com/Cog-g)) 51 | * Support for both MongoDB 3.0.x and 3.2.x - Julien Pervillé([@jperville](https://github.com/jperville)) 52 | 53 | ## 3.0.0 54 | * Update the default MongoDB package version to 3.0.7 55 | * Update README.md #8 56 | * Make keyserver configurable and fix faraday (berkshelf version bump) #11 57 | * Adding support for Amazon Linux and Debian 7.8 #10 58 | * Removing support for CentOS 5 : It seems like, there is some issue on package that MongoDB provided. 59 | * 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. 60 | 61 | NOTICE : 62 | 63 | * 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). 64 | * Current version 3.0.0 is not supporting automation and monitoring mms agent installation for Debian 7.8 65 | 66 | ## 2.0.0 67 | 68 | WARNING : `mms-agent` recipe has been deprecated at this version. 69 | 70 | * Removing `mongodb-org` package installation : `mongodb-org` package installs latest version of mongodb modules such as `mongodb-org-server`. so that installing lower version of mongodb-org-server has been failed. 71 | * Removing `mms-agent` recipe and divide it as `mms-automation-agent` and `mms-monitoring-agent` recipe 72 | * PR #3 : Bump up the runit dependency version to 1.7.0. Thank you for your contribution @dherges 73 | 74 | ## 1.0.0 75 | 76 | mongodb3 Chef Cookbook 1.0.0 release. 77 | 78 | ## 0.2.0 79 | 80 | Bug fixes. 81 | 82 | ## 0.1.0 83 | 84 | Initial release of mongodb3 85 | 86 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | gem 'berkshelf', '~> 4.0.1' 4 | gem 'test-kitchen', '~> 1.4.0' 5 | gem 'foodcritic', '4.0.0' 6 | 7 | group :integration do 8 | gem 'kitchen-vagrant', '~> 0.18.0' 9 | end 10 | 11 | group :test do 12 | gem 'chef', '11.10' 13 | gem 'rspec', '~> 3.1' 14 | end 15 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright 2015 Sunggun Yu 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # mongodb3 cookbook 2 | 3 | [![Build Status](https://travis-ci.org/sunggun-yu/chef-mongodb3.svg?branch=master)](https://travis-ci.org/sunggun-yu/chef-mongodb3) 4 | 5 | ## Install and configure the MongoDB 3 6 | 7 | * Install and configure the mongod (or configure the config server for shard cluster) 8 | * Install and configure the mongos 9 | * Also, mongos configure the mongos service with runit : `service mongos start|stop|restart|status` 10 | * Install and configure the MMS Automation Agent 11 | * Install and configure the MMS Monitoring Agent 12 | 13 | ### NOTICE : 14 | 15 | * Current version is not supporting automation and monitoring mms agent installation for Debian 7.8. 16 | * MongoDB **3.2.8** is default version of mongodb3 cookbook. 17 | * Mongodb3 cookbook is **NO LONGER SUPPORT** Chef Client version 11. 18 | 19 | ### Contributors 20 | 21 | * David Herges - [@dherges](https://github.com/dherges) 22 | * Joe Passavanti - [@gottaloveit](https://github.com/gottaloveit) 23 | * MEGA MOnolithic meTHod - [@megamoth](https://github.com/megamoth) 24 | * Dave Augustus - [@daugustus](https://github.com/daugustus) 25 | * Constantin Guay - [@Cog-g](https://github.com/Cog-g) 26 | * Julien Pervillé - [@jperville](https://github.com/jperville) 27 | * Daniel Doubrov - [@dblock](https://github.com/dblock) 28 | * Damien Raude-Morvan - [@drazzib](https://github.com/drazzib) 29 | * Jose Olcese - [@jolcese](https://github.com/jolcese) 30 | * Dennis Pattmann - [@dpattmann](https://github.com/dpattmann) 31 | * Marcin Skurski - [@mskurski](https://github.com/mskurski) 32 | * Popsikle - [@popsikle](https://github.com/popsikle) 33 | * Amsdard - [@amsdard](https://github.com/amsdard) 34 | 35 | ## Supported Platforms 36 | 37 | The following platforms have been tested with Test Kitchen 38 | 39 | * Ubuntu 12.04, 14.04, 15.04, 16.04 40 | * Debian 7.8 41 | * CentOS 6.8, 7.2 42 | * Oralce 6.6 43 | * Amazon Linux 44 | 45 | ## Attributes 46 | 47 | ### Cookbook Attributes 48 | mongodb3 cookbook uses the package installation of mongodb3 such as yum or apt. and these attributes are used for setting default values in order to provide the correct installation of mongodb3. typically, you can modify cookbook attributes if you need. however, I do not recommend to modify these attributes if you want to use package that is provided from MongoDB. 49 | 50 | WARNING : Please do not set the user and group attribute on your side. This cook book let installing user and group by mongodb package (except `mongos` and `mms-monitoring-agent` recipe). The user and group name will be set by condition in default attribute because mongodb package installs different user and group name by platform. 51 | 52 | ``` 53 | # MongoDB version to install 54 | default['mongodb3']['version'] = '3.2.1' 55 | default['mongodb3']['package']['version'] = Actual package version to install. It builds from version attribute. 56 | 57 | # Package repository url 58 | default['mongodb3']['package']['repo']['url'] = Package repository url 59 | 60 | # Attribute for apt_repository 61 | default['mongodb3']['package']['repo']['apt']['name'] = nil # eg. 3.0, 3.2 62 | default['mongodb3']['package']['repo']['apt']['keyserver'] = nil # eg. hkp://keyserver.ubuntu.com:80 63 | default['mongodb3']['package']['repo']['apt']['key'] = nil # eg. 3.2 : 'EA312927', 3.0 : '7F0CEB10' 64 | default['mongodb3']['package']['repo']['apt']['components'] = nil # `multiverse` for ubuntu. `main` for debian 65 | 66 | # MongoDB user:group : PLEASE DO NOT SET THE USER AND GROUP ATTRIBUTE 67 | default['mongodb3']['user'] = 'mongod' | 'mongodb' 68 | default['mongodb3']['group'] = 'mongod' | 'mongodb' 69 | 70 | # Mongod config file path 71 | default['mongodb3']['mongod']['config_file'] = '/etc/mongod.conf' 72 | 73 | # Mongos config file path 74 | default['mongodb3']['mongos']['config_file'] = '/etc/mongos.conf' 75 | 76 | # Runit template cookbook for mongos 77 | default['mongodb3']['mongos']['runit_template_cookbook'] = 'mongodb3' 78 | 79 | # Key file contents 80 | default['mongodb3']['config']['key_file_content'] = nil 81 | ``` 82 | 83 | ### Mongod config Attributes 84 | 85 | * The default value of the attribute is referred to the MongoDB documentation. 86 | * The `nil` value attribute will be ignored for mongod config file. 87 | * This cookbook fills nil for some of the attribute value to concise initial mongod config file. 88 | * Also, deprecated attributed is not included. 89 | 90 | #### systemLog Options 91 | 92 | http://docs.mongodb.org/manual/reference/configuration-options/#systemlog-options 93 | 94 | ``` 95 | default['mongodb3']['config']['mongod']['systemLog']['verbosity'] = nil # default : 0 96 | default['mongodb3']['config']['mongod']['systemLog']['quiet'] = nil # default : false 97 | default['mongodb3']['config']['mongod']['systemLog']['traceAllException'] = nil # default : false 98 | default['mongodb3']['config']['mongod']['systemLog']['syslogFacility'] = nil # default : 'user' 99 | default['mongodb3']['config']['mongod']['systemLog']['path'] = '/var/log/mongodb/mongod.log' 100 | default['mongodb3']['config']['mongod']['systemLog']['logAppend'] = true # default : false 101 | default['mongodb3']['config']['mongod']['systemLog']['logRotate'] = nil # default : 'rename' 102 | default['mongodb3']['config']['mongod']['systemLog']['destination'] = 'file' # default : 'file' 103 | default['mongodb3']['config']['mongod']['systemLog']['timeStampFormat'] = nil # default : 'iso8601-local' 104 | ``` 105 | 106 | #### systemLog.component Options 107 | 108 | http://docs.mongodb.org/manual/reference/configuration-options/#systemlog-component-options 109 | 110 | ``` 111 | default['mongodb3']['config']['mongod']['systemLog']['component']['accessControl']['verbosity'] = nil # default : 0 112 | default['mongodb3']['config']['mongod']['systemLog']['component']['command']['verbosity'] = nil # default : 0 113 | default['mongodb3']['config']['mongod']['systemLog']['component']['control']['verbosity'] = nil # default : 0 114 | default['mongodb3']['config']['mongod']['systemLog']['component']['geo']['verbosity'] = nil # default : 0 115 | default['mongodb3']['config']['mongod']['systemLog']['component']['index']['verbosity'] = nil # default : 0 116 | default['mongodb3']['config']['mongod']['systemLog']['component']['network']['verbosity'] = nil # default : 0 117 | default['mongodb3']['config']['mongod']['systemLog']['component']['query']['verbosity'] = nil # default : 0 118 | default['mongodb3']['config']['mongod']['systemLog']['component']['replication']['verbosity'] = nil # default : 0 119 | default['mongodb3']['config']['mongod']['systemLog']['component']['sharding']['verbosity'] = nil # default : 0 120 | default['mongodb3']['config']['mongod']['systemLog']['component']['storage']['verbosity'] = nil # default : 0 121 | default['mongodb3']['config']['mongod']['systemLog']['component']['storage']['journal']['verbosity'] = nil # default : 0 122 | default['mongodb3']['config']['mongod']['systemLog']['component']['write']['verbosity'] = nil # default : 0 123 | ``` 124 | 125 | #### processManagement Options 126 | 127 | http://docs.mongodb.org/manual/reference/configuration-options/#processmanagement-options 128 | 129 | ``` 130 | default['mongodb3']['config']['mongod']['processManagement']['fork'] = true or nil # default : false 131 | default['mongodb3']['config']['mongod']['processManagement']['pidFilePath'] = '/var/run/mongodb/mongodb.pid' or nil 132 | ``` 133 | 134 | #### net Options 135 | 136 | http://docs.mongodb.org/manual/reference/configuration-options/#net-options 137 | 138 | ``` 139 | default['mongodb3']['config']['mongod']['net']['port'] = 27017 140 | default['mongodb3']['config']['mongod']['net']['bindIp'] = nil # default : '0.0.0.0' 141 | default['mongodb3']['config']['mongod']['net']['maxIncomingConnections'] = nil # default : 65536 142 | default['mongodb3']['config']['mongod']['net']['wireObjectCheck'] = nil # default : true 143 | default['mongodb3']['config']['mongod']['net']['ipv6'] = nil # default : false 144 | ``` 145 | 146 | #### net.unixDomainSocket Options 147 | 148 | http://docs.mongodb.org/manual/reference/configuration-options/#net-unixdomainsocket-options 149 | 150 | ``` 151 | default['mongodb3']['config']['mongod']['net']['unixDomainSocket']['enabled'] = nil # default : true 152 | default['mongodb3']['config']['mongod']['net']['unixDomainSocket']['pathPrefix'] = nil # default : '/tmp' 153 | default['mongodb3']['config']['mongod']['net']['unixDomainSocket']['filePermissions'] = nil # default : '0700' 154 | ``` 155 | 156 | #### net.http Options 157 | 158 | http://docs.mongodb.org/manual/reference/configuration-options/#net-http-options 159 | 160 | ``` 161 | default['mongodb3']['config']['mongod']['net']['http']['enabled'] = nil # default : false 162 | default['mongodb3']['config']['mongod']['net']['http']['JSONPEnabled'] = nil # default : false 163 | default['mongodb3']['config']['mongod']['net']['http']['RESTInterfaceEnabled'] = nil # default : false 164 | ``` 165 | 166 | #### net.ssl Options 167 | 168 | http://docs.mongodb.org/manual/reference/configuration-options/#net-ssl-options 169 | 170 | ``` 171 | default['mongodb3']['config']['mongod']['net']['ssl']['mode'] = nil 172 | default['mongodb3']['config']['mongod']['net']['ssl']['PEMKeyFile'] = nil 173 | default['mongodb3']['config']['mongod']['net']['ssl']['PEMKeyPassword'] = nil 174 | default['mongodb3']['config']['mongod']['net']['ssl']['clusterFile'] = nil 175 | default['mongodb3']['config']['mongod']['net']['ssl']['clusterPassword'] = nil 176 | default['mongodb3']['config']['mongod']['net']['ssl']['CAFile'] = nil 177 | default['mongodb3']['config']['mongod']['net']['ssl']['CRLFile'] = nil 178 | default['mongodb3']['config']['mongod']['net']['ssl']['allowConnectionsWithoutCertificates'] = nil 179 | default['mongodb3']['config']['mongod']['net']['ssl']['allowInvalidCertificates'] = nil 180 | default['mongodb3']['config']['mongod']['net']['ssl']['allowInvalidHostnames'] = nil # default : false 181 | default['mongodb3']['config']['mongod']['net']['ssl']['FIPSMode'] = nil 182 | ``` 183 | 184 | #### security Options 185 | 186 | http://docs.mongodb.org/manual/reference/configuration-options/#security-options 187 | 188 | ``` 189 | default['mongodb3']['config']['mongod']['security']['keyFile'] = nil 190 | default['mongodb3']['config']['mongod']['security']['clusterAuthMode'] = nil 191 | default['mongodb3']['config']['mongod']['security']['authorization'] = 'disabled' 192 | default['mongodb3']['config']['mongod']['security']['javascriptEnabled'] = nil # default : true 193 | ``` 194 | 195 | #### security.sasl Options 196 | 197 | http://docs.mongodb.org/manual/reference/configuration-options/#security-sasl-options 198 | 199 | ``` 200 | default['mongodb3']['config']['mongod']['security']['sasl']['hostName'] = nil 201 | default['mongodb3']['config']['mongod']['security']['sasl']['serviceName'] = nil 202 | default['mongodb3']['config']['mongod']['security']['sasl']['saslauthdSocketPath'] = nil 203 | ``` 204 | 205 | #### storage Options 206 | 207 | http://docs.mongodb.org/manual/reference/configuration-options/#storage-options 208 | 209 | ``` 210 | default['mongodb3']['config']['mongod']['storage']['dbPath'] = '/var/lib/mongo' | '/var/lib/mongodb' 211 | default['mongodb3']['config']['mongod']['storage']['indexBuildRetry'] = nil # default : true 212 | default['mongodb3']['config']['mongod']['storage']['repairPath'] = nil 213 | default['mongodb3']['config']['mongod']['storage']['journal']['enabled'] = true 214 | default['mongodb3']['config']['mongod']['storage']['directoryPerDB'] = nil # default : false 215 | default['mongodb3']['config']['mongod']['storage']['syncPeriodSecs'] = nil # default : 60 216 | default['mongodb3']['config']['mongod']['storage']['engine'] = 'mmapv1' 217 | ``` 218 | 219 | #### storage.mmapv1 Options 220 | 221 | http://docs.mongodb.org/manual/reference/configuration-options/#storage-mmapv1-options 222 | 223 | ``` 224 | default['mongodb3']['config']['mongod']['storage']['mmapv1']['preallocDataFiles'] = nil # default : true 225 | default['mongodb3']['config']['mongod']['storage']['mmapv1']['nsSize'] = nil # default : 16 226 | default['mongodb3']['config']['mongod']['storage']['mmapv1']['quota']['enforced'] = nil # default : false 227 | default['mongodb3']['config']['mongod']['storage']['mmapv1']['quota']['maxFilesPerDB'] = nil # default : 8 228 | default['mongodb3']['config']['mongod']['storage']['mmapv1']['smallFiles'] = nil # default : false 229 | default['mongodb3']['config']['mongod']['storage']['mmapv1']['journal']['debugFlags'] = nil 230 | default['mongodb3']['config']['mongod']['storage']['mmapv1']['journal']['commitIntervalMs'] = nil # default : 100 or 30 231 | ``` 232 | 233 | #### storage.wiredTiger Options 234 | 235 | http://docs.mongodb.org/manual/reference/configuration-options/#storage-wiredtiger-options 236 | 237 | ``` 238 | default['mongodb3']['config']['mongod']['storage']['wiredTiger']['engineConfig']['cacheSizeGB'] = nil 239 | default['mongodb3']['config']['mongod']['storage']['wiredTiger']['engineConfig']['statisticsLogDelaySecs'] = nil # default : 0 240 | default['mongodb3']['config']['mongod']['storage']['wiredTiger']['engineConfig']['journalCompressor'] = nil # default : 'snappy' 241 | default['mongodb3']['config']['mongod']['storage']['wiredTiger']['engineConfig']['directoryForIndexes'] = nil # default : false 242 | default['mongodb3']['config']['mongod']['storage']['wiredTiger']['collectionConfig']['blockCompressor'] = nil # default : 'snappy' 243 | default['mongodb3']['config']['mongod']['storage']['wiredTiger']['indexConfig']['prefixCompression'] = nil # default : true 244 | ``` 245 | 246 | #### operationProfiling Options 247 | 248 | http://docs.mongodb.org/manual/reference/configuration-options/#operationprofiling-options 249 | 250 | ``` 251 | default['mongodb3']['config']['mongod']['operationProfiling']['slowOpThresholdMs'] = nil # default : 100 252 | default['mongodb3']['config']['mongod']['operationProfiling']['mode'] = nil # default : 'off' 253 | ``` 254 | 255 | #### replication Options 256 | 257 | http://docs.mongodb.org/manual/reference/configuration-options/#replication-options 258 | 259 | ``` 260 | default['mongodb3']['config']['mongod']['replication']['oplogSizeMB'] = nil 261 | default['mongodb3']['config']['mongod']['replication']['replSetName'] = nil 262 | default['mongodb3']['config']['mongod']['replication']['secondaryIndexPrefetch'] = nil # default : 'all' 263 | ``` 264 | 265 | #### sharding Options 266 | 267 | http://docs.mongodb.org/manual/reference/configuration-options/#sharding-options 268 | 269 | ``` 270 | default['mongodb3']['config']['mongod']['sharding']['clusterRole'] = nil 271 | default['mongodb3']['config']['mongod']['sharding']['archiveMovedChunks'] = nil # default : true 272 | ``` 273 | 274 | #### auditLog Options 275 | 276 | http://docs.mongodb.org/manual/reference/configuration-options/#auditlog-options 277 | 278 | ``` 279 | default['mongodb3']['config']['mongod']['auditLog']['destination'] = nil 280 | default['mongodb3']['config']['mongod']['auditLog']['format'] = nil 281 | default['mongodb3']['config']['mongod']['auditLog']['path'] = nil 282 | default['mongodb3']['config']['mongod']['auditLog']['filter'] = nil 283 | ``` 284 | 285 | #### snmp Options 286 | 287 | http://docs.mongodb.org/manual/reference/configuration-options/#snmp-options 288 | 289 | ``` 290 | default['mongodb3']['config']['mongod']['snmp']['subagent'] = nil 291 | default['mongodb3']['config']['mongod']['snmp']['master'] = nil 292 | ``` 293 | 294 | ### Mongos config Attributes 295 | 296 | #### Default config for mongos 297 | 298 | ``` 299 | default['mongodb3']['config']['mongos']['net']['port'] = 27018 # default : 27017 300 | default['mongodb3']['config']['mongos']['net']['bindIp'] = '127.0.0.1' # default : '0.0.0.0' 301 | default['mongodb3']['config']['mongos']['systemLog']['path'] = '/var/log/mongodb/mongos.log' 302 | default['mongodb3']['config']['mongos']['systemLog']['logAppend'] = true # default : false 303 | default['mongodb3']['config']['mongos']['systemLog']['destination'] = 'file' # default : 'file' 304 | ``` 305 | 306 | #### mongos-only Options 307 | 308 | http://docs.mongodb.org/manual/reference/configuration-options/#mongos-only-options 309 | 310 | ``` 311 | default['mongodb3']['config']['mongos']['replication']['localPingThresholdMs'] = nil # default : 15 312 | default['mongodb3']['config']['mongos']['sharding']['autoSplit'] = true # default : true 313 | default['mongodb3']['config']['mongos']['sharding']['configDB'] = nil 314 | default['mongodb3']['config']['mongos']['sharding']['chunkSize'] = 64 # default : 64 315 | ``` 316 | 317 | ### MMS Automation/Monitoring Agent 318 | 319 | #### Common configuration attributes for both automation and monitoring agent. 320 | ``` 321 | default['mongodb3']['config']['mms']['mmsApiKey'] = nil 322 | default['mongodb3']['config']['mms']['mmsBaseUrl'] = 'https://api-agents.mongodb.com' 323 | default['mongodb3']['config']['mms']['httpProxy'] = nil 324 | default['mongodb3']['config']['mms']['krb5ConfigLocation'] = nil 325 | default['mongodb3']['config']['mms']['sslTrustedMMSServerCertificate'] = nil 326 | default['mongodb3']['config']['mms']['sslRequireValidMMSServerCertificates'] = nil 327 | ``` 328 | 329 | #### Attributes for automation agent. 330 | https://docs.opsmanager.mongodb.com/current/reference/automation-agent 331 | ``` 332 | default['mongodb3']['config']['mms']['mmsGroupId'] = nil 333 | default['mongodb3']['config']['mms']['logFile'] = '/var/log/mongodb-mms-automation/automation-agent.log' 334 | default['mongodb3']['config']['mms']['mmsConfigBackup'] = '/var/lib/mongodb-mms-automation/mms-cluster-config-backup.json' 335 | default['mongodb3']['config']['mms']['logLevel'] = 'INFO' 336 | default['mongodb3']['config']['mms']['maxLogFiles'] = 10 337 | default['mongodb3']['config']['mms']['maxLogFileSize'] = 268435456 338 | ``` 339 | 340 | #### Attributes for monitoring agent. 341 | https://docs.opsmanager.mongodb.com/current/reference/monitoring-agent 342 | ``` 343 | default['mongodb3']['config']['mms']['useSslForAllConnections'] = nil 344 | default['mongodb3']['config']['mms']['sslClientCertificate'] = nil 345 | default['mongodb3']['config']['mms']['sslClientCertificatePassword'] = nil 346 | default['mongodb3']['config']['mms']['sslTrustedServerCertificates'] = nil 347 | default['mongodb3']['config']['mms']['sslRequireValidServerCertificates'] = nil 348 | default['mongodb3']['config']['mms']['krb5Principal'] = nil 349 | default['mongodb3']['config']['mms']['krb5Keytab'] = nil 350 | default['mongodb3']['config']['mms']['gsappiServiceName'] = nil 351 | default['mongodb3']['config']['mms']['enableMunin'] = nil 352 | ``` 353 | 354 | 355 | ## Usage 356 | 357 | ### mongodb3::default 358 | 359 | Install and configure the mongod or config server instance. 360 | 361 | Include `mongodb3::default` in your node's `run_list`: 362 | 363 | ```json 364 | { 365 | "run_list": [ 366 | "recipe[mongodb3::default]" 367 | ] 368 | } 369 | ``` 370 | 371 | ### mongodb3::mongos 372 | 373 | Install and configure the mongos. 374 | 375 | Include `mongodb3::mongos` in your node's `run_list`: 376 | 377 | ```json 378 | { 379 | "run_list": [ 380 | "recipe[mongodb3::mongos]" 381 | ] 382 | } 383 | ``` 384 | 385 | ### mongodb3::mms\_automation_agent 386 | 387 | Install the MMS Automation Agent. 388 | 389 | Include `mongodb3::mms_automation_agent` in your node's `run_list`: 390 | 391 | ```json 392 | { 393 | "run_list": [ 394 | "recipe[mongodb3::mms_automation_agent]" 395 | ] 396 | } 397 | ``` 398 | 399 | ### mongodb3::mms\_monitoring_agent 400 | 401 | Install the MMS Monitoring Agent. 402 | 403 | Include `mongodb3::mms_monitoring_agent` in your node's `run_list`: 404 | 405 | ```json 406 | { 407 | "run_list": [ 408 | "recipe[mongodb3::mms_monitoring_agent]" 409 | ] 410 | } 411 | ``` 412 | 413 | ## Examples 414 | 415 | ### Default mongod.conf file contents 416 | 417 | Simply `mongodb3::default` recipe with none of additional attribute setting 418 | 419 | ```json 420 | { 421 | "run_list": [ 422 | "recipe[mongodb3::default]" 423 | ] 424 | } 425 | ``` 426 | 427 | #### Result of mongod.conf 428 | 429 | ```text 430 | # THIS FILE IS MAINTAINED BY CHEF. DO NOT MODIFY AS IT WILL BE OVERWRITTEN. 431 | --- 432 | systemLog: 433 | path: /var/log/mongodb/mongod.log 434 | logAppend: true 435 | destination: file 436 | net: 437 | port: 27017 438 | security: 439 | authorization: disabled 440 | storage: 441 | dbPath: /var/lib/mongodb 442 | journal: 443 | enabled: true 444 | engine: mmapv1 445 | ``` 446 | 447 | ### Replicaset 448 | 449 | #### Role file 450 | 451 | You can set the config attribute on node or wrapper recipe. 452 | 453 | ```json 454 | { 455 | "name": "replica", 456 | "description": "Role for Replica set", 457 | "json_class": "Chef::Role", 458 | "default_attributes": { 459 | "mongodb3" : { 460 | "config" : { 461 | "mongod" : { 462 | "replication" : { 463 | "replSetName" : "replset-1" 464 | } 465 | } 466 | } 467 | } 468 | }, 469 | "override_attributes": { 470 | }, 471 | "chef_type": "role", 472 | "run_list": [ 473 | "recipe[mongodb3::default]" 474 | ], 475 | "env_run_lists": { 476 | } 477 | } 478 | ``` 479 | 480 | #### Result of mongod.conf 481 | 482 | ```text 483 | # THIS FILE IS MAINTAINED BY CHEF. DO NOT MODIFY AS IT WILL BE OVERWRITTEN. 484 | --- 485 | systemLog: 486 | path: /var/log/mongodb/mongod.log 487 | logAppend: true 488 | destination: file 489 | net: 490 | port: 27017 491 | security: 492 | authorization: disabled 493 | storage: 494 | dbPath: /var/lib/mongodb 495 | journal: 496 | enabled: true 497 | engine: mmapv1 498 | replication: 499 | replSetName: replset-1 500 | ``` 501 | 502 | ### Config server 503 | 504 | #### Role file 505 | 506 | You can set the config attribute on node or wrapper recipe. 507 | 508 | ```json 509 | { 510 | "name": "configsvr", 511 | "description": "Role for MongoDB Config server", 512 | "json_class": "Chef::Role", 513 | "default_attributes": { 514 | "mongodb3": { 515 | "config" : { 516 | "mongod" : { 517 | "net" : { 518 | "port" : 27019 519 | }, 520 | "sharding" : { 521 | "clusterRole" : "configsvr" 522 | } 523 | } 524 | } 525 | } 526 | }, 527 | "override_attributes": { 528 | }, 529 | "chef_type": "role", 530 | "run_list": [ 531 | "recipe[mongodb3::default]" 532 | ], 533 | "env_run_lists": { 534 | } 535 | } 536 | ``` 537 | 538 | #### Result of mongod.conf 539 | 540 | ```text 541 | # THIS FILE IS MAINTAINED BY CHEF. DO NOT MODIFY AS IT WILL BE OVERWRITTEN. 542 | --- 543 | systemLog: 544 | path: /var/log/mongodb/mongod.log 545 | logAppend: true 546 | destination: file 547 | net: 548 | port: 27019 549 | security: 550 | authorization: disabled 551 | storage: 552 | dbPath: /var/lib/mongodb 553 | journal: 554 | enabled: true 555 | engine: mmapv1 556 | sharding: 557 | clusterRole: configsvr 558 | ``` 559 | 560 | ### WiredTiger storage engine config 561 | 562 | #### Role file 563 | 564 | You can set the config attribute on node or wrapper recipe. 565 | 566 | ```json 567 | { 568 | "name": "wired_tiger", 569 | "description": "Role for testing Wired Tiger storage engine", 570 | "json_class": "Chef::Role", 571 | "default_attributes": { 572 | "mongodb3" : { 573 | "config" : { 574 | "mongod" : { 575 | "storage" : { 576 | "dbPath" : "/var/lib/mongodb/wiredTiger", 577 | "engine" : "wiredTiger", 578 | "wiredTiger" : { 579 | "engineConfig" : { 580 | "cacheSizeGB" : 10, 581 | "statisticsLogDelaySecs" : 60, 582 | "journalCompressor" : "snappy", 583 | "directoryForIndexes" : false 584 | }, 585 | "collectionConfig" : { 586 | "blockCompressor" : "snappy" 587 | }, 588 | "indexConfig" : { 589 | "prefixCompression" : true 590 | } 591 | } 592 | } 593 | } 594 | } 595 | } 596 | }, 597 | "override_attributes": { 598 | }, 599 | "chef_type": "role", 600 | "run_list": [ 601 | "recipe[mongodb3::default]" 602 | ], 603 | "env_run_lists": { 604 | } 605 | } 606 | 607 | ``` 608 | 609 | #### Result of mongod.conf 610 | 611 | ```text 612 | # THIS FILE IS MAINTAINED BY CHEF. DO NOT MODIFY AS IT WILL BE OVERWRITTEN. 613 | --- 614 | systemLog: 615 | path: /var/log/mongodb/mongod.log 616 | logAppend: true 617 | destination: file 618 | net: 619 | port: 27017 620 | security: 621 | authorization: disabled 622 | storage: 623 | dbPath: /var/lib/mongodb/wiredTiger 624 | journal: 625 | enabled: true 626 | engine: wiredTiger 627 | wiredTiger: 628 | engineConfig: 629 | cacheSizeGB: 10 630 | statisticsLogDelaySecs: 60 631 | journalCompressor: snappy 632 | directoryForIndexes: false 633 | collectionConfig: 634 | blockCompressor: snappy 635 | indexConfig: 636 | prefixCompression: true 637 | ``` 638 | 639 | ### Mongos 640 | 641 | #### Role file 642 | 643 | You can set the config attribute on node or wrapper recipe. 644 | 645 | ```json 646 | { 647 | "name": "mongos", 648 | "description": "Role for Mongos", 649 | "json_class": "Chef::Role", 650 | "default_attributes": { 651 | "mongodb3" : { 652 | "config" : { 653 | "mongos" : { 654 | "sharding" : { 655 | "configDB" : "configsvr1:27019, configsvr2:27019, configsvr3:27019" 656 | } 657 | } 658 | } 659 | } 660 | }, 661 | "override_attributes": { 662 | }, 663 | "chef_type": "role", 664 | "run_list": [ 665 | "recipe[mongodb3::mongos]" 666 | ], 667 | "env_run_lists": { 668 | } 669 | } 670 | ``` 671 | 672 | #### Result of mongos.conf 673 | 674 | ```text 675 | # THIS FILE IS MAINTAINED BY CHEF. DO NOT MODIFY AS IT WILL BE OVERWRITTEN. 676 | --- 677 | net: 678 | port: 27017 679 | bindIp: 0.0.0.0 680 | systemLog: 681 | path: /var/log/mongodb/mongos.log 682 | logAppend: true 683 | destination: file 684 | sharding: 685 | autoSplit: true 686 | configDB: configsvr1:27019, configsvr2:27019, configsvr3:27019 687 | chunkSize: 64 688 | ``` 689 | 690 | ### MMS Automation agent 691 | 692 | #### Role file 693 | 694 | You can set the config attribute on node or wrapper recipe. 695 | 696 | ```json 697 | { 698 | "name": "mms_automation_agent", 699 | "description": "Role for MMS automation agent", 700 | "json_class": "Chef::Role", 701 | "default_attributes": { 702 | "mongodb3" : { 703 | "config" : { 704 | "mms" : { 705 | "mmsGroupId" : "grpgrpididid", 706 | "mmsApiKey" : "apikeykekekekeke" 707 | } 708 | } 709 | } 710 | }, 711 | "override_attributes": { 712 | }, 713 | "chef_type": "role", 714 | "run_list": [ 715 | "recipe[mongodb3::mms_automation_agent]" 716 | ], 717 | "env_run_lists": { 718 | } 719 | } 720 | 721 | ``` 722 | 723 | #### Result of `/etc/mongodb-mms/automation-agent.config` 724 | 725 | ```text 726 | # /etc/mongodb-mms/automation-agent.config 727 | 728 | # 729 | # REQUIRED 730 | # Enter your Group ID - It can be found at https://cloud.mongodb.com/settings/group 731 | # 732 | mmsGroupId=grpgrpididid 733 | 734 | # 735 | # REQUIRED 736 | # Enter your API key - It can be found at https://cloud.mongodb.com/settings/group 737 | # 738 | mmsApiKey=apikeykekekekeke 739 | 740 | # 741 | # Base url of the MMS web server. 742 | # 743 | mmsBaseUrl=https://api-agents.mongodb.com 744 | 745 | # 746 | # Path to log file 747 | # 748 | logFile=/var/log/mongodb-mms-automation/automation-agent.log 749 | 750 | # 751 | # Path to backup cluster config to 752 | # 753 | mmsConfigBackup=/var/lib/mongodb-mms-automation/mms-cluster-config-backup.json 754 | 755 | # 756 | # Lowest log level to log. Can be (in order): DEBUG, ROUTINE, INFO, WARN, ERROR, DOOM 757 | # 758 | logLevel=INFO 759 | 760 | # 761 | # Maximum number of rotated log files 762 | # 763 | maxLogFiles=10 764 | 765 | # 766 | # Maximum size in bytes of a log file (before rotating) 767 | # 768 | maxLogFileSize=268435456 769 | 770 | # 771 | # URL to proxy all HTTP requests through 772 | # 773 | #httpProxy= 774 | 775 | # 776 | # The absolute path to an non-system-standard location for the Kerberos configuration file 777 | # 778 | #krb5ConfigLocation= 779 | 780 | # 781 | # The path on disk that contains the trusted certificate authority certificates in PEM format. 782 | # 783 | #sslTrustedMMSServerCertificate= 784 | 785 | # 786 | # Use this option to disable certificate verification by setting this value to false. 787 | # 788 | #sslRequireValidMMSServerCertificates= 789 | 790 | # For additional optional settings, please see 791 | # https://docs.cloud.mongodb.com/reference/automation-agent/ 792 | 793 | 794 | ``` 795 | 796 | ### MMS Monitoring agent 797 | 798 | #### Role file 799 | 800 | You can set the config attribute on node or wrapper recipe. 801 | 802 | ```json 803 | { 804 | "name": "mms_monitoring_agent", 805 | "description": "Role for MMS monitoring agent", 806 | "json_class": "Chef::Role", 807 | "default_attributes": { 808 | "mongodb3" : { 809 | "config" : { 810 | "mms" : { 811 | "api_key" : "apikeykekekekeke" 812 | } 813 | } 814 | } 815 | }, 816 | "override_attributes": { 817 | }, 818 | "chef_type": "role", 819 | "run_list": [ 820 | "recipe[mongodb3::mms_monitoring_agent]" 821 | ], 822 | "env_run_lists": { 823 | } 824 | } 825 | 826 | ``` 827 | 828 | #### Result of `/etc/mongodb-mms/monitoring-agent.config` 829 | 830 | ```text 831 | # THIS FILE IS MAINTAINED BY CHEF. DO NOT MODIFY AS IT WILL BE OVERWRITTEN. 832 | 833 | # 834 | # Enter your API key - See: cloud.mongodb.com/settings/group 835 | # 836 | mmsApiKey=apikeykekekekeke 837 | 838 | # 839 | # Hostname of the MMS monitoring web server. 840 | # 841 | mmsBaseUrl=https://api-agents.mongodb.com 842 | 843 | # 844 | # URL to proxy all HTTP requests through 845 | # 846 | #httpProxy= 847 | 848 | # 849 | # Set to true to enable SSL support globally and to use SSL for all MongoDB connections. 850 | # 851 | #useSslForAllConnections= 852 | 853 | # 854 | # The path to the private key, client certificate, and optional intermediate certificates in PEM format 855 | # 856 | #sslClientCertificate= 857 | 858 | # 859 | # The password needed to decrypt the private key in the file specified in sslClientCertificate. 860 | # 861 | #sslClientCertificatePassword= 862 | 863 | # 864 | # The path on disk that contains the trusted certificate authority certificates in PEM format. 865 | # 866 | #sslTrustedServerCertificates= 867 | 868 | # 869 | # Use this option to disable certificate verification by setting this value to false. 870 | # 871 | #sslRequireValidServerCertificates= 872 | 873 | # 874 | # The Kerberos principal used by the agent. 875 | # 876 | #krb5Principal= 877 | 878 | # 879 | # The absolute path to Kerberos principal’s keytab file. 880 | # 881 | #krb5Keytab= 882 | 883 | # 884 | # The absolute path to an non-system-standard location for the Kerberos configuration file. 885 | # 886 | #krb5ConfigLocation= 887 | 888 | # 889 | # The default service name used by MongoDB is mongodb can specify a custom service name with the gssapiServiceName option. 890 | # 891 | #gsappiServiceName= 892 | 893 | # 894 | # By default the Monitoring Agent will use the trusted root CAs installed on the system. If the agent cannot find the trusted root CAs, configure these settings manually. 895 | # 896 | #sslTrustedMMSServerCertificate= 897 | 898 | # 899 | # You can disable certificate verification by setting this value to false. 900 | # 901 | #sslRequireValidMMSServerCertificates= 902 | 903 | # 904 | # Set to false if you do not with the Monitoring Agent to collect hardware statistics via Munin-node. 905 | # 906 | #enableMunin= 907 | 908 | 909 | # For additional optional settings, please see 910 | # https://docs.cloud.mongodb.com/reference/monitoring-agent/ 911 | 912 | ``` 913 | 914 | ## License and Authors 915 | 916 | Author:: Sunggun Yu (sunggun.dev@gmail.com) 917 | 918 | ```text 919 | Copyright (c) 2016, Sunggun Yu. 920 | 921 | Licensed under the Apache License, Version 2.0 (the "License"); 922 | you may not use this file except in compliance with the License. 923 | You may obtain a copy of the License at 924 | 925 | http://www.apache.org/licenses/LICENSE-2.0 926 | 927 | Unless required by applicable law or agreed to in writing, software 928 | distributed under the License is distributed on an "AS IS" BASIS, 929 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 930 | See the License for the specific language governing permissions and 931 | limitations under the License. 932 | ``` 933 | -------------------------------------------------------------------------------- /Thorfile: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require 'bundler' 4 | require 'bundler/setup' 5 | require 'berkshelf/thor' 6 | 7 | begin 8 | require "kitchen/thor_tasks" 9 | Kitchen::ThorTasks.new 10 | rescue LoadError 11 | puts ">>>>> Kitchen gem not loaded, omitting tasks" unless ENV["CI"] 12 | end 13 | -------------------------------------------------------------------------------- /Vagrantfile: -------------------------------------------------------------------------------- 1 | # -*- mode: ruby -*- 2 | # vi: set ft=ruby : 3 | 4 | # Vagrantfile API/syntax version. Don't touch unless you know what you're doing! 5 | VAGRANTFILE_API_VERSION = '2' 6 | 7 | Vagrant.require_version '>= 1.5.0' 8 | 9 | Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| 10 | # All Vagrant configuration is done here. The most common configuration 11 | # options are documented and commented below. For a complete reference, 12 | # please see the online documentation at vagrantup.com. 13 | 14 | config.vm.hostname = 'mongodb3-berkshelf' 15 | 16 | # Set the version of chef to install using the vagrant-omnibus plugin 17 | # NOTE: You will need to install the vagrant-omnibus plugin: 18 | # 19 | # $ vagrant plugin install vagrant-omnibus 20 | # 21 | if Vagrant.has_plugin?("vagrant-omnibus") 22 | config.omnibus.chef_version = 'latest' 23 | end 24 | 25 | # Every Vagrant virtual environment requires a box to build off of. 26 | # If this value is a shorthand to a box in Vagrant Cloud then 27 | # config.vm.box_url doesn't need to be specified. 28 | config.vm.box = 'chef/ubuntu-14.04' 29 | 30 | 31 | # Assign this VM to a host-only network IP, allowing you to access it 32 | # via the IP. Host-only networks can talk to the host machine as well as 33 | # any other machines on the same network, but cannot be accessed (through this 34 | # network interface) by any external networks. 35 | config.vm.network :private_network, type: 'dhcp' 36 | 37 | # Create a forwarded port mapping which allows access to a specific port 38 | # within the machine from a port on the host machine. In the example below, 39 | # accessing "localhost:8080" will access port 80 on the guest machine. 40 | 41 | # Share an additional folder to the guest VM. The first argument is 42 | # the path on the host to the actual folder. The second argument is 43 | # the path on the guest to mount the folder. And the optional third 44 | # argument is a set of non-required options. 45 | # config.vm.synced_folder "../data", "/vagrant_data" 46 | 47 | # Provider-specific configuration so you can fine-tune various 48 | # backing providers for Vagrant. These expose provider-specific options. 49 | # Example for VirtualBox: 50 | # 51 | # config.vm.provider :virtualbox do |vb| 52 | # # Don't boot with headless mode 53 | # vb.gui = true 54 | # 55 | # # Use VBoxManage to customize the VM. For example to change memory: 56 | # vb.customize ["modifyvm", :id, "--memory", "1024"] 57 | # end 58 | # 59 | # View the documentation for the provider you're using for more 60 | # information on available options. 61 | 62 | # The path to the Berksfile to use with Vagrant Berkshelf 63 | # config.berkshelf.berksfile_path = "./Berksfile" 64 | 65 | # Enabling the Berkshelf plugin. To enable this globally, add this configuration 66 | # option to your ~/.vagrant.d/Vagrantfile file 67 | config.berkshelf.enabled = true 68 | 69 | # An array of symbols representing groups of cookbook described in the Vagrantfile 70 | # to exclusively install and copy to Vagrant's shelf. 71 | # config.berkshelf.only = [] 72 | 73 | # An array of symbols representing groups of cookbook described in the Vagrantfile 74 | # to skip installing and copying to Vagrant's shelf. 75 | # config.berkshelf.except = [] 76 | 77 | config.vm.provision :chef_solo do |chef| 78 | chef.json = { 79 | mysql: { 80 | server_root_password: 'rootpass', 81 | server_debian_password: 'debpass', 82 | server_repl_password: 'replpass' 83 | } 84 | } 85 | 86 | chef.run_list = [ 87 | 'recipe[mongodb3::default]' 88 | ] 89 | end 90 | end 91 | -------------------------------------------------------------------------------- /attributes/default.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: mongodb3 3 | # Attribute:: default 4 | # 5 | # Copyright 2015, Sunggun Yu 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the 'License'); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an 'AS IS' BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | 20 | # MongoDB version to install 21 | default['mongodb3']['version'] = '3.2.8' 22 | 23 | # Please note : The default values for ['mongodb3']['package'] attributes will be set in `package_repo` recipe. 24 | # but, You can set custom values for yum/apt repo url, yum package version or apt related in your wrapper 25 | 26 | # MongoDB package version to install : eg. 3.0.8, 3.2.1, 3.2.1-1.el6 or 3.2.1-1.amzn1 27 | default['mongodb3']['package']['version'] = nil 28 | 29 | # MongoDB package repo url 30 | # eg. ubuntu : 'http://repo.mongodb.org/apt/ubuntu' 31 | # eg. centos : 'https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/3.2/x86_64/' 32 | default['mongodb3']['package']['repo']['url'] = nil 33 | 34 | # MongoDB repository info for apt 35 | default['mongodb3']['package']['repo']['apt']['name'] = nil # eg. 3.0, 3.2 36 | default['mongodb3']['package']['repo']['apt']['keyserver'] = nil # eg. hkp://keyserver.ubuntu.com:80 37 | default['mongodb3']['package']['repo']['apt']['key'] = nil # eg. 3.2 : 'EA312927', 3.0 : '7F0CEB10' 38 | default['mongodb3']['package']['repo']['apt']['components'] = nil # eg. ['multiverse'] 39 | 40 | # Default attribute for MongoDB installation 41 | case node['platform_family'] 42 | when 'rhel', 'fedora' 43 | mongo_user = 'mongod' 44 | mongo_group = 'mongod' 45 | mongo_dbpath = '/var/lib/mongo' 46 | # To guarantee the compatibility for centos 6 in previous version of mongodb3 cookbook 47 | if node['platform_version'].to_i >= 7 48 | mongo_pid_file = '/var/run/mongodb/mongod.pid' 49 | else 50 | mongo_pid_file = '/var/run/mongodb/mongodb.pid' 51 | end 52 | config_processManagement_fork = true 53 | when 'debian' 54 | mongo_user = 'mongodb' 55 | mongo_group = 'mongodb' 56 | mongo_dbpath = '/var/lib/mongodb' 57 | mongo_pid_file = nil 58 | config_processManagement_fork = nil 59 | end 60 | 61 | # MongoDB user:group 62 | default['mongodb3']['user'] = mongo_user 63 | default['mongodb3']['group'] = mongo_group 64 | 65 | # Mongod config file 66 | default['mongodb3']['mongod']['config_file'] = '/etc/mongod.conf' 67 | 68 | # Disable Transparent Huge Pages (THP) 69 | default['mongodb3']['mongod']['disable-transparent-hugepages'] = false 70 | 71 | # Mongos config file 72 | default['mongodb3']['mongos']['config_file'] = '/etc/mongos.conf' 73 | 74 | # Runit template cookbook for mongos 75 | default['mongodb3']['mongos']['runit_template_cookbook'] = 'mongodb3' 76 | 77 | # Key file contents 78 | default['mongodb3']['config']['key_file_content'] = nil 79 | 80 | # Key server 81 | default['mongodb3']['keyserver'] = 'hkp://keyserver.ubuntu.com:80' 82 | 83 | # Mongod config 84 | # The default value of the attribute is referred to the MongoDB documentation. 85 | # The attribute value of nil will be removed from mongod config file. 86 | # This cookbook fills nil for some of the attribute value to concise initial mongod config file. 87 | # Also, deprecated attributed is not applied. 88 | 89 | # systemLog Options : http://docs.mongodb.org/manual/reference/configuration-options/#systemlog-options 90 | default['mongodb3']['config']['mongod']['systemLog']['verbosity'] = nil # default : 0 91 | default['mongodb3']['config']['mongod']['systemLog']['quiet'] = nil # default : false 92 | default['mongodb3']['config']['mongod']['systemLog']['traceAllException'] = nil # default : false 93 | default['mongodb3']['config']['mongod']['systemLog']['syslogFacility'] = nil # default : 'user' 94 | default['mongodb3']['config']['mongod']['systemLog']['path'] = '/var/log/mongodb/mongod.log' 95 | default['mongodb3']['config']['mongod']['systemLog']['logAppend'] = true # default : false 96 | default['mongodb3']['config']['mongod']['systemLog']['logRotate'] = nil # default : 'rename' 97 | default['mongodb3']['config']['mongod']['systemLog']['destination'] = 'file' # default : 'file' 98 | default['mongodb3']['config']['mongod']['systemLog']['timeStampFormat'] = nil # default : 'iso8601-local' 99 | 100 | # systemLog.component Options : http://docs.mongodb.org/manual/reference/configuration-options/#systemlog-component-options 101 | default['mongodb3']['config']['mongod']['systemLog']['component']['accessControl']['verbosity'] = nil # default : 0 102 | default['mongodb3']['config']['mongod']['systemLog']['component']['command']['verbosity'] = nil # default : 0 103 | default['mongodb3']['config']['mongod']['systemLog']['component']['control']['verbosity'] = nil # default : 0 104 | default['mongodb3']['config']['mongod']['systemLog']['component']['geo']['verbosity'] = nil # default : 0 105 | default['mongodb3']['config']['mongod']['systemLog']['component']['index']['verbosity'] = nil # default : 0 106 | default['mongodb3']['config']['mongod']['systemLog']['component']['network']['verbosity'] = nil # default : 0 107 | default['mongodb3']['config']['mongod']['systemLog']['component']['query']['verbosity'] = nil # default : 0 108 | default['mongodb3']['config']['mongod']['systemLog']['component']['replication']['verbosity'] = nil # default : 0 109 | default['mongodb3']['config']['mongod']['systemLog']['component']['sharding']['verbosity'] = nil # default : 0 110 | default['mongodb3']['config']['mongod']['systemLog']['component']['storage']['verbosity'] = nil # default : 0 111 | default['mongodb3']['config']['mongod']['systemLog']['component']['storage']['journal']['verbosity'] = nil # default : 0 112 | default['mongodb3']['config']['mongod']['systemLog']['component']['write']['verbosity'] = nil # default : 0 113 | 114 | # processManagement Options : http://docs.mongodb.org/manual/reference/configuration-options/#processmanagement-options 115 | 116 | default['mongodb3']['config']['mongod']['processManagement']['fork'] = config_processManagement_fork # default : false 117 | default['mongodb3']['config']['mongod']['processManagement']['pidFilePath'] = mongo_pid_file 118 | 119 | # net Options : http://docs.mongodb.org/manual/reference/configuration-options/#net-options 120 | default['mongodb3']['config']['mongod']['net']['port'] = 27017 121 | default['mongodb3']['config']['mongod']['net']['bindIp'] = nil # default : '0.0.0.0' 122 | default['mongodb3']['config']['mongod']['net']['maxIncomingConnections'] = nil # default : 65536 123 | default['mongodb3']['config']['mongod']['net']['wireObjectCheck'] = nil # default : true 124 | default['mongodb3']['config']['mongod']['net']['ipv6'] = nil # default : false 125 | 126 | # net.unixDomainSocket Options : http://docs.mongodb.org/manual/reference/configuration-options/#net-unixdomainsocket-options 127 | default['mongodb3']['config']['mongod']['net']['unixDomainSocket']['enabled'] = nil # default : true 128 | default['mongodb3']['config']['mongod']['net']['unixDomainSocket']['pathPrefix'] = nil # default : '/tmp' 129 | default['mongodb3']['config']['mongod']['net']['unixDomainSocket']['filePermissions'] = nil # default : '0700' 130 | 131 | # net.http Options : http://docs.mongodb.org/manual/reference/configuration-options/#net-http-options 132 | default['mongodb3']['config']['mongod']['net']['http']['enabled'] = nil # default : false 133 | default['mongodb3']['config']['mongod']['net']['http']['JSONPEnabled'] = nil # default : false 134 | default['mongodb3']['config']['mongod']['net']['http']['RESTInterfaceEnabled'] = nil # default : false 135 | 136 | # net.ssl Options : http://docs.mongodb.org/manual/reference/configuration-options/#net-ssl-options 137 | default['mongodb3']['config']['mongod']['net']['ssl']['mode'] = nil 138 | default['mongodb3']['config']['mongod']['net']['ssl']['PEMKeyFile'] = nil 139 | default['mongodb3']['config']['mongod']['net']['ssl']['PEMKeyPassword'] = nil 140 | default['mongodb3']['config']['mongod']['net']['ssl']['clusterFile'] = nil 141 | default['mongodb3']['config']['mongod']['net']['ssl']['clusterPassword'] = nil 142 | default['mongodb3']['config']['mongod']['net']['ssl']['CAFile'] = nil 143 | default['mongodb3']['config']['mongod']['net']['ssl']['CRLFile'] = nil 144 | default['mongodb3']['config']['mongod']['net']['ssl']['allowConnectionsWithoutCertificates'] = nil 145 | default['mongodb3']['config']['mongod']['net']['ssl']['allowInvalidCertificates'] = nil 146 | default['mongodb3']['config']['mongod']['net']['ssl']['allowInvalidHostnames'] = nil # default : false 147 | default['mongodb3']['config']['mongod']['net']['ssl']['FIPSMode'] = nil 148 | 149 | # security Options : http://docs.mongodb.org/manual/reference/configuration-options/#security-options 150 | default['mongodb3']['config']['mongod']['security']['keyFile'] = nil 151 | default['mongodb3']['config']['mongod']['security']['clusterAuthMode'] = nil 152 | default['mongodb3']['config']['mongod']['security']['authorization'] = 'disabled' 153 | default['mongodb3']['config']['mongod']['security']['javascriptEnabled'] = nil # default : true 154 | 155 | # security.sasl Options : http://docs.mongodb.org/manual/reference/configuration-options/#security-sasl-options 156 | default['mongodb3']['config']['mongod']['security']['sasl']['hostName'] = nil 157 | default['mongodb3']['config']['mongod']['security']['sasl']['serviceName'] = nil 158 | default['mongodb3']['config']['mongod']['security']['sasl']['saslauthdSocketPath'] = nil 159 | 160 | # storage Options : http://docs.mongodb.org/manual/reference/configuration-options/#storage-options 161 | default['mongodb3']['config']['mongod']['storage']['dbPath'] = mongo_dbpath 162 | default['mongodb3']['config']['mongod']['storage']['indexBuildRetry'] = nil # default : true 163 | default['mongodb3']['config']['mongod']['storage']['repairPath'] = nil 164 | default['mongodb3']['config']['mongod']['storage']['journal']['enabled'] = true 165 | default['mongodb3']['config']['mongod']['storage']['directoryPerDB'] = nil # default : false 166 | default['mongodb3']['config']['mongod']['storage']['syncPeriodSecs'] = nil # default : 60 167 | default['mongodb3']['config']['mongod']['storage']['engine'] = nil # default - since 3.2 : wiredTiger, until 3.2 : mmapv1 168 | 169 | # storage.mmapv1 Options : http://docs.mongodb.org/manual/reference/configuration-options/#storage-mmapv1-options 170 | default['mongodb3']['config']['mongod']['storage']['mmapv1']['preallocDataFiles'] = nil # default : true 171 | default['mongodb3']['config']['mongod']['storage']['mmapv1']['nsSize'] = nil # default : 16 172 | default['mongodb3']['config']['mongod']['storage']['mmapv1']['quota']['enforced'] = nil # default : false 173 | default['mongodb3']['config']['mongod']['storage']['mmapv1']['quota']['maxFilesPerDB'] = nil # default : 8 174 | default['mongodb3']['config']['mongod']['storage']['mmapv1']['smallFiles'] = nil # default : false 175 | default['mongodb3']['config']['mongod']['storage']['mmapv1']['journal']['debugFlags'] = nil 176 | default['mongodb3']['config']['mongod']['storage']['mmapv1']['journal']['commitIntervalMs'] = nil # default : 100 or 30 177 | 178 | # storage.wiredTiger Options : http://docs.mongodb.org/manual/reference/configuration-options/#storage-wiredtiger-options 179 | default['mongodb3']['config']['mongod']['storage']['wiredTiger']['engineConfig']['cacheSizeGB'] = nil 180 | default['mongodb3']['config']['mongod']['storage']['wiredTiger']['engineConfig']['statisticsLogDelaySecs'] = nil # default : 0 181 | default['mongodb3']['config']['mongod']['storage']['wiredTiger']['engineConfig']['journalCompressor'] = nil # default : 'snappy' 182 | default['mongodb3']['config']['mongod']['storage']['wiredTiger']['engineConfig']['directoryForIndexes'] = nil # default : false 183 | default['mongodb3']['config']['mongod']['storage']['wiredTiger']['collectionConfig']['blockCompressor'] = nil # default : 'snappy' 184 | default['mongodb3']['config']['mongod']['storage']['wiredTiger']['indexConfig']['prefixCompression'] = nil # default : true 185 | 186 | # operationProfiling Options : http://docs.mongodb.org/manual/reference/configuration-options/#operationprofiling-options 187 | default['mongodb3']['config']['mongod']['operationProfiling']['slowOpThresholdMs'] = nil # default : 100 188 | default['mongodb3']['config']['mongod']['operationProfiling']['mode'] = nil # default : 'off' 189 | 190 | # replication Options : http://docs.mongodb.org/manual/reference/configuration-options/#replication-options 191 | default['mongodb3']['config']['mongod']['replication']['oplogSizeMB'] = nil 192 | default['mongodb3']['config']['mongod']['replication']['replSetName'] = nil 193 | default['mongodb3']['config']['mongod']['replication']['secondaryIndexPrefetch'] = nil # default : 'all' 194 | 195 | # sharding Options : http://docs.mongodb.org/manual/reference/configuration-options/#sharding-options 196 | default['mongodb3']['config']['mongod']['sharding']['clusterRole'] = nil 197 | default['mongodb3']['config']['mongod']['sharding']['archiveMovedChunks'] = nil # default : true 198 | 199 | # auditLog Options : http://docs.mongodb.org/manual/reference/configuration-options/#auditlog-options 200 | default['mongodb3']['config']['mongod']['auditLog']['destination'] = nil 201 | default['mongodb3']['config']['mongod']['auditLog']['format'] = nil 202 | default['mongodb3']['config']['mongod']['auditLog']['path'] = nil 203 | default['mongodb3']['config']['mongod']['auditLog']['filter'] = nil 204 | 205 | # snmp Options : http://docs.mongodb.org/manual/reference/configuration-options/#snmp-options 206 | default['mongodb3']['config']['mongod']['snmp']['subagent'] = nil 207 | default['mongodb3']['config']['mongod']['snmp']['master'] = nil 208 | 209 | # Mongos config 210 | default['mongodb3']['config']['mongos']['net']['port'] = 27018 # default : 27017 211 | default['mongodb3']['config']['mongos']['net']['bindIp'] = '127.0.0.1' # default : '0.0.0.0' 212 | default['mongodb3']['config']['mongos']['systemLog']['path'] = '/var/log/mongodb/mongos.log' 213 | default['mongodb3']['config']['mongos']['systemLog']['logAppend'] = true # default : false 214 | default['mongodb3']['config']['mongos']['systemLog']['destination'] = 'file' # default : 'file' 215 | 216 | # mongos-only Options : http://docs.mongodb.org/manual/reference/configuration-options/#mongos-only-options 217 | default['mongodb3']['config']['mongos']['replication']['localPingThresholdMs'] = nil # default : 15 218 | default['mongodb3']['config']['mongos']['sharding']['autoSplit'] = true # default : true 219 | default['mongodb3']['config']['mongos']['sharding']['configDB'] = nil 220 | default['mongodb3']['config']['mongos']['sharding']['chunkSize'] = 64 # default : 64 221 | 222 | # MMS automation and monitoring agent config attributes 223 | ## common attributes for both automation and monitoring agent 224 | default['mongodb3']['config']['mms']['mmsApiKey'] = nil 225 | default['mongodb3']['config']['mms']['mmsBaseUrl'] = 'https://api-agents.mongodb.com' 226 | default['mongodb3']['config']['mms']['httpProxy'] = nil 227 | default['mongodb3']['config']['mms']['krb5ConfigLocation'] = nil 228 | default['mongodb3']['config']['mms']['sslTrustedMMSServerCertificate'] = nil 229 | default['mongodb3']['config']['mms']['sslRequireValidMMSServerCertificates'] = nil 230 | 231 | ## Attributes for automation agent 232 | default['mongodb3']['config']['mms']['mmsGroupId'] = nil 233 | default['mongodb3']['config']['mms']['logFile'] = '/var/log/mongodb-mms-automation/automation-agent.log' 234 | default['mongodb3']['config']['mms']['mmsConfigBackup'] = '/var/lib/mongodb-mms-automation/mms-cluster-config-backup.json' 235 | default['mongodb3']['config']['mms']['logLevel'] = 'INFO' 236 | default['mongodb3']['config']['mms']['maxLogFiles'] = 10 237 | default['mongodb3']['config']['mms']['maxLogFileSize'] = 268435456 238 | 239 | ## Attributes for monitoring agent 240 | default['mongodb3']['config']['mms']['useSslForAllConnections'] = nil 241 | default['mongodb3']['config']['mms']['sslClientCertificate'] = nil 242 | default['mongodb3']['config']['mms']['sslClientCertificatePassword'] = nil 243 | default['mongodb3']['config']['mms']['sslTrustedServerCertificates'] = nil 244 | default['mongodb3']['config']['mms']['sslRequireValidServerCertificates'] = nil 245 | default['mongodb3']['config']['mms']['krb5Principal'] = nil 246 | default['mongodb3']['config']['mms']['krb5Keytab'] = nil 247 | default['mongodb3']['config']['mms']['gsappiServiceName'] = nil 248 | default['mongodb3']['config']['mms']['enableMunin'] = nil 249 | -------------------------------------------------------------------------------- /chefignore: -------------------------------------------------------------------------------- 1 | # Put files/directories that should be ignored in this file when uploading 2 | # or sharing to the community site. 3 | # Lines that start with '# ' are comments. 4 | 5 | # OS generated files # 6 | ###################### 7 | .DS_Store 8 | Icon? 9 | nohup.out 10 | ehthumbs.db 11 | Thumbs.db 12 | 13 | # SASS # 14 | ######## 15 | .sass-cache 16 | 17 | # EDITORS # 18 | ########### 19 | \#* 20 | .#* 21 | *~ 22 | *.sw[a-z] 23 | *.bak 24 | REVISION 25 | TAGS* 26 | tmtags 27 | *_flymake.* 28 | *_flymake 29 | *.tmproj 30 | .project 31 | .settings 32 | mkmf.log 33 | 34 | ## COMPILED ## 35 | ############## 36 | a.out 37 | *.o 38 | *.pyc 39 | *.so 40 | *.com 41 | *.class 42 | *.dll 43 | *.exe 44 | */rdoc/ 45 | 46 | # Testing # 47 | ########### 48 | .watchr 49 | .rspec 50 | spec/* 51 | spec/fixtures/* 52 | test/* 53 | features/* 54 | Guardfile 55 | Procfile 56 | 57 | # SCM # 58 | ####### 59 | .git 60 | */.git 61 | .gitignore 62 | .gitmodules 63 | .gitconfig 64 | .gitattributes 65 | .svn 66 | */.bzr/* 67 | */.hg/* 68 | */.svn/* 69 | 70 | # Berkshelf # 71 | ############# 72 | cookbooks/* 73 | tmp 74 | 75 | # Cookbooks # 76 | ############# 77 | CONTRIBUTING 78 | CHANGELOG* 79 | 80 | # Strainer # 81 | ############ 82 | Colanderfile 83 | Strainerfile 84 | .colander 85 | .strainer 86 | 87 | # Vagrant # 88 | ########### 89 | .vagrant 90 | Vagrantfile 91 | 92 | # Travis # 93 | ########## 94 | .travis.yml 95 | -------------------------------------------------------------------------------- /files/default/disable-transparent-hugepages: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # THIS FILE IS MAINTAINED BY CHEF. DO NOT MODIFY AS IT WILL BE OVERWRITTEN. 4 | 5 | ### BEGIN INIT INFO 6 | # Provides: disable-transparent-hugepages 7 | # Required-Start: $local_fs 8 | # Required-Stop: 9 | # X-Start-Before: mongod mongodb-mms-automation-agent 10 | # Default-Start: 2 3 4 5 11 | # Default-Stop: 0 1 6 12 | # Short-Description: Disable Linux transparent huge pages 13 | # Description: Disable Linux transparent huge pages, to improve 14 | # database performance. 15 | ### END INIT INFO 16 | 17 | case $1 in 18 | start) 19 | if [ -d /sys/kernel/mm/transparent_hugepage ]; then 20 | thp_path=/sys/kernel/mm/transparent_hugepage 21 | elif [ -d /sys/kernel/mm/redhat_transparent_hugepage ]; then 22 | thp_path=/sys/kernel/mm/redhat_transparent_hugepage 23 | else 24 | return 0 25 | fi 26 | 27 | echo 'never' > ${thp_path}/enabled 28 | echo 'never' > ${thp_path}/defrag 29 | 30 | unset thp_path 31 | ;; 32 | esac 33 | -------------------------------------------------------------------------------- /files/default/disable-transparent-hugepages.service: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # THIS FILE IS MAINTAINED BY CHEF. DO NOT MODIFY AS IT WILL BE OVERWRITTEN. 4 | 5 | ### BEGIN INIT INFO 6 | # Provides: disable-transparent-hugepages 7 | # Required-Start: $local_fs 8 | # Required-Stop: 9 | # X-Start-Before: mongod mongodb-mms-automation-agent 10 | # Default-Start: 2 3 4 5 11 | # Default-Stop: 0 1 6 12 | # Short-Description: Disable Linux transparent huge pages 13 | # Description: Disable Linux transparent huge pages, to improve 14 | # database performance. 15 | ### END INIT INFO 16 | 17 | [Unit] 18 | Description= disable-transparent-hugepages 19 | SourcePath=/etc/init.d/disable-transparent-hugepages 20 | 21 | [Service] 22 | ExecStart=/etc/init.d/disable-transparent-hugepages start 23 | -------------------------------------------------------------------------------- /libraries/mongodb3_helper.rb: -------------------------------------------------------------------------------- 1 | module Mongodb3Helper 2 | def mongodb_config(config) 3 | config.to_hash.compact.to_yaml 4 | end 5 | end 6 | 7 | class Hash 8 | def compact 9 | inject({}) do |new_hash, (k, v)| 10 | if v.is_a?(Hash) 11 | v = v.compact 12 | new_hash[k] = v unless v.empty? 13 | else 14 | new_hash[k] = v unless v.nil? 15 | end 16 | new_hash 17 | end 18 | end 19 | end 20 | -------------------------------------------------------------------------------- /metadata.rb: -------------------------------------------------------------------------------- 1 | name 'mongodb3' 2 | maintainer 'Sunggun Yu' 3 | maintainer_email 'sunggun.dev@gmail.com' 4 | license 'Apache 2.0' 5 | description 'Installs/Configures mongodb3' 6 | long_description 'Installs/Configures mongodb3' 7 | version '5.3.0' 8 | 9 | supports 'ubuntu', '>= 12.04' 10 | supports 'debian', '= 7.8' 11 | supports 'redhat', '= 6.6' 12 | supports 'centos', '= 6.8' 13 | supports 'centos', '= 7.2' 14 | supports 'oracle', '= 6.6' 15 | supports 'amazon' 16 | 17 | depends 'apt' 18 | depends 'yum' 19 | depends 'user' 20 | depends 'runit', '~> 1.7.0' 21 | -------------------------------------------------------------------------------- /recipes/default.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: mongodb3 3 | # Recipe:: default 4 | # 5 | # Copyright 2015, Sunggun Yu 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the 'License'); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an 'AS IS' BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | 20 | include_recipe 'mongodb3::package_repo' 21 | 22 | # Install MongoDB package 23 | install_package = %w(mongodb-org-server mongodb-org-shell mongodb-org-tools) 24 | 25 | install_package.each do |pkg| 26 | package pkg do 27 | version node['mongodb3']['package']['version'] 28 | case node['platform_family'] 29 | when 'debian' 30 | # bypass dpkg errors about pre-existing init or conf file 31 | options '-o Dpkg::Options::="--force-confold" --force-yes' 32 | end 33 | action :install 34 | end 35 | end 36 | 37 | # Create the db path if not exist. 38 | directory node['mongodb3']['config']['mongod']['storage']['dbPath'] do 39 | owner node['mongodb3']['user'] 40 | group node['mongodb3']['group'] 41 | mode '0755' 42 | action :create 43 | recursive true 44 | end 45 | 46 | # Create the systemLog directory. 47 | directory File.dirname(node['mongodb3']['config']['mongod']['systemLog']['path']).to_s do 48 | owner node['mongodb3']['user'] 49 | group node['mongodb3']['group'] 50 | mode '0755' 51 | action :create 52 | recursive true 53 | end 54 | 55 | unless node['mongodb3']['config']['key_file_content'].to_s.empty? 56 | # Create the key file if it is not exist 57 | key_file = node['mongodb3']['config']['mongod']['security']['keyFile'] 58 | 59 | # Create the directory for key file 60 | directory File.dirname(key_file).to_s do 61 | action :create 62 | owner node['mongodb3']['user'] 63 | group node['mongodb3']['group'] 64 | recursive true 65 | end 66 | 67 | file key_file do 68 | content node['mongodb3']['config']['key_file_content'] 69 | mode '0600' 70 | owner node['mongodb3']['user'] 71 | group node['mongodb3']['group'] 72 | end 73 | end 74 | 75 | # Update the mongodb config file 76 | template node['mongodb3']['mongod']['config_file'] do 77 | source 'mongodb.conf.erb' 78 | mode 0644 79 | variables( 80 | :config => node['mongodb3']['config']['mongod'] 81 | ) 82 | helpers Mongodb3Helper 83 | end 84 | 85 | # Disable Transparent Huge Pages (THP) 86 | # https://docs.mongodb.com/manual/tutorial/transparent-huge-pages/ 87 | cookbook_file '/etc/init.d/disable-transparent-hugepages' do 88 | source 'disable-transparent-hugepages' 89 | owner 'root' 90 | group 'root' 91 | mode '0755' 92 | action :create 93 | only_if { 94 | node['mongodb3']['mongod']['disable-transparent-hugepages'] 95 | } 96 | end 97 | 98 | case node['platform'] 99 | when 'ubuntu' 100 | if node['platform_version'].to_f >= 15.04 101 | cookbook_file '/lib/systemd/system/disable-transparent-hugepages.service' do 102 | source 'disable-transparent-hugepages.service' 103 | owner 'root' 104 | group 'root' 105 | mode '0655' 106 | action :create 107 | only_if { 108 | node['mongodb3']['mongod']['disable-transparent-hugepages'] 109 | } 110 | end 111 | end 112 | end 113 | 114 | service 'disable-transparent-hugepages' do 115 | case node['platform'] 116 | when 'ubuntu' 117 | if node['platform_version'].to_f >= 15.04 118 | provider Chef::Provider::Service::Systemd 119 | end 120 | end 121 | action [ :enable, :start ] 122 | only_if { 123 | node['mongodb3']['mongod']['disable-transparent-hugepages'] 124 | } 125 | end 126 | 127 | # Create the mongod.service file 128 | case node['platform'] 129 | when 'ubuntu' 130 | template '/lib/systemd/system/mongod.service' do 131 | source 'mongod.service.erb' 132 | mode 0644 133 | only_if { node['platform_version'].to_f >= 15.04 } 134 | end 135 | end 136 | 137 | # Start the mongod service 138 | service 'mongod' do 139 | case node['platform'] 140 | when 'ubuntu' 141 | if node['platform_version'].to_f >= 15.04 142 | provider Chef::Provider::Service::Systemd 143 | elsif node['platform_version'].to_f >= 14.04 144 | provider Chef::Provider::Service::Upstart 145 | end 146 | end 147 | supports :start => true, :stop => true, :restart => true, :status => true 148 | action :enable 149 | subscribes :restart, "template[#{node['mongodb3']['mongod']['config_file']}]", :delayed 150 | subscribes :restart, "template[#{node['mongodb3']['config']['mongod']['security']['keyFile']}", :delayed 151 | end 152 | -------------------------------------------------------------------------------- /recipes/mms_automation_agent.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: mongodb3 3 | # Recipe:: mms_automation_agent 4 | # 5 | # Copyright 2015, Sunggun Yu 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the 'License'); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an 'AS IS' BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | 20 | # Install curl 21 | package 'curl' do 22 | action :install 23 | end 24 | 25 | # Set variables by platform 26 | case node['platform_family'] 27 | when 'rhel', 'fedora' 28 | mms_agent_source = 'https://cloud.mongodb.com/download/agent/automation/mongodb-mms-automation-agent-manager-latest.x86_64.rpm' 29 | mms_agent_file = '/root/mongodb-mms-automation-agent-manager-latest.x86_64.rpm' 30 | when 'debian' 31 | if node['platform'] == 'ubuntu' && node['platform_version'].to_f >= 15.04 32 | mms_agent_source = 'https://cloud.mongodb.com/download/agent/automation/mongodb-mms-automation-agent-manager_latest_amd64.ubuntu1604.deb' 33 | mms_agent_file = '/root/mongodb-mms-automation-agent-manager_latest_amd64.ubuntu1604.deb' 34 | else 35 | mms_agent_source = 'https://cloud.mongodb.com/download/agent/automation/mongodb-mms-automation-agent-manager_latest_amd64.deb' 36 | mms_agent_file = '/root/mongodb-mms-automation-agent-manager_latest_amd64.deb' 37 | end 38 | end 39 | 40 | # Download the mms automation agent manager latest 41 | remote_file mms_agent_file do 42 | source mms_agent_source 43 | owner 'root' 44 | group 'root' 45 | mode '0644' 46 | action :create 47 | end 48 | 49 | # Install package 50 | case node['platform_family'] 51 | when 'rhel', 'fedora' 52 | rpm_package 'mongodb-mms-automation-agent-manager' do 53 | source mms_agent_file 54 | action :install 55 | end 56 | when 'debian' 57 | dpkg_package 'mongodb-mms-automation-agent-manager' do 58 | source mms_agent_file 59 | action :install 60 | end 61 | end 62 | 63 | # Create or modify the mms agent config file 64 | template '/etc/mongodb-mms/automation-agent.config' do 65 | source 'automation-agent.config.erb' 66 | mode 0600 67 | owner node['mongodb3']['user'] 68 | group node['mongodb3']['group'] 69 | variables( 70 | :config => node['mongodb3']['config']['mms'] 71 | ) 72 | end 73 | 74 | # Change ownership of data directory to mongo user 75 | directory node['mongodb3']['config']['mongod']['storage']['dbPath'] do 76 | owner node['mongodb3']['user'] 77 | group node['mongodb3']['group'] 78 | recursive true 79 | action :create 80 | end 81 | 82 | # Start the mms automation agent 83 | service 'mongodb-mms-automation-agent' do 84 | # The service provider of MMS Agent for Ubuntu is upstart 85 | provider Chef::Provider::Service::Upstart if node['platform_family'] == 'debian' 86 | provider Chef::Provider::Service::Systemd if node['platform'] == 'ubuntu' && node['platform_version'].to_f >= 15.04 87 | supports :status => true, :restart => true, :stop => true 88 | action [ :enable, :start ] 89 | end 90 | -------------------------------------------------------------------------------- /recipes/mms_monitoring_agent.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: mongodb3 3 | # Recipe:: mms_monitoring_agent 4 | # 5 | # Copyright 2015, Sunggun Yu 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the 'License'); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an 'AS IS' BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | 20 | # Install curl 21 | package 'curl' do 22 | action :install 23 | end 24 | 25 | # Set variables by platform 26 | case node['platform_family'] 27 | when 'rhel', 'fedora' 28 | mms_agent_source = 'https://cloud.mongodb.com/download/agent/monitoring/mongodb-mms-monitoring-agent-latest.x86_64.rpm' 29 | mms_agent_file = '/root/mongodb-mms-monitoring-agent-latest.x86_64.rpm' 30 | when 'debian' 31 | if node['platform'] == 'ubuntu' && node['platform_version'].to_f >= 15.04 32 | mms_agent_source = 'https://cloud.mongodb.com/download/agent/monitoring/mongodb-mms-monitoring-agent_latest_amd64.ubuntu1604.deb' 33 | mms_agent_file = '/root/mongodb-mms-monitoring-agent_latest_amd64.ubuntu1604.deb' 34 | else 35 | mms_agent_source = 'https://cloud.mongodb.com/download/agent/monitoring/mongodb-mms-monitoring-agent_latest_amd64.deb' 36 | mms_agent_file = '/root/mongodb-mms-monitoring-agent_latest_amd64.deb' 37 | end 38 | end 39 | 40 | # Download the mms automation agent manager latest 41 | remote_file mms_agent_file do 42 | source mms_agent_source 43 | action :create 44 | end 45 | 46 | # Install package 47 | case node['platform_family'] 48 | when 'rhel', 'fedora' 49 | rpm_package 'mongodb-mms-monitoring-agent' do 50 | source mms_agent_file 51 | action :install 52 | end 53 | when 'debian' 54 | dpkg_package 'mongodb-mms-monitoring-agent' do 55 | source mms_agent_file 56 | action :install 57 | end 58 | end 59 | 60 | # Create or modify the mms agent config file 61 | template '/etc/mongodb-mms/monitoring-agent.config' do 62 | source 'monitoring-agent.config.erb' 63 | mode 0600 64 | owner 'mongodb-mms-agent' 65 | group 'mongodb-mms-agent' 66 | variables( 67 | :config => node['mongodb3']['config']['mms'] 68 | ) 69 | end 70 | 71 | # Start the mms automation agent 72 | service 'mongodb-mms-monitoring-agent' do 73 | # The service provider of MMS Agent for Ubuntu is upstart 74 | provider Chef::Provider::Service::Upstart if node['platform_family'] == 'debian' 75 | provider Chef::Provider::Service::Systemd if node['platform'] == 'ubuntu' && node['platform_version'].to_f >= 15.04 76 | supports :status => true, :restart => true, :stop => true 77 | action [ :enable, :start ] 78 | end 79 | -------------------------------------------------------------------------------- /recipes/mongos.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: mongodb3 3 | # Recipe:: default 4 | # 5 | # Copyright 2015, Sunggun Yu 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the 'License'); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an 'AS IS' BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | 20 | include_recipe 'mongodb3::package_repo' 21 | 22 | # Install Mongos package 23 | install_package = %w(mongodb-org-shell mongodb-org-mongos mongodb-org-tools) 24 | 25 | install_package.each do |pkg| 26 | package pkg do 27 | version node['mongodb3']['package']['version'] 28 | action :install 29 | end 30 | end 31 | 32 | # Mongos configuration 33 | # Create the mongodb user if not exist 34 | user node['mongodb3']['user'] do 35 | action :create 36 | end 37 | 38 | # Create the Mongos config file 39 | template node['mongodb3']['mongos']['config_file'] do 40 | source 'mongodb.conf.erb' 41 | owner node['mongodb3']['user'] 42 | mode 0644 43 | variables( 44 | :config => node['mongodb3']['config']['mongos'] 45 | ) 46 | helpers Mongodb3Helper 47 | notifies :restart, 'runit_service[mongos]' 48 | end 49 | 50 | # Create the log directory 51 | directory File.dirname(node['mongodb3']['config']['mongos']['systemLog']['path']).to_s do 52 | owner node['mongodb3']['user'] 53 | action :create 54 | recursive true 55 | end 56 | 57 | # Install runit service package 58 | # packagecloud cookbook is not working for oracle linux. 59 | if node['platform'] == 'oracle' 60 | # Install pygpgme package for imeyer runit yum repository 61 | package 'pygpgme' do 62 | ignore_failure true 63 | end 64 | # Install imeyer runit packagecloud yum repository 65 | yum_repository 'imeyer_runit' do 66 | description 'imeyer_runit' 67 | baseurl 'https://packagecloud.io/imeyer/runit/el/6/$basearch' 68 | gpgkey 'https://packagecloud.io/gpg.key' 69 | sslcacert '/etc/pki/tls/certs/ca-bundle.crt' 70 | sslverify false 71 | gpgcheck false 72 | action :create 73 | end 74 | # Set `['runit']['prefer_local_yum'] = true` to avoid install yum repository through packagecloud cookbook 75 | node.set['runit']['prefer_local_yum'] = true 76 | end 77 | 78 | # Install runit service package through runit::default recipe 79 | include_recipe 'runit::default' 80 | 81 | # Adding `mongos` service with runit 82 | runit_service 'mongos' do 83 | retries 3 84 | restart_on_update true 85 | cookbook node['mongodb3']['mongos']['runit_template_cookbook'] 86 | options ({ 87 | :user => node['mongodb3']['user'], 88 | :config_file => node['mongodb3']['mongos']['config_file'] 89 | }) 90 | end 91 | -------------------------------------------------------------------------------- /recipes/package_repo.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: mongodb3 3 | # Recipe:: package_repo 4 | # 5 | # Copyright 2015, Sunggun Yu 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the 'License'); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an 'AS IS' BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | 20 | pkg_major_version = node['mongodb3']['version'].to_f # eg. 3.0, 3.2 21 | 22 | # Setup default package version attribute to install 23 | pkg_version = node['mongodb3']['version'] 24 | case node['platform_family'] 25 | when 'rhel', 'fedora' 26 | pkg_version = "#{node['mongodb3']['version']}-1.el#{node.platform_version.to_i}" # ~FC019 27 | if node['platform'] == 'amazon' 28 | pkg_version = "#{node['mongodb3']['version']}-1.amzn1" # ~FC019 29 | end 30 | end 31 | 32 | # Setup default package repo url attribute for each platform family or platform 33 | case node['platform'] 34 | when 'redhat', 'oracle','centos', 'fedora' # ~FC024 35 | pkg_repo = "https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/#{pkg_major_version}/#{node['kernel']['machine'] =~ /x86_64/ ? 'x86_64' : 'i686'}" 36 | when 'amazon' 37 | pkg_repo = "https://repo.mongodb.org/yum/amazon/2013.03/mongodb-org/#{pkg_major_version}/x86_64/" 38 | when 'ubuntu' 39 | pkg_repo = 'http://repo.mongodb.org/apt/ubuntu' 40 | when 'debian' 41 | pkg_repo = 'http://repo.mongodb.org/apt/debian' 42 | end 43 | 44 | # Setup apt variables 45 | case node['platform'] 46 | when 'ubuntu' 47 | apt_repo_keyserver = 'hkp://keyserver.ubuntu.com:80' 48 | apt_repo_component = ['multiverse'] 49 | when 'debian' 50 | apt_repo_keyserver = 'keyserver.ubuntu.com' 51 | apt_repo_component = ['main'] 52 | end 53 | 54 | # MongoDB package version to install 55 | if node['mongodb3']['package']['version'].nil? 56 | node.set['mongodb3']['package']['version'] = pkg_version 57 | end 58 | 59 | # MongoDB package repo url 60 | if node['mongodb3']['package']['repo']['url'].nil? 61 | node.set['mongodb3']['package']['repo']['url'] = pkg_repo 62 | end 63 | 64 | # MongoDB repository name 65 | if node['mongodb3']['package']['repo']['apt']['name'].nil? 66 | node.set['mongodb3']['package']['repo']['apt']['name'] = pkg_major_version.to_s 67 | end 68 | 69 | # MongoDB apt keyserver and key 70 | if node['mongodb3']['package']['repo']['apt']['keyserver'].nil? 71 | node.set['mongodb3']['package']['repo']['apt']['keyserver'] = apt_repo_keyserver 72 | end 73 | 74 | if node['mongodb3']['package']['repo']['apt']['key'].nil? 75 | if pkg_major_version >= 3.2 76 | node.set['mongodb3']['package']['repo']['apt']['key'] = 'EA312927' 77 | else 78 | node.set['mongodb3']['package']['repo']['apt']['key'] = '7F0CEB10' 79 | end 80 | end 81 | 82 | if node['mongodb3']['package']['repo']['apt']['components'].nil? 83 | node.set['mongodb3']['package']['repo']['apt']['components'] = apt_repo_component 84 | end 85 | 86 | # Add the MongoDB Package repository 87 | case node['platform_family'] 88 | when 'rhel', 'fedora' 89 | yum_repository "mongodb-org-#{pkg_major_version}" do 90 | description 'MongoDB Repository' 91 | baseurl node['mongodb3']['package']['repo']['url'] 92 | action :create 93 | gpgcheck false 94 | enabled true 95 | sslverify false 96 | end 97 | when 'debian' 98 | apt_repository "mongodb-org-#{pkg_major_version}" do 99 | uri node['mongodb3']['package']['repo']['url'] 100 | if node['platform'] == 'ubuntu' and node['platform_version'].to_f == 15.04 101 | # seems that mongodb supports only LTS versions of Ubuntu 102 | distribution "trusty/mongodb-org/#{node['mongodb3']['package']['repo']['apt']['name']}" 103 | else 104 | distribution "#{node['lsb']['codename']}/mongodb-org/#{node['mongodb3']['package']['repo']['apt']['name']}" 105 | end 106 | components node['mongodb3']['package']['repo']['apt']['components'] 107 | keyserver node['mongodb3']['package']['repo']['apt']['keyserver'] 108 | key node['mongodb3']['package']['repo']['apt']['key'] 109 | action :add 110 | end 111 | include_recipe 'apt' 112 | end 113 | -------------------------------------------------------------------------------- /templates/default/automation-agent.config.erb: -------------------------------------------------------------------------------- 1 | # /etc/mongodb-mms/automation-agent.config 2 | 3 | # 4 | # REQUIRED 5 | # Enter your Group ID - It can be found at https://cloud.mongodb.com/settings/group 6 | # 7 | mmsGroupId=<%= @config['mmsGroupId'] %> 8 | 9 | # 10 | # REQUIRED 11 | # Enter your API key - It can be found at https://cloud.mongodb.com/settings/group 12 | # 13 | mmsApiKey=<%= @config['mmsApiKey'] %> 14 | 15 | # 16 | # Base url of the MMS web server. 17 | # 18 | mmsBaseUrl=<%= @config['mmsBaseUrl'] %> 19 | 20 | # 21 | # Path to log file 22 | # 23 | logFile=<%= @config['logFile'] %> 24 | 25 | # 26 | # Path to backup cluster config to 27 | # 28 | mmsConfigBackup=<%= @config['mmsConfigBackup'] %> 29 | 30 | # 31 | # Lowest log level to log. Can be (in order): DEBUG, ROUTINE, INFO, WARN, ERROR, DOOM 32 | # 33 | logLevel=<%= @config['logLevel'] %> 34 | 35 | # 36 | # Maximum number of rotated log files 37 | # 38 | maxLogFiles=<%= @config['maxLogFiles'] %> 39 | 40 | # 41 | # Maximum size in bytes of a log file (before rotating) 42 | # 43 | maxLogFileSize=<%= @config['maxLogFileSize'] %> 44 | 45 | # 46 | # URL to proxy all HTTP requests through 47 | # 48 | <% if @config['httpProxy'].to_s.empty? %> 49 | #httpProxy= 50 | <% else %> 51 | httpProxy=<%= @config['httpProxy'] %> 52 | <% end %> 53 | 54 | # 55 | # The absolute path to an non-system-standard location for the Kerberos configuration file 56 | # 57 | <% if @config['krb5ConfigLocation'].to_s.empty? %> 58 | #krb5ConfigLocation= 59 | <% else %> 60 | krb5ConfigLocation=<%= @config['krb5ConfigLocation'] %> 61 | <% end %> 62 | 63 | # 64 | # The path on disk that contains the trusted certificate authority certificates in PEM format. 65 | # 66 | <% if @config['sslTrustedMMSServerCertificate'].to_s.empty? %> 67 | #sslTrustedMMSServerCertificate= 68 | <% else %> 69 | sslTrustedMMSServerCertificate=<%= @config['sslTrustedMMSServerCertificate'] %> 70 | <% end %> 71 | 72 | # 73 | # Use this option to disable certificate verification by setting this value to false. 74 | # 75 | <% if @config['sslTrustedMMSServerCertificate'].to_s.empty? %> 76 | #sslRequireValidMMSServerCertificates= 77 | <% else %> 78 | sslRequireValidMMSServerCertificates=<%= @config['sslRequireValidMMSServerCertificates'] %> 79 | <% end %> 80 | 81 | # For additional optional settings, please see 82 | # https://docs.cloud.mongodb.com/reference/automation-agent/ 83 | -------------------------------------------------------------------------------- /templates/default/mongod.service.erb: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=High-performance, schema-free document-oriented database 3 | Documentation=man:mongod(1) 4 | After=network.target 5 | 6 | [Service] 7 | Type=forking 8 | User=mongodb 9 | Group=mongodb 10 | RuntimeDirectory=mongod 11 | PIDFile=/var/run/mongod/mongod.pid 12 | ExecStart=/usr/bin/mongod -f /etc/mongod.conf --pidfilepath /var/run/mongod/mongod.pid --fork 13 | TimeoutStopSec=5 14 | KillMode=mixed 15 | 16 | [Install] 17 | WantedBy=multi-user.target -------------------------------------------------------------------------------- /templates/default/mongodb.conf.erb: -------------------------------------------------------------------------------- 1 | # THIS FILE IS MAINTAINED BY CHEF. DO NOT MODIFY AS IT WILL BE OVERWRITTEN. 2 | <%= mongodb_config @config%> -------------------------------------------------------------------------------- /templates/default/mongos.conf.erb: -------------------------------------------------------------------------------- 1 | # THIS FILE IS MAINTAINED BY CHEF. DO NOT MODIFY AS IT WILL BE OVERWRITTEN. 2 | <%= mongodb_config @config%> 3 | -------------------------------------------------------------------------------- /templates/default/monitoring-agent.config.erb: -------------------------------------------------------------------------------- 1 | # THIS FILE IS MAINTAINED BY CHEF. DO NOT MODIFY AS IT WILL BE OVERWRITTEN. 2 | 3 | # 4 | # Enter your API key - See: cloud.mongodb.com/settings/group 5 | # 6 | mmsApiKey=<%= @config['mmsApiKey'] %> 7 | 8 | # 9 | # Hostname of the MMS monitoring web server. 10 | # 11 | mmsBaseUrl=<%= @config['mmsBaseUrl'] %> 12 | 13 | # 14 | # URL to proxy all HTTP requests through 15 | # 16 | <% if @config['httpProxy'].to_s.empty? %> 17 | #httpProxy= 18 | <% else %> 19 | httpProxy=<%= @config['httpProxy'] %> 20 | <% end %> 21 | 22 | # 23 | # Set to true to enable SSL support globally and to use SSL for all MongoDB connections. 24 | # 25 | <% if @config['useSslForAllConnections'].to_s.empty? %> 26 | #useSslForAllConnections= 27 | <% else %> 28 | useSslForAllConnections=<%= @config['useSslForAllConnections'] %> 29 | <% end %> 30 | 31 | # 32 | # The path to the private key, client certificate, and optional intermediate certificates in PEM format 33 | # 34 | <% if @config['sslClientCertificate'].to_s.empty? %> 35 | #sslClientCertificate= 36 | <% else %> 37 | sslClientCertificate=<%= @config['sslClientCertificate'] %> 38 | <% end %> 39 | 40 | # 41 | # The password needed to decrypt the private key in the file specified in sslClientCertificate. 42 | # 43 | <% if @config['sslClientCertificatePassword'].to_s.empty? %> 44 | #sslClientCertificatePassword= 45 | <% else %> 46 | sslClientCertificatePassword=<%= @config['sslClientCertificatePassword'] %> 47 | <% end %> 48 | 49 | # 50 | # The path on disk that contains the trusted certificate authority certificates in PEM format. 51 | # 52 | <% if @config['sslTrustedServerCertificates'].to_s.empty? %> 53 | #sslTrustedServerCertificates= 54 | <% else %> 55 | sslTrustedServerCertificates=<%= @config['sslTrustedServerCertificates'] %> 56 | <% end %> 57 | 58 | # 59 | # Use this option to disable certificate verification by setting this value to false. 60 | # 61 | <% if @config['sslRequireValidServerCertificates'].to_s.empty? %> 62 | #sslRequireValidServerCertificates= 63 | <% else %> 64 | sslRequireValidServerCertificates=<%= @config['sslRequireValidServerCertificates'] %> 65 | <% end %> 66 | 67 | # 68 | # The Kerberos principal used by the agent. 69 | # 70 | <% if @config['krb5Principal'].to_s.empty? %> 71 | #krb5Principal= 72 | <% else %> 73 | krb5Principal=<%= @config['krb5Principal'] %> 74 | <% end %> 75 | 76 | # 77 | # The absolute path to Kerberos principal’s keytab file. 78 | # 79 | <% if @config['krb5Keytab'].to_s.empty? %> 80 | #krb5Keytab= 81 | <% else %> 82 | krb5Keytab=<%= @config['krb5Keytab'] %> 83 | <% end %> 84 | 85 | # 86 | # The absolute path to an non-system-standard location for the Kerberos configuration file. 87 | # 88 | <% if @config['krb5ConfigLocation'].to_s.empty? %> 89 | #krb5ConfigLocation= 90 | <% else %> 91 | krb5ConfigLocation=<%= @config['krb5ConfigLocation'] %> 92 | <% end %> 93 | 94 | # 95 | # The default service name used by MongoDB is mongodb can specify a custom service name with the gssapiServiceName option. 96 | # 97 | <% if @config['gsappiServiceName'].to_s.empty? %> 98 | #gsappiServiceName= 99 | <% else %> 100 | gsappiServiceName=<%= @config['gsappiServiceName'] %> 101 | <% end %> 102 | 103 | # 104 | # By default the Monitoring Agent will use the trusted root CAs installed on the system. If the agent cannot find the trusted root CAs, configure these settings manually. 105 | # 106 | <% if @config['sslTrustedMMSServerCertificate'].to_s.empty? %> 107 | #sslTrustedMMSServerCertificate= 108 | <% else %> 109 | sslTrustedMMSServerCertificate=<%= @config['sslTrustedMMSServerCertificate'] %> 110 | <% end %> 111 | 112 | # 113 | # You can disable certificate verification by setting this value to false. 114 | # 115 | <% if @config['sslRequireValidMMSServerCertificates'].to_s.empty? %> 116 | #sslRequireValidMMSServerCertificates= 117 | <% else %> 118 | sslRequireValidMMSServerCertificates=<%= @config['sslRequireValidMMSServerCertificates'] %> 119 | <% end %> 120 | 121 | # 122 | # Set to false if you do not with the Monitoring Agent to collect hardware statistics via Munin-node. 123 | # 124 | <% if @config['enableMunin'].to_s.empty? %> 125 | #enableMunin= 126 | <% else %> 127 | enableMunin=<%= @config['enableMunin'] %> 128 | <% end %> 129 | 130 | 131 | # For additional optional settings, please see 132 | # https://docs.cloud.mongodb.com/reference/monitoring-agent/ 133 | -------------------------------------------------------------------------------- /templates/default/sv-mongos-log-run.erb: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | exec 2>&1 4 | exec svlogd -tt ./main 5 | -------------------------------------------------------------------------------- /templates/default/sv-mongos-run.erb: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | exec 2>&1 3 | exec chpst -u <%= @options[:user] %> mongos -f <%= @options[:config_file] %> 4 | -------------------------------------------------------------------------------- /test/.foodcritic: -------------------------------------------------------------------------------- 1 | ~FC011 2 | ~FC031 3 | ~FC045 -------------------------------------------------------------------------------- /test/cookbooks/mongodb3-test/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | mongodb3-test CHANGELOG 2 | ======================= 3 | 4 | This file is used to list changes made in each version of the mongodb3-test cookbook. 5 | 6 | 0.1.0 7 | ----- 8 | - [your_name] - Initial release of mongodb3-test 9 | 10 | - - - 11 | Check the [Markdown Syntax Guide](http://daringfireball.net/projects/markdown/syntax) for help with Markdown. 12 | 13 | The [Github Flavored Markdown page](http://github.github.com/github-flavored-markdown/) describes the differences between markdown on github and standard markdown. 14 | -------------------------------------------------------------------------------- /test/cookbooks/mongodb3-test/README.md: -------------------------------------------------------------------------------- 1 | mongodb3-test Cookbook 2 | ====================== 3 | TODO: Enter the cookbook description here. 4 | 5 | e.g. 6 | This cookbook makes your favorite breakfast sandwich. 7 | 8 | Requirements 9 | ------------ 10 | TODO: List your cookbook requirements. Be sure to include any requirements this cookbook has on platforms, libraries, other cookbooks, packages, operating systems, etc. 11 | 12 | e.g. 13 | #### packages 14 | - `toaster` - mongodb3-test needs toaster to brown your bagel. 15 | 16 | Attributes 17 | ---------- 18 | TODO: List your cookbook attributes here. 19 | 20 | e.g. 21 | #### mongodb3-test::default 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 |
KeyTypeDescriptionDefault
['mongodb3-test']['bacon']Booleanwhether to include bacontrue
36 | 37 | Usage 38 | ----- 39 | #### mongodb3-test::default 40 | TODO: Write usage instructions for each cookbook. 41 | 42 | e.g. 43 | Just include `mongodb3-test` in your node's `run_list`: 44 | 45 | ```json 46 | { 47 | "name":"my_node", 48 | "run_list": [ 49 | "recipe[mongodb3-test]" 50 | ] 51 | } 52 | ``` 53 | 54 | Contributing 55 | ------------ 56 | TODO: (optional) If this is a public cookbook, detail the process for contributing. If this is a private cookbook, remove this section. 57 | 58 | e.g. 59 | 1. Fork the repository on Github 60 | 2. Create a named feature branch (like `add_component_x`) 61 | 3. Write your change 62 | 4. Write tests for your change (if applicable) 63 | 5. Run the tests, ensuring they all pass 64 | 6. Submit a Pull Request using Github 65 | 66 | License and Authors 67 | ------------------- 68 | Authors: TODO: List authors 69 | -------------------------------------------------------------------------------- /test/cookbooks/mongodb3-test/attributes/default.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: mongodb3-test 3 | # Attribute:: default 4 | # 5 | # Copyright 2016, Sunggun Yu 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the 'License'); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an 'AS IS' BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | -------------------------------------------------------------------------------- /test/cookbooks/mongodb3-test/metadata.rb: -------------------------------------------------------------------------------- 1 | name 'mongodb3-test' 2 | maintainer 'Sunggun Yu' 3 | maintainer_email 'sunggun.dev@gmail.com' 4 | license 'Apache 2.0' 5 | description 'Installs/Configures mongodb3-test' 6 | long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) 7 | version '0.1.0' 8 | 9 | depends 'mongodb3' 10 | -------------------------------------------------------------------------------- /test/cookbooks/mongodb3-test/recipes/amazon.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: mongodb3-test 3 | # Recipe:: amazon 4 | # 5 | # Copyright 2016, Sunggun Yu 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the 'License'); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an 'AS IS' BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | 20 | file '/etc/redhat-release' do 21 | content 'Amazon Linux AMI' 22 | end 23 | -------------------------------------------------------------------------------- /test/cookbooks/mongodb3-test/recipes/custom.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: mongodb3-test 3 | # Recipe:: custom 4 | # 5 | # Copyright 2016, Sunggun Yu 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the 'License'); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an 'AS IS' BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | 20 | node.set['mongodb3']['config']['mongod']['storage']['dbPath'] = '/var/lib/mongodb/custom' 21 | node.set['mongodb3']['config']['mongod']['systemLog']['path'] = '/var/log/mongodb/custom/mongod.log' 22 | 23 | include_recipe 'mongodb3::default' 24 | -------------------------------------------------------------------------------- /test/cookbooks/mongodb3-test/recipes/default-30x.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: mongodb3-test 3 | # Recipe:: default-30x 4 | # 5 | # Copyright 2016, Sunggun Yu 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the 'License'); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an 'AS IS' BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | 20 | node.set['mongodb3']['version'] = '3.0.11' 21 | 22 | # For package upgrade testing : executing converge twice with different version 23 | # node.set['mongodb3']['version'] = '3.2.4' 24 | # node.set['mongodb3']['package']['version'] = '3.2.4' 25 | # node.set['mongodb3']['package']['repo']['apt']['name'] = '3.2' 26 | 27 | include_recipe 'mongodb3::default' 28 | -------------------------------------------------------------------------------- /test/cookbooks/mongodb3-test/recipes/default.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: mongodb3-test 3 | # Recipe:: default 4 | # 5 | # Copyright 2016, Sunggun Yu 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the 'License'); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an 'AS IS' BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | 20 | include_recipe 'mongodb3::default' 21 | -------------------------------------------------------------------------------- /test/cookbooks/mongodb3-test/recipes/mms_automation_agent_with_data_bag.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: mongodb3-test 3 | # Recipe:: mms_automation_agent_with_data_bag 4 | # 5 | # Copyright 2016, Sunggun Yu 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the 'License'); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an 'AS IS' BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | 20 | # 21 | # The data bag content that is encrypted 22 | # 23 | # { 24 | # "id" : "mms-agent", 25 | # "environments": { 26 | # "dev": { 27 | # "mms_group_id" : "mms_group_id_from_data_bag", 28 | # "mms_api_key" : "mms_api_key_from_data_bag" 29 | # } 30 | # } 31 | # } 32 | 33 | # mms agent data bag 34 | mms_data_bag_item = Chef::EncryptedDataBagItem.load('mongodb', 'mms-agent') 35 | mms_data_bag = mms_data_bag_item['environments'][node.chef_environment] 36 | 37 | node.set['mongodb3']['config']['mms']['mmsGroupId'] = mms_data_bag['mms_group_id'] 38 | node.set['mongodb3']['config']['mms']['mmsApiKey'] = mms_data_bag['mms_api_key'] 39 | 40 | include_recipe 'mongodb3::mms_automation_agent' 41 | -------------------------------------------------------------------------------- /test/data_bags/encrypted_data_bag_secret: -------------------------------------------------------------------------------- 1 | YC1xx2lq0MsaDW1lFihswcOP6XUzgMmSaWzI8ptspcnB6dCFBq1dFlGzpfsXXeys 2 | X+fpkzLTo2aHMWDZiyzRuDl4ix1OO10TJRxNkLVvGiN4yHw+wk3+WOTcjm1qp0Vy 3 | zsbN5BkjYPlzz9SfYyXZP2jTeo5aE/+oBiGDjzB8kiQ/7wJUt8aJdpW+ez6mwE+s 4 | qLe8WvF73s0InPnxDIwcPfa2j8BCBY7fXgHsPf4xSMYG3DRG4dMNB2875NXVNLrW 5 | d67eoNQedlQFsZlgeUDDVBCvsEWAhJImDvlzlGBLAn9UYKWwAnHFlFaEJ6zeN724 6 | RvQ5g1SatnJijF8mNztdE8Mz5zhFpYI107D10wLBnHn7bISY+nHZHBvhjtPfmvSv 7 | fOi/XICH8gu28Rp2etsOa9virojvGx81aWNOAPBLDuqQgLqCs8P3HEIhnD1iaU4X 8 | 9yQlDGb79viGCWKQMMaJNa3pgLH4dzEqgsb9ySPM4jnItE3X2X5KPqr8X9NKiYHX 9 | yCksc4ZE6IbtJ8f0uC/qUbC1YleGdiC/drWAlURqZXOutBFrNv3ysOmx8q08EPJV 10 | l4JJnwh6bsESfIiZu0fymKN6PgO85hSTRli0/nRjcUj07e27SF59/eRIIiD5VAQo 11 | MQw1wJGpV36XvmT/u69eUz/ZraNTACJ19pyhWNtBJ+w= 12 | -------------------------------------------------------------------------------- /test/data_bags/mongodb/mms-agent.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "mms-agent", 3 | "environments": { 4 | "encrypted_data": "B2rMHbbtkhNcl+BgF+nA/9ZGhgfa1O+J27NjvD6bDuz46Y9nSjiABK6K/CDq\n3FWignVJfJ9GegwrWyscX2Uk2publKopj8ZTKTew6+RTvy6rTXB9FA5+zy+L\nERRe2K8C2MFlBvZG5FT1kn6T6rTi80Z5mywlscz4w5QnCQAWwvs=\n", 5 | "iv": "9HwyIJXUCFqBBS1yiLPN5A==\n", 6 | "version": 1, 7 | "cipher": "aes-256-cbc" 8 | } 9 | } -------------------------------------------------------------------------------- /test/environments/dev.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "dev", 3 | "description": "Kitchen DEV env", 4 | "cookbook_versions": { 5 | }, 6 | "json_class": "Chef::Environment", 7 | "chef_type": "environment", 8 | "default_attributes": { 9 | }, 10 | "override_attributes": { 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /test/integration/configsvr/serverspec/default_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | # RHEL and Debian family has different value for some of mongodb settings. 4 | if os[:family] == 'redhat' 5 | mongo_user = 'mongod' 6 | mongo_data_dir = '/var/lib/mongo' 7 | elsif ['debian', 'ubuntu'] 8 | mongo_user = 'mongodb' 9 | mongo_data_dir = '/var/lib/mongodb' 10 | end 11 | 12 | # Test `mongodb-org-server` package is installed. 13 | describe package('mongodb-org-server') do 14 | it { should be_installed } 15 | end 16 | 17 | # Test `mongod` service is running. 18 | describe service('mongod') do 19 | it { should be_enabled } 20 | it { should be_running } 21 | end 22 | 23 | # Test mongodb port `27019` is listening. 24 | describe port(27019) do 25 | it { should be_listening } 26 | end 27 | 28 | # Test mongod process starts with expected mongodb config file 29 | describe command('ps -ef | grep mongod') do 30 | its(:stdout) { should contain('/etc/mongod.conf') } 31 | end 32 | 33 | # Test mongodb config file is created with right permission. 34 | describe file('/etc/mongod.conf') do 35 | it { should be_file } 36 | it { should be_owned_by 'root' } 37 | it { should be_grouped_into 'root' } 38 | end 39 | 40 | # Test mongodb data directory is created with right permission. 41 | describe file(mongo_data_dir) do 42 | it { should be_directory } 43 | it { should be_mode 755 } 44 | it { should be_owned_by mongo_user } 45 | it { should be_grouped_into mongo_user } 46 | end 47 | 48 | # Test mongodb log file is created with right permission. 49 | describe file('/var/log/mongodb/mongod.log') do 50 | it { should be_file } 51 | it { should be_owned_by mongo_user } 52 | end 53 | 54 | # Test mongodb config file contains expected replica set name 55 | describe file('/etc/mongod.conf') do 56 | it { should_not contain 'replSetName' } 57 | end 58 | -------------------------------------------------------------------------------- /test/integration/custom/serverspec/default_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | # RHEL and Debian family has different value for some of mongodb settings. 4 | if os[:family] == 'redhat' 5 | mongo_user = 'mongod' 6 | elsif ['debian', 'ubuntu'] 7 | mongo_user = 'mongodb' 8 | end 9 | 10 | mongo_data_dir = '/var/lib/mongodb/custom' 11 | mongo_syslog_path = '/var/log/mongodb/custom/mongod.log' 12 | 13 | # Test `mongodb-org-server` package is installed. 14 | describe package('mongodb-org-server') do 15 | it { should be_installed } 16 | end 17 | 18 | # Test `mongod` service is running. 19 | describe service('mongod') do 20 | it { should be_enabled } 21 | it { should be_running } 22 | end 23 | 24 | # Test mongodb port `27017` is listening. 25 | describe port(27017) do 26 | it { should be_listening } 27 | end 28 | 29 | # Test mongod process starts with expected mongodb config file 30 | describe command('ps -ef | grep mongod') do 31 | its(:stdout) { should contain('/etc/mongod.conf') } 32 | end 33 | 34 | # Test mongodb config file is created with right permission. 35 | describe file('/etc/mongod.conf') do 36 | it { should be_file } 37 | it { should be_owned_by 'root' } 38 | it { should be_grouped_into 'root' } 39 | end 40 | 41 | # Test mongodb data directory is created with right permission. 42 | describe file(mongo_data_dir) do 43 | it { should be_directory } 44 | it { should be_mode 755 } 45 | it { should be_owned_by mongo_user } 46 | it { should be_grouped_into mongo_user } 47 | end 48 | 49 | # Test mongodb log file is created with right permission. 50 | describe file(mongo_syslog_path) do 51 | it { should be_file } 52 | it { should be_owned_by mongo_user } 53 | end 54 | 55 | # Test mongod process starts with expected mongodb config file 56 | describe command('export LC_ALL="en_US.UTF-8"; mongo --eval "db.version()"') do 57 | its(:stdout) { should contain('3.2.8') } 58 | end 59 | -------------------------------------------------------------------------------- /test/integration/default-30x/serverspec/default_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | # RHEL and Debian family has different value for some of mongodb settings. 4 | if os[:family] == 'redhat' 5 | mongo_user = 'mongod' 6 | mongo_data_dir = '/var/lib/mongo' 7 | elsif ['debian', 'ubuntu'] 8 | mongo_user = 'mongodb' 9 | mongo_data_dir = '/var/lib/mongodb' 10 | end 11 | 12 | # Test `mongodb-org-server` package is installed. 13 | describe package('mongodb-org-server') do 14 | it { should be_installed } 15 | end 16 | 17 | # Test `mongod` service is running. 18 | describe service('mongod') do 19 | it { should be_enabled } 20 | it { should be_running } 21 | end 22 | 23 | # Test mongodb port `27017` is listening. 24 | describe port(27017) do 25 | it { should be_listening } 26 | end 27 | 28 | # Test mongod process starts with expected mongodb config file 29 | describe command('ps -ef | grep mongod') do 30 | its(:stdout) { should contain('/etc/mongod.conf') } 31 | end 32 | 33 | # Test mongodb config file is created with right permission. 34 | describe file('/etc/mongod.conf') do 35 | it { should be_file } 36 | it { should be_owned_by 'root' } 37 | it { should be_grouped_into 'root' } 38 | end 39 | 40 | # Test mongodb data directory is created with right permission. 41 | describe file(mongo_data_dir) do 42 | it { should be_directory } 43 | it { should be_mode 755 } 44 | it { should be_owned_by mongo_user } 45 | it { should be_grouped_into mongo_user } 46 | end 47 | 48 | # Test mongodb log file is created with right permission. 49 | describe file('/var/log/mongodb/mongod.log') do 50 | it { should be_file } 51 | it { should be_owned_by mongo_user } 52 | end 53 | 54 | # Test mongod process starts with expected mongodb config file 55 | describe command('mongo --eval "db.version()"') do 56 | its(:stdout) { should contain('3.0.11') } 57 | end 58 | -------------------------------------------------------------------------------- /test/integration/default/serverspec/default_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | # RHEL and Debian family has different value for some of mongodb settings. 4 | if os[:family] == 'redhat' 5 | mongo_user = 'mongod' 6 | mongo_data_dir = '/var/lib/mongo' 7 | elsif ['debian', 'ubuntu'] 8 | mongo_user = 'mongodb' 9 | mongo_data_dir = '/var/lib/mongodb' 10 | end 11 | 12 | # Test `mongodb-org-server` package is installed. 13 | describe package('mongodb-org-server') do 14 | it { should be_installed } 15 | end 16 | 17 | # Test `mongod` service is running. 18 | describe service('mongod') do 19 | it { should be_enabled } 20 | it { should be_running } 21 | end 22 | 23 | # Test mongodb port `27017` is listening. 24 | describe port(27017) do 25 | it { should be_listening } 26 | end 27 | 28 | # Test mongod process starts with expected mongodb config file 29 | describe command('ps -ef | grep mongod') do 30 | its(:stdout) { should contain('/etc/mongod.conf') } 31 | end 32 | 33 | # Test mongodb config file is created with right permission. 34 | describe file('/etc/mongod.conf') do 35 | it { should be_file } 36 | it { should be_owned_by 'root' } 37 | it { should be_grouped_into 'root' } 38 | end 39 | 40 | # Test mongodb data directory is created with right permission. 41 | describe file(mongo_data_dir) do 42 | it { should be_directory } 43 | it { should be_mode 755 } 44 | it { should be_owned_by mongo_user } 45 | it { should be_grouped_into mongo_user } 46 | end 47 | 48 | # Test disable-transparent-hugepages script is created 49 | describe file('/etc/init.d/disable-transparent-hugepages') do 50 | it { should be_file } 51 | it { should be_mode 755} 52 | it { should be_owned_by 'root' } 53 | it { should be_grouped_into 'root' } 54 | end 55 | 56 | # Test disable-transparent-hugepages service is enabled. 57 | describe service('disable-transparent-hugepages') do 58 | it { should be_enabled } 59 | end 60 | 61 | # Test transparent_hugepage is set to never 62 | describe command('cat /sys/kernel/mm/transparent_hugepage/defrag') do 63 | its(:stdout) { should contain ('\[never\]') } 64 | end 65 | 66 | # Test transparent_hugepage is set to never 67 | describe command('cat /sys/kernel/mm/transparent_hugepage/enabled') do 68 | its(:stdout) { should contain ('\[never\]') } 69 | end 70 | 71 | # Test mongodb log file is created with right permission. 72 | describe file('/var/log/mongodb/mongod.log') do 73 | it { should be_file } 74 | it { should be_owned_by mongo_user } 75 | end 76 | 77 | # Test mongod process starts with expected mongodb config file 78 | describe command('export LC_ALL="en_US.UTF-8"; mongo --eval "db.version()"') do 79 | its(:stdout) { should contain('3.2.8') } 80 | end 81 | -------------------------------------------------------------------------------- /test/integration/helpers/serverspec/Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | gem 'serverspec', '> 2.0' -------------------------------------------------------------------------------- /test/integration/helpers/serverspec/spec_helper.rb: -------------------------------------------------------------------------------- 1 | require 'serverspec' 2 | 3 | set :backend, :exec 4 | 5 | # Set path for testing 6 | set :path, '/sbin:/usr/sbin:/usr/local/sbin:$PATH' 7 | -------------------------------------------------------------------------------- /test/integration/mms-automation-agent-with-databag/serverspec/default_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | # RHEL and Debian family has different value for some of mongodb settings. 4 | if os[:family] == 'redhat' 5 | mongo_user = 'mongod' 6 | elsif ['debian', 'ubuntu'] 7 | mongo_user = 'mongodb' 8 | end 9 | 10 | # MMS Automation Agent is installed 11 | describe package('mongodb-mms-automation-agent-manager') do 12 | it { should be_installed } 13 | end 14 | 15 | # MMS Automation Agent is running 16 | describe service('mongodb-mms-automation-agent') do 17 | it { should be_enabled } 18 | it { should be_running } 19 | end 20 | 21 | # MMS Automation Agent config file is in place 22 | describe file('/etc/mongodb-mms/automation-agent.config') do 23 | it { should be_file } 24 | it { should be_mode 600 } 25 | it { should be_owned_by mongo_user } 26 | end 27 | 28 | # MMS Automation Agent config file is contains group_id and api_key value 29 | describe file('/etc/mongodb-mms/automation-agent.config') do 30 | it { should contain 'mmsGroupId=mms_group_id_from_data_bag' } 31 | it { should contain 'mmsApiKey=mms_api_key_from_data_bag' } 32 | end 33 | -------------------------------------------------------------------------------- /test/integration/mms-automation-agent/serverspec/default_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | # RHEL and Debian family has different value for some of mongodb settings. 4 | if os[:family] == 'redhat' 5 | mongo_user = 'mongod' 6 | elsif ['debian', 'ubuntu'] 7 | mongo_user = 'mongodb' 8 | end 9 | 10 | # MMS Automation Agent is installed 11 | describe package('mongodb-mms-automation-agent-manager') do 12 | it { should be_installed } 13 | end 14 | 15 | # MMS Automation Agent is running 16 | describe service('mongodb-mms-automation-agent') do 17 | it { should be_enabled } 18 | it { should be_running } 19 | end 20 | 21 | # MMS Automation Agent config file is in place 22 | describe file('/etc/mongodb-mms/automation-agent.config') do 23 | it { should be_file } 24 | it { should be_mode 600 } 25 | it { should be_owned_by mongo_user } 26 | end 27 | 28 | # MMS Automation Agent config file is contains group_id and api_key value 29 | describe file('/etc/mongodb-mms/automation-agent.config') do 30 | it { should contain 'mmsGroupId=grpgrpididid' } 31 | it { should contain 'mmsApiKey=apikeykekekekeke' } 32 | end 33 | -------------------------------------------------------------------------------- /test/integration/mms-monitoring-agent/serverspec/default_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | # MMS Automation Agent is installed 4 | describe package('mongodb-mms-monitoring-agent') do 5 | it { should be_installed } 6 | end 7 | 8 | # MMS Automation Agent is running 9 | describe service('mongodb-mms-monitoring-agent') do 10 | it { should be_enabled } 11 | it { should be_running } 12 | end 13 | 14 | # MMS Automation Agent config file is in place 15 | describe file('/etc/mongodb-mms/monitoring-agent.config') do 16 | it { should be_file } 17 | it { should be_mode 600 } 18 | it { should be_owned_by 'mongodb-mms-agent' } 19 | end 20 | 21 | # MMS Automation Agent config file is contains group_id and api_key value 22 | describe file('/etc/mongodb-mms/monitoring-agent.config') do 23 | it { should contain 'mmsApiKey=apikeykekekekeke' } 24 | end 25 | -------------------------------------------------------------------------------- /test/integration/mongos/serverspec/default_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | # RHEL and Debian family has different value for some of mongodb settings. 4 | if os[:family] == 'redhat' 5 | mongo_user = 'mongod' 6 | elsif ['debian', 'ubuntu'] 7 | mongo_user = 'mongodb' 8 | end 9 | 10 | # Test `mongodb-org` package is installed. 11 | describe package('mongodb-org-mongos') do 12 | it { should be_installed } 13 | end 14 | 15 | # Testing `mongos` service is not valid since test unit doesn't have valid config server 16 | # Testing mongodb port listening is not valid since test unit doesn't have valid config server 17 | 18 | # Test mongod process starts with expected mongodb config file 19 | describe command('ps -ef | grep mongos') do 20 | its(:stdout) { should contain('/etc/mongos.conf') } 21 | end 22 | 23 | # Test mongodb config file is created with right permission. 24 | describe file('/etc/mongos.conf') do 25 | it { should be_file } 26 | it { should be_owned_by mongo_user } 27 | end 28 | 29 | # Test mongodb replicaset key file is created with right permission. 30 | describe file('/etc/mongodb.key') do 31 | it { should_not be_file } 32 | end 33 | 34 | # Test mongodb log file is created with right permission. 35 | describe file('/var/log/mongodb/mongos.log') do 36 | it { should be_file } 37 | it { should be_owned_by mongo_user } 38 | end 39 | -------------------------------------------------------------------------------- /test/integration/replica/serverspec/default_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | # RHEL and Debian family has different value for some of mongodb settings. 4 | if os[:family] == 'redhat' 5 | mongo_user = 'mongod' 6 | mongo_data_dir = '/var/lib/mongo' 7 | elsif ['debian', 'ubuntu'] 8 | mongo_user = 'mongodb' 9 | mongo_data_dir = '/var/lib/mongodb' 10 | end 11 | 12 | # Test `mongodb-org-server` package is installed. 13 | describe package('mongodb-org-server') do 14 | it { should be_installed } 15 | end 16 | 17 | # Test `mongod` service is running. 18 | describe service('mongod') do 19 | it { should be_enabled } 20 | it { should be_running } 21 | end 22 | 23 | # Test mongodb port `27017` is listening. 24 | describe port(27017) do 25 | it { should be_listening } 26 | end 27 | 28 | # Test mongod process starts with expected mongodb config file 29 | describe command('ps -ef | grep mongod') do 30 | its(:stdout) { should contain('/etc/mongod.conf') } 31 | end 32 | 33 | # Test mongodb config file is created with right permission. 34 | describe file('/etc/mongod.conf') do 35 | it { should be_file } 36 | it { should be_owned_by 'root' } 37 | it { should be_grouped_into 'root' } 38 | end 39 | 40 | # Test mongodb data directory is created with right permission. 41 | describe file(mongo_data_dir) do 42 | it { should be_directory } 43 | it { should be_mode 755 } 44 | it { should be_owned_by mongo_user } 45 | it { should be_grouped_into mongo_user } 46 | end 47 | 48 | # Test mongodb log file is created with right permission. 49 | describe file('/var/log/mongodb/mongod.log') do 50 | it { should be_file } 51 | it { should be_owned_by mongo_user } 52 | end 53 | 54 | # Test mongodb config file contains expected replica set name 55 | describe file('/etc/mongod.conf') do 56 | it { should contain 'replSetName: replset-1' } 57 | end 58 | 59 | # Test mongodb replicaset key file is created with right permission. 60 | describe file('/srv/mongodb/mongodb-keyfile') do 61 | it { should be_file } 62 | it { should be_mode 600 } 63 | it { should be_owned_by mongo_user } 64 | it { should be_grouped_into mongo_user } 65 | end 66 | 67 | # Test mongodb replicaset key file is matching 68 | describe file('/srv/mongodb/mongodb-keyfile') do 69 | it { should contain "Mb5KNEpIVq1PRIZaA4lcV2KCi1BdSGuzhFUCH61tbhmgHk3Shcc8dbvYW1Lv7jC6\nAtrBWKG4Mn8G5fCTW0cEV0RexNhBRCmSUNszduVi00bMYipyisCD3UUu2ukdUqs9\nNRWlEqeAUEJp8nBZ0AnKpFdtYMsL3zKW7KepW9xWccC0DWQnfSmrZ19ppV0DNVRr\nS5zBbLw0pd7OImkovWAQurLdEVYlgXgkL2Sp7aOWIymrKmWe7leZ4+TITR6xXQ3H\nEcLuICxq+nyDOZ/eKblC5GTfcHyMfGRWiqdfuQeTJbWuo9xPCsbVgfz3c4saHphW\nMflwM1wKTFL/h2+dNSQfSDaOD9HZSprjqx0b4bFS5TsHfiJlaEfbZ0Mv9YPWd9Wi\nNnUDz6l6WW9UVIPCsTrCxRphzYjrn1MF2vIINypDbthpR4s97b89UtCxFsk/Rdzi\nN0RCQtf6a4UeeAf6SFZrWS2/PBzSCaaP/ic3fOaF7VAGQOand9fURkijWxiuBORB\nSP4ftXUoqROgjl1h4vz4C5BDERcN/TQtBmVcuhpqlwPFPhWBoCX09jUZRlodb181\nE9fDsISAZxsrmYNsqHtWwe/PioQFcRe55hk8FPC1TB+aHxtThof493Dd1nDzVXbp\nSOfttBB6qnG/XmgPXVNOov1kkmpaHjn8rvGN+SeMfq7XLnkJD24DgmW3037IYv2k\n/T2hNZaBBd875R+pVyzAmBR50yoJgiJjU/natq7VCcqJ4pMl/YjDvB1EFDQ/4sYy\nOnKtRrKmSEzsqarrKY6u1ttmmlF5i9q5vJmDUNVryxJOCZOS4V+Ma4ZPG3kkZ1sb\nPRS6ZUEBCdZW2Bscuxj3TJZDUuMS/dDq7FiGOC/hRm54YLgpwKaNK3Pc0Uw3FI3e\nObDVLKllDS6cKPDSetf3IJ3CBrCwpUtxDtLA5hIESzpBqbs9Kdm2GPO7UmapJ/ZQ\nKLkCs351W7MCmgXPqv0E7qFXcVnQ" } 70 | end 71 | -------------------------------------------------------------------------------- /test/integration/wired-tiger/serverspec/default_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | # RHEL and Debian family has different value for some of mongodb settings. 4 | if os[:family] == 'redhat' 5 | mongo_user = 'mongod' 6 | elsif ['debian', 'ubuntu'] 7 | mongo_user = 'mongodb' 8 | end 9 | 10 | mongo_data_dir = '/var/lib/mongodb/wiredTiger' 11 | 12 | # Test `mongodb-org-server` package is installed. 13 | describe package('mongodb-org-server') do 14 | it { should be_installed } 15 | end 16 | 17 | # Test `mongod` service is running. 18 | describe service('mongod') do 19 | it { should be_enabled } 20 | it { should be_running } 21 | end 22 | 23 | # Test mongodb port `27017` is listening. 24 | describe port(27017) do 25 | it { should be_listening } 26 | end 27 | 28 | # Test mongod process starts with expected mongodb config file 29 | describe command('ps -ef | grep mongod') do 30 | its(:stdout) { should contain('/etc/mongod.conf') } 31 | end 32 | 33 | # Test mongodb config file is created with right permission. 34 | describe file('/etc/mongod.conf') do 35 | it { should be_file } 36 | it { should be_owned_by 'root' } 37 | it { should be_grouped_into 'root' } 38 | end 39 | 40 | # Test mongodb data directory is created with right permission. 41 | describe file(mongo_data_dir) do 42 | it { should be_directory } 43 | it { should be_mode 755 } 44 | it { should be_owned_by mongo_user } 45 | it { should be_grouped_into mongo_user } 46 | end 47 | 48 | # Test mongodb log file is created with right permission. 49 | describe file('/var/log/mongodb/mongod.log') do 50 | it { should be_file } 51 | it { should be_owned_by mongo_user } 52 | end 53 | 54 | # Test mongodb config file contains expected replica set name 55 | describe file('/etc/mongod.conf') do 56 | it { should contain 'engine: wiredTiger' } 57 | end 58 | 59 | # Test mongod process starts with expected mongodb config file 60 | describe command('mongo --eval "printjson(db.serverStatus())"') do 61 | its(:stdout) { should contain('"name" : "wiredTiger"') } 62 | end 63 | -------------------------------------------------------------------------------- /test/libraries/mongodb3_helper_spec.rb: -------------------------------------------------------------------------------- 1 | require 'chef' 2 | require 'chef/node/immutable_collections' 3 | require './libraries/mongodb3_helper' 4 | 5 | describe 'Mongodb3Helper' do 6 | subject do 7 | Class.new do 8 | extend Mongodb3Helper 9 | end 10 | end 11 | context '#mongodb_config' do 12 | let(:config) { Chef::Node::ImmutableMash.new('systemLog' => { 'verbosity' => nil, 'path' => '/var/log', 'empty' => { 'foo' => nil } }) } 13 | it 'with an immutable Mash' do 14 | expect(YAML.load(subject.mongodb_config(config))).to eq('systemLog' => { 'path' => '/var/log' }) 15 | end 16 | end 17 | end 18 | -------------------------------------------------------------------------------- /test/roles/configsvr.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "configsvr", 3 | "description": "Role for MongoDB Config server", 4 | "json_class": "Chef::Role", 5 | "default_attributes": { 6 | "mongodb3": { 7 | "config" : { 8 | "mongod" : { 9 | "net" : { 10 | "port" : 27019 11 | }, 12 | "sharding" : { 13 | "clusterRole" : "configsvr" 14 | } 15 | } 16 | } 17 | } 18 | }, 19 | "override_attributes": { 20 | }, 21 | "chef_type": "role", 22 | "run_list": [ 23 | "recipe[mongodb3::default]" 24 | ], 25 | "env_run_lists": { 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /test/roles/mms_automation_agent.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "mms_automation_agent", 3 | "description": "Role for MMS automation agent", 4 | "json_class": "Chef::Role", 5 | "default_attributes": { 6 | "mongodb3" : { 7 | "config" : { 8 | "mms" : { 9 | "mmsGroupId" : "grpgrpididid", 10 | "mmsApiKey" : "apikeykekekekeke" 11 | } 12 | } 13 | } 14 | }, 15 | "override_attributes": { 16 | }, 17 | "chef_type": "role", 18 | "run_list": [ 19 | "recipe[mongodb3::mms_automation_agent]" 20 | ], 21 | "env_run_lists": { 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /test/roles/mms_monitoring_agent.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "mms_monitoring_agent", 3 | "description": "Role for MMS automation agent", 4 | "json_class": "Chef::Role", 5 | "default_attributes": { 6 | "mongodb3" : { 7 | "config" : { 8 | "mms" : { 9 | "mmsApiKey" : "apikeykekekekeke" 10 | } 11 | } 12 | } 13 | }, 14 | "override_attributes": { 15 | }, 16 | "chef_type": "role", 17 | "run_list": [ 18 | "recipe[mongodb3::mms_monitoring_agent]" 19 | ], 20 | "env_run_lists": { 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /test/roles/mongos.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "mongos", 3 | "description": "Role for Mongos", 4 | "json_class": "Chef::Role", 5 | "default_attributes": { 6 | "mongodb3" : { 7 | "config" : { 8 | "mongos" : { 9 | "sharding" : { 10 | "configDB" : "server1, server2, server3" 11 | } 12 | } 13 | } 14 | } 15 | }, 16 | "override_attributes": { 17 | }, 18 | "chef_type": "role", 19 | "run_list": [ 20 | "recipe[mongodb3::mongos]" 21 | ], 22 | "env_run_lists": { 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /test/roles/replset.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "replica", 3 | "description": "Role for Replica set", 4 | "json_class": "Chef::Role", 5 | "default_attributes": { 6 | "mongodb3" : { 7 | "config" : { 8 | "mongod" : { 9 | "replication" : { 10 | "replSetName" : "replset-1" 11 | }, 12 | "security" : { 13 | "keyFile" : "/srv/mongodb/mongodb-keyfile" 14 | } 15 | }, 16 | "key_file_content" : "Mb5KNEpIVq1PRIZaA4lcV2KCi1BdSGuzhFUCH61tbhmgHk3Shcc8dbvYW1Lv7jC6\nAtrBWKG4Mn8G5fCTW0cEV0RexNhBRCmSUNszduVi00bMYipyisCD3UUu2ukdUqs9\nNRWlEqeAUEJp8nBZ0AnKpFdtYMsL3zKW7KepW9xWccC0DWQnfSmrZ19ppV0DNVRr\nS5zBbLw0pd7OImkovWAQurLdEVYlgXgkL2Sp7aOWIymrKmWe7leZ4+TITR6xXQ3H\nEcLuICxq+nyDOZ/eKblC5GTfcHyMfGRWiqdfuQeTJbWuo9xPCsbVgfz3c4saHphW\nMflwM1wKTFL/h2+dNSQfSDaOD9HZSprjqx0b4bFS5TsHfiJlaEfbZ0Mv9YPWd9Wi\nNnUDz6l6WW9UVIPCsTrCxRphzYjrn1MF2vIINypDbthpR4s97b89UtCxFsk/Rdzi\nN0RCQtf6a4UeeAf6SFZrWS2/PBzSCaaP/ic3fOaF7VAGQOand9fURkijWxiuBORB\nSP4ftXUoqROgjl1h4vz4C5BDERcN/TQtBmVcuhpqlwPFPhWBoCX09jUZRlodb181\nE9fDsISAZxsrmYNsqHtWwe/PioQFcRe55hk8FPC1TB+aHxtThof493Dd1nDzVXbp\nSOfttBB6qnG/XmgPXVNOov1kkmpaHjn8rvGN+SeMfq7XLnkJD24DgmW3037IYv2k\n/T2hNZaBBd875R+pVyzAmBR50yoJgiJjU/natq7VCcqJ4pMl/YjDvB1EFDQ/4sYy\nOnKtRrKmSEzsqarrKY6u1ttmmlF5i9q5vJmDUNVryxJOCZOS4V+Ma4ZPG3kkZ1sb\nPRS6ZUEBCdZW2Bscuxj3TJZDUuMS/dDq7FiGOC/hRm54YLgpwKaNK3Pc0Uw3FI3e\nObDVLKllDS6cKPDSetf3IJ3CBrCwpUtxDtLA5hIESzpBqbs9Kdm2GPO7UmapJ/ZQ\nKLkCs351W7MCmgXPqv0E7qFXcVnQ" 17 | } 18 | } 19 | }, 20 | "override_attributes": { 21 | }, 22 | "chef_type": "role", 23 | "run_list": [ 24 | "recipe[mongodb3::default]" 25 | ], 26 | "env_run_lists": { 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /test/roles/wired_tiger.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "wired_tiger", 3 | "description": "Role for testing Wired Tiger storage engine", 4 | "json_class": "Chef::Role", 5 | "default_attributes": { 6 | "mongodb3" : { 7 | "config" : { 8 | "mongod" : { 9 | "storage" : { 10 | "dbPath" : "/var/lib/mongodb/wiredTiger", 11 | "engine" : "wiredTiger", 12 | "wiredTiger" : { 13 | "engineConfig" : { 14 | "cacheSizeGB" : 10, 15 | "statisticsLogDelaySecs" : 60, 16 | "journalCompressor" : "snappy", 17 | "directoryForIndexes" : false 18 | }, 19 | "collectionConfig" : { 20 | "blockCompressor" : "snappy" 21 | }, 22 | "indexConfig" : { 23 | "prefixCompression" : true 24 | } 25 | } 26 | } 27 | } 28 | } 29 | } 30 | }, 31 | "override_attributes": { 32 | }, 33 | "chef_type": "role", 34 | "run_list": [ 35 | "recipe[mongodb3::default]" 36 | ], 37 | "env_run_lists": { 38 | } 39 | } 40 | --------------------------------------------------------------------------------