cookbook 'chef_handler_sns', '= 2.0.0'
chef_handler_sns (5) Versions 2.0.0 Follow2
Installs and enables chef-handler-sns: A simple Chef report handler that reports status of a Chef run through Amazon SNS. Includes IAM roles support. Amazon SNS can send notifications by SMS, email, Amazon SQS queues or to any HTTP endpoint.
cookbook 'chef_handler_sns', '= 2.0.0', :supermarket
knife supermarket install chef_handler_sns
knife supermarket download chef_handler_sns
Description
Chef cookbook to install and enable chef-handler-sns: A simple Chef report handler that reports status of a Chef run through Amazon SNS. Includes IAM roles support.
Amazon SNS can send notifications by SMS, email, Amazon SQS queues or to any HTTP endpoint.
This cookbook has been tested to work with AWS OpsWorks.
Requirements
Cookbooks:
Attributes
Attribute | Default | Description |
---|---|---|
node['chef_handler_sns']['topic_arn'] |
required | AWS topic ARN name (required). |
node['chef_handler_sns']['access_key'] |
calculated from ohai with IAM roles | AWS access key (required, but will try to read it from ohai with IAM roles). |
node['chef_handler_sns']['secret_key'] |
calculated from ohai with IAM roles | AWS secret key (required, but will try to read it from ohai with IAM roles). We do not recomend using this attribute, it is better to use the LWRP. |
node['chef_handler_sns']['token'] |
calculated from ohai with IAM roles | AWS security token (read from ohai with IAM roles). Set to false to disable the token detected by ohai. |
node['chef_handler_sns']['region'] |
calculated from ohai | AWS region. |
node['chef_handler_sns']['subject'] |
calculated | Message subject string in erubis format. |
node['chef_handler_sns']['body_template'] |
calculated | Full path of an erubis template file to use for the message body. |
node['chef_handler_sns']['supports'] |
{ 'exception' => true } |
Type of Chef Handler to register as, ie :report , :exception or both. |
node['chef_handler_sns']['version'] |
latest stable | chef-handler-sns gem version to install. |
node['chef_handler_sns']['mirror_url'] |
nil |
chef-handler-sns mirror to download the gem from. For cases where you do not want to use RubyGems. |
Recipes
chef_handler_sns::default
Installs and enables the Chef SNS Handler.
Resources
chef_handler_sns[topic_arn]
Installs and enables the Chef SNS handler.
chef_handler_sns Actions
-
enable
: Installs and enables the Chef Handler.
chef_handler_sns Parameters
Parameter | Default | Description |
---|---|---|
topic_arn | resource name | AWS topic ARN name (required). |
access_key | node['chef_handler_sns']['access_key'] |
AWS access key (required, but will try to read it from ohai with IAM roles). |
secret_key | node['chef_handler_sns']['secret_key'] |
AWS secret key (required, but will try to read it from ohai with IAM roles). |
token | node['chef_handler_sns']['token'] |
AWS security token (read from ohai with IAM roles). Set to false to disable the token detected by ohai. |
region | node['chef_handler_sns']['region'] |
AWS region. |
subject | node['chef_handler_sns']['subject'] |
Message subject string in erubis format. |
body_template | node['chef_handler_sns']['body_template'] |
Full path of an erubis template file to use for the message body. |
supports | node['chef_handler_sns']['supports'] |
Type of Chef Handler to register as, ie :report , :exception or both. |
version | node['chef_handler_sns']['version'] |
chef-handler-sns gem version to install. |
mirror_url | node['chef_handler_sns']['mirror_url'] |
chef-handler-sns mirror to download the gem from. For cases where you do not want to use RubyGems. |
AWS Credentials permissions
If you are using AWS IAM credentials or AWS IAM role credentials, they should have at least the following privileges:
{ "Statement": [ { "Sid": "Stmt1234", "Effect": "Allow", "Action": [ "sns:Publish" ], "Resource": [ "arn:aws:sns:us-east-1:12341234:MyTopicName" ] } ] }
Usage Examples
Using Amazon IAM roles
Using chef_handler_sns
cookbook with IAM roles is rather easy.
Including in a Cookbook Recipe
First, you need to include this cookbook as a dependency in your cookbook:
# metadata.rb depends 'chef_handler_sns'
# in your recipe node['chef_handler_sns']['topic_arn'] = 'arn:aws:sns:us-east-1:12341234:MyTopicName' include_recipe 'chef_handler_sns::default'
Using the LWRP from a Cookbook Recipe
You can also use the chef_handler_sns
LWRP directly instead of including the recipe:
# metadata.rb depends 'chef_handler_sns'
# in your recipe chef_handler_sns 'arn:aws:sns:us-east-1:12341234:MyTopicName'
Including in the Run List
To include this cookbook directly in your run list, you must set at least the topic_arn
attribute:
{ "name": "git.zuazo.org", [...] "normal": { "chef_handler_sns": { "topic_arn": "arn:aws:sns:us-east-1:12341234:MyTopicName" } }, "run_list": [ [...] "recipe[chef_handler_sns]" ] }
Passing the AWS credentials (machines without IAM roles)
If you are using Amazon EC2 without IAM roles or machines from other providers outside AWS, you must set the AWS credentials: access_key
and secret_key
(and sometimes also token
).
Using the LWRP from a Cookbook Recipe
# metadata.rb depends 'chef_handler_sns'
# in your recipe chef_handler_sns 'arn:aws:sns:us-east-1:12341234:MyTopicName' do access_key '***AMAZON-KEY***' secret_key '***AMAZON-SECRET***' end
Installing old versions
If you are not using IAM roles and you don't need to use AWS security tokens, you can use old versions of chef-handler-sns
(< 1.0.0
). Those versions does not require nokogiri
, so they have lighter dependencies and take less time to install.
chef_handler_sns 'arn:aws:sns:us-east-1:12341234:MyTopicName' do access_key '***AMAZON-KEY***' secret_key '***AMAZON-SECRET***' version '0.2.6' end
Testing
See TESTING.md.
Contributing
Please do not hesitate to open an issue with any questions or problems.
See CONTRIBUTING.md.
TODO
See TODO.md.
License and Author
Author: | Xabier de Zuazo (xabier@zuazo.org) |
Copyright: | Copyright (c) 2015, Xabier de Zuazo |
Copyright: | Copyright (c) 2014, Onddo Labs, SL. |
License: | Apache License, Version 2.0 |
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.
Dependent cookbooks
xml >= 0.0.0 |
chef_handler >= 0.0.0 |
Contingent cookbooks
There are no cookbooks that are contingent upon this one.
CHANGELOG for chef_handler_sns
This file is used to list changes made in each version of the chef_handler_sns
cookbook.
v2.0.0 (2015-12-26)
Breaking Changes on v2.0.0
- Drop Ruby
1.8
and1.9.2
support (not tested).
New Features on v2.0.0
- ChefSpec matchers: Add helper methods to locate LWRP resources.
- Add support to install from a URL.
Fixes on v2.0.0
- Fix prerelease gem option.
- Use relative gem path if complete path is not found.
Improvements on v2.0.0
- Integrate with RuboCop.
- Enable
chef_gem#compile_time
for Chef12
. - Install
chef-handler-sns
gem version1.2.0
by default.
Documentation Changes on v2.0.0
- Homogenize license headers.
- Update chef links to use chef.io domain.
- Update contact information and links after migration.
- README:
- Fix build status badge links.
- Split it in multiple files.
Changes on Tests on v2.0.0
- Gemfile: Upadte to ChefSpec
4.1
. - Fix RSpec old syntax warnings.
- Integrate with
should_not
- Updates: Berksfile, Gemfile, Guardfile, Rakefile.
- Enable ChefSpec coverage.
- Update Berkshelf to version
4
. - Run tests on Ruby
2.2
. - Update foodcritic to version
5
.
v1.1.0 (2014-07-07)
- README:
- Clarify setting for both reports (issue #1, thanks Florian Holzhauer).
- Token attribute should accept
false
(related tochef-handler-sns
gem issue #5, thanks Michael Hobbs for reporting and testing). - Gemfile:
- Some versions updated.
- Added
chef-sugar
as dependency for the tests.
v1.0.0 (2014-06-07)
- README: some style and small fixes.
- Fix support for Chef inside Bundler, used by AWS OpsWorks (thanks Michael Hobbs, for reporting in chef-handler-sns issue #4).
- Removed
use_system_libraries
attribute, integrated inside xml cookbook (1.2.4).
v0.1.0 (2014-02-20)
- Initial release of
chef_handler_sns
.
Foodcritic Metric
2.0.0 passed this metric
2.0.0 passed this metric