cookbook 'chef_cfn', '~> 2.1.1'
chef_cfn (9) Versions 2.1.1 Follow1
Chef integration with AWS cloudformation
cookbook 'chef_cfn', '~> 2.1.1', :supermarket
knife supermarket install chef_cfn
knife supermarket download chef_cfn
chef_cfn Cookbook
This cookbook provides tools which aid in the integration of Chef and AWS,
specifically with CloudFormation.
Todo
- This cookbook will shortly be undergoing a refactor and cleanup
Requirements
Cookbooks:
- chef_handler
- python
- ohai
Attributes
Feature Flags
The recipes included within default.rb
my be selectively enabled by toggling
the appropriate feature flags.
<table>
<tr>
<td>Attribute</td>
<td>Description</td>
<td>Default</td>
</tr>
<tr>
<td><code>node['cfn']['recipes']['awslogs']</code></td>
<td>Install the cloudwatch logs daemon named awslogs</td>
<td><code>false</code></td>
</tr>
<tr>
<td><code>node['cfn']['recipes']['cloudinit']</code></td>
<td>Configure a stripped down cloud-init to speed up cloud instance startup
time</td>
<td><code>false</code></td>
</tr>
<tr>
<td><code>node['cfn']['recipes']['coudwatch']</code></td>
<td>Install a cloudwatch event handler to report chef runs back to
cloudwatch events.</td>
<td><code>true</code></td>
</tr>
<tr>
<td><code>node['cfn']['recipes']['handler']</code></td>
<td>Deprecated Install a cfn-init chef handler which will report
chef-run success to cloudformatin.
<td><code>true</code></td>
</tr>
<tr>
<td><code>node['cfn']['recipes']['mounts']</code></td>
<td>Format and mount volumes based on metadata provided in cloudformation</td>
<td><code>true</code></td>
</tr>
<tr>
<td><code>node['cfn']['recipes']['ohai']</code></td>
<td>Install an ohai plugin to fetch instance, stack and metadata from ec2.
</td>
<td><code>true</code></td>
</tr>
<tr>
<td><code>node['cfn']['recipes']['shutdown']</code></td>
<td>Deprecated Install a service which will delete the chef client and
node on shutdown</td>
<td><code>true</code></td>
</tr>
<tr>
<td><code>node['cfn']['recipes']['tools']</code></td>
<td>Install the cfn-init and cfn-signal tools</td>
<td><code>true</code></td>
</tr>
</table>
Ohai Attributes
<table>
<tr>
<td>Attribute</td>
<td>Description</td>
<td>Default</td>
</tr>
<tr>
<td><code>node['cfn']['vpc']</code></td>
<td>Informaiton related to the VPC</td>
<td><code>{}</code></td>
</tr>
<tr>
<td><code>node['cfn']['tags']</code></td>
<td>Hash of the EC2 instance tags</td>
<td><code>{}</code></td>
</tr>
<tr>
<td><code>node['cfn']['stack']</code></td>
<td>Hash of Cloudformation stack parameters</td>
<td><code>{}</code></td>
</tr>
<tr>
<td><code>node['cfn']['properties']</code></td>
<td>Hash of arbitrary metadata provided in cloudformation</td>
<td><code>{}</code></td>
</tr>
</table>
Recipes
chef_cfn::default
Installs dependencies and includes additional recipes based on feature flags.
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.1.1
- Add missing cloudwatch configuration attributes
v2.1.0
- Add cloudwatch events report handler
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.1.1 failed this metric
Failure: Cookbook has 0 collaborators. A cookbook must have at least 2 collaborators to pass this metric.
Contributing File Metric
2.1.1 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
2.1.1 failed this metric
FC066: Ensure chef_version is set in metadata: chef_cfn/metadata.rb:1
FC067: Ensure at least one platform supported in metadata: chef_cfn/metadata.rb:1
FC069: Ensure standardized license defined in metadata: chef_cfn/metadata.rb:1
FC072: Metadata should not contain "attribute" keyword: chef_cfn/metadata.rb:1
FC121: Cookbook depends on cookbook made obsolete by Chef 14: chef_cfn/metadata.rb:1
Run with Foodcritic Version 16.3.0 with tags metadata,correctness ~FC031 ~FC045 and failure tags any
No Binaries Metric
2.1.1 passed this metric
Testing File Metric
2.1.1 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
2.1.1 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
2.1.1 failed this metric
2.1.1 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
2.1.1 failed this metric
FC066: Ensure chef_version is set in metadata: chef_cfn/metadata.rb:1
FC067: Ensure at least one platform supported in metadata: chef_cfn/metadata.rb:1
FC069: Ensure standardized license defined in metadata: chef_cfn/metadata.rb:1
FC072: Metadata should not contain "attribute" keyword: chef_cfn/metadata.rb:1
FC121: Cookbook depends on cookbook made obsolete by Chef 14: chef_cfn/metadata.rb:1
Run with Foodcritic Version 16.3.0 with tags metadata,correctness ~FC031 ~FC045 and failure tags any
No Binaries Metric
2.1.1 passed this metric
Testing File Metric
2.1.1 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
2.1.1 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
2.1.1 failed this metric
FC067: Ensure at least one platform supported in metadata: chef_cfn/metadata.rb:1
FC069: Ensure standardized license defined in metadata: chef_cfn/metadata.rb:1
FC072: Metadata should not contain "attribute" keyword: chef_cfn/metadata.rb:1
FC121: Cookbook depends on cookbook made obsolete by Chef 14: chef_cfn/metadata.rb:1
Run with Foodcritic Version 16.3.0 with tags metadata,correctness ~FC031 ~FC045 and failure tags any
2.1.1 passed this metric
Testing File Metric
2.1.1 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
2.1.1 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
2.1.1 failed this metric
2.1.1 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