Adoptable Cookbooks List

Looking for a cookbook to adopt? You can now see a list of cookbooks available for adoption!
List of Adoptable Cookbooks

Supermarket Belongs to the Community

Supermarket belongs to the community. While Chef has the responsibility to keep it running and be stewards of its functionality, what it does and how it works is driven by the community. The chef/supermarket repository will continue to be where development of the Supermarket application takes place. Come be part of shaping the direction of Supermarket by opening issues and pull requests or by joining us on the Chef Mailing List.

Select Badges

Select Supported Platforms

Select Status

RSS

chef_handler_sns (5) Versions 3.0.0

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.

Policyfile
Berkshelf
Knife
cookbook 'chef_handler_sns', '~> 3.0.0', :supermarket
cookbook 'chef_handler_sns', '~> 3.0.0'
knife supermarket install chef_handler_sns
knife supermarket download chef_handler_sns
README
Dependencies
Changelog
Quality 17%

Description

Cookbook Version
GitHub
License

Dependency Status
Build Status

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

Supported Platforms

  • Amazon Linux
  • CentOS
  • Debian
  • Fedora
  • FreeBSD
  • openSUSE
  • Oracle Linux
  • RedHat
  • Scientific Linux
  • SUSE
  • Ubuntu

Required 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 want to install chef-handler-sns gem versions older than version 2, you can use previous cookbook versions:

# Berksfile

cookbook 'chef_handler_sns', '~> 2.0'

Testing

See TESTING.md.

ChefSpec Matchers

chef_handler_sns(topic_arn)

Helper method for locating a chef_handler_sns resource in the collection.

topic_arn = 'arn:aws:sns:us-east-1:12341234:MyTopicName'
resource = chef_run.chef_handler_sns(topic_arn)

expect(resource).to notify('service[apache2]').to(:reload)

enable_chef_handler_sns(topic_arn)

Assert that the Chef run enables chef_handler_sns.

topic_arn = 'arn:aws:sns:us-east-1:12341234:MyTopicName'

expect(chef_run).to enable_chef_handler_sns(topic_arn)
  .with_access_key('***AMAZON-KEY***')
  .with_secret_key('***AMAZON-SECRET***')

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-2016, 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

chef_handler ~> 1.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.

v3.0.0 (2016-01-01)

Breaking Changes on v3.0.0

  • Update chef-handler-sns gem to version 2.
    • Drop gem version 1 support.

Improvements on v3.0.0

  • Update RuboCop to 0.35.
  • metadata: Add source_url and issues_url links.
  • Add version constraint to chef_handler dependency.

Documentation Changes on v3.0.0

  • Some documentation improvements.
  • Add a LICENSE file.
  • Add a .yardopts and a .inch.yml file.
  • Update license year.
  • README:
    • Fix the json example.
    • Move ChefSpec matchers to the README.
    • Add badges: GitHub, license, gemnasium.

Changes on Tests on v3.0.0

  • Run test-kitchen with Travis CI native Docker support.
  • Test on multiple platforms, including using Docker and multiple clouds.
  • Move ChefSpec tests to test/unit.

v2.0.0 (2015-12-26)

Breaking Changes on v2.0.0

  • Drop Ruby 1.8 and 1.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 Chef 12.
  • Install chef-handler-sns gem version 1.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)

v1.0.0 (2014-06-07)

v0.1.0 (2014-02-20)

  • Initial release of chef_handler_sns.

Collaborator Number Metric
            

3.0.0 failed this metric

Failure: Cookbook has 1 collaborators. A cookbook must have at least 2 collaborators to pass this metric.

Contributing File Metric
            

3.0.0 failed this metric

Failure: To pass this metric, your cookbook metadata must include a source url, the source url must be in the form of https://github.com/user/repo, and your repo must contain a CONTRIBUTING.md file

Foodcritic Metric
            

3.0.0 failed this metric

FC066: Ensure chef_version is set in metadata: chef_handler_sns/metadata.rb:1
FC069: Ensure standardized license defined in metadata: chef_handler_sns/metadata.rb:1
FC072: Metadata should not contain "attribute" keyword: chef_handler_sns/metadata.rb:1
FC074: LWRP should use DSL to define resource's default action: chef_handler_sns/resources/default.rb:1
FC121: Cookbook depends on cookbook made obsolete by Chef 14: chef_handler_sns/metadata.rb:1
Run with Foodcritic Version 16.3.0 with tags metadata,correctness ~FC031 ~FC045 and failure tags any

No Binaries Metric
            

3.0.0 passed this metric

Testing File Metric
            

3.0.0 failed this metric

Failure: To pass this metric, your cookbook metadata must include a source url, the source url must be in the form of https://github.com/user/repo, and your repo must contain a TESTING.md file

Version Tag Metric
            

3.0.0 failed this metric

Failure: To pass this metric, your cookbook metadata must include a source url, the source url must be in the form of https://github.com/user/repo, and your repo must include a tag that matches this cookbook version number