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

Commit

Permalink
Adding wrapper cookbook
Browse files Browse the repository at this point in the history
* to prove wrapper cookbook can be used : #7
  • Loading branch information
sunggun-yu committed Jan 19, 2016
1 parent 8a8ee0e commit bd0cf5e
Show file tree
Hide file tree
Showing 12 changed files with 236 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .kitchen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,18 @@ suites:
- ami-2014.03
- debian-7.8

- name: mms-automation-agent-with-databag
driver:
vm_hostname: mms-automation-agent
encrypted_data_bag_secret_key_path: "test/data_bags/encrypted_data_bag_secret"
run_list:
- recipe[mongodb3-test::mms_automation_agent_with_data_bag]
provisioner:
client_rb:
environment: dev
includes:
- ubuntu-12.04

- name: mms-monitoring-agent
driver:
vm_hostname: mms-monitoring-agent
Expand Down
4 changes: 4 additions & 0 deletions Berksfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
source "https://supermarket.chef.io"

metadata

group :integration do
cookbook 'mongodb3-test', :path => './test/cookbooks/mongodb3-test'
end
13 changes: 13 additions & 0 deletions test/cookbooks/mongodb3-test/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
mongodb3-test CHANGELOG
=======================

This file is used to list changes made in each version of the mongodb3-test cookbook.

0.1.0
-----
- [your_name] - Initial release of mongodb3-test

- - -
Check the [Markdown Syntax Guide](http://daringfireball.net/projects/markdown/syntax) for help with Markdown.

The [Github Flavored Markdown page](http://github.github.com/github-flavored-markdown/) describes the differences between markdown on github and standard markdown.
68 changes: 68 additions & 0 deletions test/cookbooks/mongodb3-test/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
mongodb3-test Cookbook
======================
TODO: Enter the cookbook description here.

e.g.
This cookbook makes your favorite breakfast sandwich.

Requirements
------------
TODO: List your cookbook requirements. Be sure to include any requirements this cookbook has on platforms, libraries, other cookbooks, packages, operating systems, etc.

e.g.
#### packages
- `toaster` - mongodb3-test needs toaster to brown your bagel.

Attributes
----------
TODO: List your cookbook attributes here.

e.g.
#### mongodb3-test::default
<table>
<tr>
<th>Key</th>
<th>Type</th>
<th>Description</th>
<th>Default</th>
</tr>
<tr>
<td><tt>['mongodb3-test']['bacon']</tt></td>
<td>Boolean</td>
<td>whether to include bacon</td>
<td><tt>true</tt></td>
</tr>
</table>

Usage
-----
#### mongodb3-test::default
TODO: Write usage instructions for each cookbook.

e.g.
Just include `mongodb3-test` in your node's `run_list`:

```json
{
"name":"my_node",
"run_list": [
"recipe[mongodb3-test]"
]
}
```

Contributing
------------
TODO: (optional) If this is a public cookbook, detail the process for contributing. If this is a private cookbook, remove this section.

e.g.
1. Fork the repository on Github
2. Create a named feature branch (like `add_component_x`)
3. Write your change
4. Write tests for your change (if applicable)
5. Run the tests, ensuring they all pass
6. Submit a Pull Request using Github

License and Authors
-------------------
Authors: TODO: List authors
18 changes: 18 additions & 0 deletions test/cookbooks/mongodb3-test/attributes/default.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#
# Cookbook Name:: mongodb3-test
# Attribute:: default
#
# Copyright 2016, 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.
#
9 changes: 9 additions & 0 deletions test/cookbooks/mongodb3-test/metadata.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name 'mongodb3-test'
maintainer 'Sunggun Yu'
maintainer_email 'sunggun.dev@gmail.com'
license 'Apache 2.0'
description 'Installs/Configures mongodb3-test'
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version '0.1.0'

depends 'mongodb3'
20 changes: 20 additions & 0 deletions test/cookbooks/mongodb3-test/recipes/default.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#
# Cookbook Name:: mongodb3-test
# Recipe:: default
#
# Copyright 2016, 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.
#

include_recipe 'mongodb3::default'
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#
# Cookbook Name:: mongodb3-test
# Recipe:: mms_automation_agent_with_data_bag
#
# Copyright 2016, 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.
#

#
# The data bag content that is encrypted
#
# {
# "id" : "mms-agent",
# "environments": {
# "dev": {
# "mms_group_id" : "mms_group_id_from_data_bag",
# "mms_api_key" : "mms_api_key_from_data_bag"
# }
# }
# }

# mms agent data bag
mms_data_bag_item = Chef::EncryptedDataBagItem.load('mongodb', 'mms-agent')
mms_data_bag = mms_data_bag_item['environments'][node.chef_environment]

node.set['mongodb3']['config']['mms']['mmsGroupId'] = mms_data_bag['mms_group_id']
node.set['mongodb3']['config']['mms']['mmsApiKey'] = mms_data_bag['mms_api_key']

include_recipe 'mongodb3::mms_automation_agent'
11 changes: 11 additions & 0 deletions test/data_bags/encrypted_data_bag_secret
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
YC1xx2lq0MsaDW1lFihswcOP6XUzgMmSaWzI8ptspcnB6dCFBq1dFlGzpfsXXeys
X+fpkzLTo2aHMWDZiyzRuDl4ix1OO10TJRxNkLVvGiN4yHw+wk3+WOTcjm1qp0Vy
zsbN5BkjYPlzz9SfYyXZP2jTeo5aE/+oBiGDjzB8kiQ/7wJUt8aJdpW+ez6mwE+s
qLe8WvF73s0InPnxDIwcPfa2j8BCBY7fXgHsPf4xSMYG3DRG4dMNB2875NXVNLrW
d67eoNQedlQFsZlgeUDDVBCvsEWAhJImDvlzlGBLAn9UYKWwAnHFlFaEJ6zeN724
RvQ5g1SatnJijF8mNztdE8Mz5zhFpYI107D10wLBnHn7bISY+nHZHBvhjtPfmvSv
fOi/XICH8gu28Rp2etsOa9virojvGx81aWNOAPBLDuqQgLqCs8P3HEIhnD1iaU4X
9yQlDGb79viGCWKQMMaJNa3pgLH4dzEqgsb9ySPM4jnItE3X2X5KPqr8X9NKiYHX
yCksc4ZE6IbtJ8f0uC/qUbC1YleGdiC/drWAlURqZXOutBFrNv3ysOmx8q08EPJV
l4JJnwh6bsESfIiZu0fymKN6PgO85hSTRli0/nRjcUj07e27SF59/eRIIiD5VAQo
MQw1wJGpV36XvmT/u69eUz/ZraNTACJ19pyhWNtBJ+w=
9 changes: 9 additions & 0 deletions test/data_bags/mongodb/mms-agent.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"id": "mms-agent",
"environments": {
"encrypted_data": "B2rMHbbtkhNcl+BgF+nA/9ZGhgfa1O+J27NjvD6bDuz46Y9nSjiABK6K/CDq\n3FWignVJfJ9GegwrWyscX2Uk2publKopj8ZTKTew6+RTvy6rTXB9FA5+zy+L\nERRe2K8C2MFlBvZG5FT1kn6T6rTi80Z5mywlscz4w5QnCQAWwvs=\n",
"iv": "9HwyIJXUCFqBBS1yiLPN5A==\n",
"version": 1,
"cipher": "aes-256-cbc"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
require 'spec_helper'

# RHEL and Debian family has different value for some of mongodb settings.
if os[:family] == 'redhat'
mongo_user = 'mongod'
elsif ['debian', 'ubuntu']
mongo_user = 'mongodb'
end

# MMS Automation Agent is installed
describe package('mongodb-mms-automation-agent-manager') do
it { should be_installed }
end

# MMS Automation Agent is running
describe service('mongodb-mms-automation-agent') do
it { should be_enabled }
it { should be_running }
end

# MMS Automation Agent config file is in place
describe file('/etc/mongodb-mms/automation-agent.config') do
it { should be_file }
it { should be_mode 600 }
it { should be_owned_by mongo_user }
end

# MMS Automation Agent config file is contains group_id and api_key value
describe file('/etc/mongodb-mms/automation-agent.config') do
it { should contain 'mmsGroupId=mms_group_id_from_data_bag' }
it { should contain 'mmsApiKey=mms_api_key_from_data_bag' }
end

0 comments on commit bd0cf5e

Please sign in to comment.