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_cfn (9) Versions 2.0.3

Chef integration with AWS cloudformation

Policyfile
Berkshelf
Knife
cookbook 'chef_cfn', '= 2.0.3', :supermarket
cookbook 'chef_cfn', '= 2.0.3'
knife supermarket install chef_cfn
knife supermarket download chef_cfn
README
Dependencies
Changelog
Quality 0%

Chef_cfn Cookbook

Provide tools to aid in the integration of Chef with AWS Cloudformation.

Requirements

Cookbooks:

  • chef_handler
  • python
  • ohai

Attributes

<table>
<tr>
<td>Attribute</td>
<td>Description</td>
<td>Default</td>
</tr>
<tr>
<td><code>node['cfn']['properties']</code></td>
<td>Cloudformation metadata properties merged with cfn hint</td>
<td><code>{}</code></td>
</tr>
<tr>
<td><code>node['cfn']['properties']['mounts']</code></td>
<td>Provides a mechanism to ensure volumes are mounted during chef</td>
<td><code>{}</code></td>
</tr>
<tr>
<td><code>node['cfn']['recipes']</code></td>
<td>Booleans determining which recipes are executed</td>
<td><code>{}</code></td>
</tr>
<tr>
<td><code>node['cfn']['stack']</code></td>
<td>Cloudformation Stack ohai namespace</td>
<td><code>{}</code></td>
</tr>
<tr>
<td><code>node['cfn']['stack']['autoscaling_name']</code></td>
<td>Name of the autoscaling group that spawn the instance</td>
<td><code>ohai</code></td>
</tr>
<tr>
<td><code>node['cfn']['stack']['logical_id']</code></td>
<td>Cloudformation stack logical id</td>
<td><code>ohai</code></td>
</tr>
<tr>
<td><code>node['cfn']['stack']['stack_id']</code></td>
<td>Cloudformation stack id</td>
<td><code>ohai</code></td>
</tr>
<tr>
<td><code>node['cfn']['stack']['stack_name']</code></td>
<td>Cloudformation stack name</td>
<td><code>ohai</code></td>
</tr>
<tr>
<td><code>node['cfn']['tags']</code></td>
<td>Cloudformation Tags ohai namespace, converted to snake case</td>
<td><code>{}</code></td>
</tr>
<tr>
<td><code>node['cfn']['tools']['delete_on_shutdown']</code></td>
<td>Delete the chef node on instance shutdown</td>
<td><code>true</code></td>
</tr>
<tr>
<td><code>node['cfn']['tools']['cfn_hup']['interval']</code></td>
<td>cfn-hup will scan for metadata changes every N seconds</td>
<td><code>10</code></td>
</tr>
<tr>
<td><code>node['cfn']['tools']['cfn_hup']['verbose']</code></td>
<td>Should cfn-hup provide verbose output</td>
<td><code>false</code></td>
</tr>
<tr>
<td><code>node['cfn']['tools']['url']</code></td>
<td>Tarball url for cfn-init installation</td>
<td><code></code></td>
</tr>
<tr>
<td><code>node['cfn']['vpc']</code></td>
<td>Cloudformation VPC ohai namespace</td>
<td><code>{}</code></td>
</tr>
<tr>
<td><code>node['cfn']['vpc']['region_id']</code></td>
<td>Aws region the instance belongs to</td>
<td><code>ohai</code></td>
</tr>
<tr>
<td><code>node['cfn']['vpc']['subnet_id']</code></td>
<td>Aws subnet the instance belongs to</td>
<td><code>ohai</code></td>
</tr>
<tr>
<td><code>node['cfn']['vpc']['vpc_id']</code></td>
<td>Aws vpc the instance belongs to</td>
<td><code>ohai</code></td>
</tr>
</table>

Recipes

chef_cfn::default

Installs dependencies

chef_cfn::awslogs

Install and configure the cloudwatch logs service

chef_cfn::cloudinit

Configure cloud-init in a more stripped down ec2-specific way. This recipe is mostly of use when packaging AMIs with Packer.

chef_cfn::handler

Install the CFN handler to callback to cloudformation on stack updates. Although this is still here, you'd likely be better off simply calling cfn-signal directly from user-data.

chef_cfn::knife

(optional) Provides a basic knife.rb

chef_cfn::ohai

Installs the aws-sdk chef_gem as well as the ohai[cfn] plugin.
When this runs, it will populate the properties, stack, tags and vpc attribute hashes under the node['cfn'] namespace which may then be used to report signals with the signal handler.

In addition, the properties hash will be merged, and potentially overriden, by any hints set in the cfn hint.

Required IAM policies
{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "Stmt1434370036000",
            "Effect": "Allow",
            "Action": [
                "cloudformation:DescribeStackResource",
                "ec2:DescribeInstances"
            ],
            "Resource": [
                "*"
            ]
        }
    ]
}

chef_cfn::handler

Installs a handler to signal cloudformation of the success or failure of the chef run. When used with either Creation or Update profiles in cloudformation, we can ensure that only nodes with valid chef runs are considered healthy.

This may be disabled by setting node.cfn.tools.signal_cloudformation.

Required IAM policies
{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "Stmt1434370036000",
            "Effect": "Allow",
            "Action": [
                "cloudformation:SignalResource",
            ],
            "Resource": [
                "*"
            ]
        }
    ]
}
Example Cloudformation
{
  "AutoScailingGroup": {
    "CreationPolicy": {
      "ResourceSignal": {
        "Count": 1,
        "Timeout": "PT10M"
      }
    },
    "UpdatePolicy": {
      "AutoScalingRollingUpdate": {
        "WaitOnResourceSignals": "true"
      }
    }
  }
}

chef_cfn::mounts

Mounts cloudformation defined volumes.

Please take note that this recipe assumes that cloudformation was responsible to creating and managing the volumes, not chef. As such, all block devices must exist prior to attempting to mount them.

Example Cloudformation Attributes
{
  "AutoScailingGroup": {
    "Metadata": {
      "Mounts": {
        "xvdb3": {
          "mount_point": "/var/log",
          "mount_options": "",
          "filesystem": ""
        }
      }
    }
  }
}

chef_cfn::tools

Installs cloudformation cfn-init tools such as :

  • cfn-init
  • cfn-hup: Periodic polling of cloudformation resource metadata to determine when triggered actions should run.

chef_cfn::shutdown

Installs a service which will delete the node when the instance shuts down.

Resources

chef_cfn_signal

Provides an interface to trigger cloudformation signals from within recipes. This is designed to be used with cloudformation WaitConditions.

Actions

  • signal: Default action

Attribute Parameters

  • url: Url of the resource or WaitHandler to signal
  • unique_id: Unique id of the notification
  • data: Defaults to <code>""</code>.
  • success: Defaults to <code>true</code>.
  • reason: Defaults to <code>"Chef triggered signal from resource"</code>.
  • once: Defaults to <code>true</code>.

Ohai Plugins

CFN

Fetches instance attributes from Cloudformation:DescribeResource as well as EC2:DescribeInstances.

License and Author

Author:: Jonathan Serafini (jonathan@serafini.ca)

Copyright:: 2015, Jonathan Serafini

License:: Apache 2.0

Dependent cookbooks

chef_handler >= 0.0.0
ohai >= 4.0.0
python >= 1.4.0

Contingent cookbooks

There are no cookbooks that are contingent upon this one.

chef_cfn changelog

v2.0.3

  • Add missing ohai feature flag
  • Remove additional cfn init modules

v2.0.2

  • cloud-init bugfixes
  • awslogs service bugfix

v2.0.1

  • Bugfixes

v2.0.0

  • Refactor code for cookstyle
  • Add recipe feature flags to disable some recipes
  • Add boolean to disable cloudformation handler
  • Add awslogs installation

v1.0.0

  • Update ohai recipes to rely on the newer ohai v4+ format

v0.9.2

  • Rubocop auto-correct Style/StringLiterals
  • Rubocop auto-correct Style/TrailingBlankLines
  • Rubocop auto-correct Style/TrailingWhitespace
  • Rubocop auto-correct Lint/DeprecatedClassMethods
  • Rubocop auto-correct Style/SpaceAroundEqualsInParameterDefault
  • Rubocop auto-correct Style/ExtraSpacing
  • Rubocop auto-correct Style/SpaceAfterComma
  • Rubocop auto-correct Style/SpaceAroundOperators
  • Rubocop auto-correct Style/AndOr

v0.9.1

  • Ongoing work

v0.1.0

  • Initial release of chef_cfn

Collaborator Number Metric
            

2.0.3 failed this metric

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

Foodcritic Metric
            

2.0.3 failed this metric

FC038: Invalid resource action: /tmp/3fbdbe766390df6978f76306/chef_cfn/recipes/mounts.rb:26
Run with Foodcritic Version 8.0.0 with tags metadata,correctness ~FC031 ~FC045 and failure tags any