Skip to content
This repository has been archived by the owner on May 20, 2020. It is now read-only.

Merge develop into master #4

Merged
merged 4 commits into from
Aug 5, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 47 additions & 3 deletions .kitchen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,29 @@ suites:
excludes:
- oel-6.6

- name: default-305
driver:
vm_hostname: mongo3
run_list:
- recipe[apt]
- recipe[mongodb3::default]
attributes:
mongodb3:
version: 3.0.5
chef_client:
config:
force_logger: true
log_level: info
build-essential:
compile_time: false
apt:
compile_time_update: true
provisioner:
client_rb:
environment: dev
excludes:
- oel-6.6

- name: replica
driver:
vm_hostname: replica
Expand Down Expand Up @@ -122,12 +145,12 @@ suites:
excludes:
- oel-6.6

- name: mms-agent
- name: mms-automation-agent
driver:
vm_hostname: mms-agent
vm_hostname: mms-automation-agent
run_list:
- recipe[apt]
- role[mms_agent]
- role[mms_automation_agent]
attributes:
chef_client:
config:
Expand All @@ -142,3 +165,24 @@ suites:
environment: dev
excludes:
- oel-6.6

- name: mms-monitoring-agent
driver:
vm_hostname: mms-monitoring-agent
run_list:
- recipe[apt]
- role[mms_monitoring_agent]
attributes:
chef_client:
config:
force_logger: true
log_level: info
build-essential:
compile_time: false
apt:
compile_time_update: true
provisioner:
client_rb:
environment: dev
excludes:
- oel-6.6
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# mongodb3 Cookbook CHANGELOG

## 2.0.0

WARNING : `mms-agent` recipe has been deprecated at this version.

* 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.
* Removing `mms-agent` recipe and divide it as `mms-automation-agent` and `mms-monitoring-agent` recipe


## 1.0.0

mongodb3 Chef Cookbook 1.0.0 release.
Expand Down
87 changes: 79 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
# mongodb3 cookbook

[![Build Status](https://travis-ci.org/sunggun-yu/chef-mongodb3.svg?branch=master)](https://travis-ci.org/sunggun-yu/chef-mongodb3)
WARNING : `mms-agent` recipe has been deprecated.

[![Build Status](https://travis-ci.org/sunggun-yu/chef-mongodb3.svg?branch=develop)](https://travis-ci.org/sunggun-yu/chef-mongodb3)

Install and configure the MongoDB 3.0.x

* Install and configure the mongod (or configure the config server for shard cluster)
* Install and configure the mongos
* Also, mongos configure the mongos service with runit : `service mongos start|stop|restart|status`
* Install the MMS Automation Agent
* Install the MMS Monitoring Agent

## Supported Platforms

Expand All @@ -19,11 +22,13 @@ Install and configure the MongoDB 3.0.x

### Cookbook Attributes

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.

```
# MongoDB version to install
default['mongodb3']['version'] = '3.0.4' or '3.0.4-1.el[5|6]'
default['mongodb3']['version'] = '3.0.4'

# MongoDB user:group
# MongoDB user:group : PLEASE DO NOT SET THE USER AND GROUP ATTRIBUTE
default['mongodb3']['user'] = 'mongod' | 'mongodb'
default['mongodb3']['group'] = 'mongod' | 'mongodb'

Expand Down Expand Up @@ -315,16 +320,30 @@ Include `mongodb3::mongos` in your node's `run_list`:
}
```

### mongodb3::mms_agent
### mongodb3::mms\_automation_agent

Install the MMS Automation Agent.

Include `mongodb3::mms_agent` in your node's `run_list`:
Include `mongodb3::mms_automation_agent` in your node's `run_list`:

```json
{
"run_list": [
"recipe[mongodb3::mms_automation_agent]"
]
}
```

### mongodb3::mms\_monitoring_agent

Install the MMS Monitoring Agent.

Include `mongodb3::mms_monitoring_agent` in your node's `run_list`:

```json
{
"run_list": [
"recipe[mongodb3::mms_agent]"
"recipe[mongodb3::mms_monitoring_agent]"
]
}
```
Expand Down Expand Up @@ -614,7 +633,7 @@ You can set the config attribute on node or wrapper recipe.

```json
{
"name": "mms_agent",
"name": "mms_automation_agent",
"description": "Role for MMS automation agent",
"json_class": "Chef::Role",
"default_attributes": {
Expand All @@ -631,7 +650,7 @@ You can set the config attribute on node or wrapper recipe.
},
"chef_type": "role",
"run_list": [
"recipe[mongodb3::mms_agent]"
"recipe[mongodb3::mms_automation_agent]"
],
"env_run_lists": {
}
Expand Down Expand Up @@ -696,6 +715,58 @@ maxLogFileSize=268435456

```

### MMS Monitoring agent

#### Role file

You can set the config attribute on node or wrapper recipe.

```json
{
"name": "mms_monitoring_agent",
"description": "Role for MMS monitoring agent",
"json_class": "Chef::Role",
"default_attributes": {
"mongodb3" : {
"config" : {
"mms" : {
"api_key" : "apikeykekekekeke"
}
}
}
},
"override_attributes": {
},
"chef_type": "role",
"run_list": [
"recipe[mongodb3::mms_monitoring_agent]"
],
"env_run_lists": {
}
}

```

#### Result of `/etc/mongodb-mms/monitoring-agent.config`

```text
# THIS FILE IS MAINTAINED BY CHEF. DO NOT MODIFY AS IT WILL BE OVERWRITTEN.

#
# Enter your API key - See: cloud.mongodb.com/settings/group
#
mmsApiKey=apikeykekekekeke

#
# Hostname of the MMS monitoring web server.
#
mmsBaseUrl=https://api-agents.mongodb.com

# For additional optional settings, please see
# https://docs.cloud.mongodb.com/reference/monitoring-agent/

```

## License and Authors

Author:: Sunggun Yu (sunggun.dev@gmail.com)
Expand Down
1 change: 0 additions & 1 deletion attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
mongo_group = 'mongod'
mongo_dbpath = '/var/lib/mongo'
mongo_pid_file = '/var/run/mongodb/mongodb.pid'
default['mongodb3']['version'] = "#{node['mongodb3']['version']}-1.el#{node.platform_version.to_i}" # ~FC019
config_processManagement_fork = true
when 'debian'
mongo_user = 'mongodb'
Expand Down
2 changes: 1 addition & 1 deletion metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@
depends 'apt'
depends 'yum'
depends 'user'
depends 'runit', '~> 1.6.0'
depends 'runit', '~> 1.7.0'
13 changes: 11 additions & 2 deletions recipes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,19 @@
include_recipe 'mongodb3::package_repo'

# Install MongoDB package
install_package = %w(mongodb-org mongodb-org-server mongodb-org-shell mongodb-org-mongos mongodb-org-tools)
install_package = %w(mongodb-org-server mongodb-org-shell mongodb-org-tools)

# Setup package version to install
case node['platform_family']
when 'rhel', 'fedora'
package_version = "#{node['mongodb3']['version']}-1.el#{node.platform_version.to_i}" # ~FC019
when 'debian'
package_version = node['mongodb3']['version']
end

install_package.each do |pkg|
package pkg do
version node['mongodb3']['version']
version package_version
action :install
end
end
Expand Down
2 changes: 1 addition & 1 deletion recipes/mms_agent.rb → recipes/mms_automation_agent.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#
# Cookbook Name:: mongodb3
# Recipe:: mms_agent
# Recipe:: mms_automation_agent
#
# Copyright 2015, Sunggun Yu
#
Expand Down
72 changes: 72 additions & 0 deletions recipes/mms_monitoring_agent.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#
# Cookbook Name:: mongodb3
# Recipe:: mms_monitoring_agent
#
# Copyright 2015, Sunggun Yu
#
# Licensed under the Apache License, Version 2.0 (the 'License');
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an 'AS IS' BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

# Install curl
package 'curl' do
action :install
end

# Set variables by platform
case node['platform_family']
when 'rhel', 'fedora'
mms_agent_source = 'https://cloud.mongodb.com/download/agent/monitoring/mongodb-mms-monitoring-agent-latest.x86_64.rpm'
mms_agent_file = '/root/mongodb-mms-monitoring-agent-latest.x86_64.rpm'
when 'debian'
mms_agent_source = 'https://cloud.mongodb.com/download/agent/monitoring/mongodb-mms-monitoring-agent_latest_amd64.deb'
mms_agent_file = '/root/mongodb-mms-monitoring-agent_latest_amd64.deb'
end

# Download the mms automation agent manager latest
remote_file mms_agent_file do
source mms_agent_source
action :create
end

# Install package
case node['platform_family']
when 'rhel', 'fedora'
rpm_package 'mongodb-mms-monitoring-agent' do
source mms_agent_file
action :install
end
when 'debian'
dpkg_package 'mongodb-mms-monitoring-agent' do
source mms_agent_file
action :install
end
end

# Create or modify the mms agent config file
template '/etc/mongodb-mms/monitoring-agent.config' do
source 'monitoring-agent.config.erb'
mode 0600
owner 'mongodb-mms-agent'
group 'mongodb-mms-agent'
variables(
:config => node['mongodb3']['config']['mms']
)
end

# Start the mms automation agent
service 'mongodb-mms-monitoring-agent' do
# The service provider of MMS Agent for Ubuntu is upstart
provider Chef::Provider::Service::Upstart if node['platform_family'] == 'debian'
supports :status => true, :restart => true, :stop => true
action [ :enable, :start ]
end
11 changes: 10 additions & 1 deletion recipes/mongos.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,18 @@

# Install Mongos package
install_package = %w(mongodb-org-shell mongodb-org-mongos mongodb-org-tools)

# Setup package version to install
case node['platform_family']
when 'rhel', 'fedora'
package_version = "#{node['mongodb3']['version']}-1.el#{node.platform_version.to_i}" # ~FC019
when 'debian'
package_version = node['mongodb3']['version']
end

install_package.each do |pkg|
package pkg do
version node['mongodb3']['version']
version package_version
action :install
end
end
Expand Down
28 changes: 28 additions & 0 deletions recipes/user.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#
# Cookbook Name:: mongodb3
# Recipe:: user
#
# Copyright 2015, Sunggun Yu
#
# Licensed under the Apache License, Version 2.0 (the 'License');
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an 'AS IS' BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

# Create the mongodb user if not exist
user node['mongodb3']['user'] do
action :create
end

# Create the mongodb group if not exist
group node['mongodb3']['group'] do
members node['mongodb3']['user']
end
Loading