cookbook 'chef_cfn', '= 1.0.0'
chef_cfn (9) Versions 1.0.0 Follow1
Chef integration with AWS cloudformation
cookbook 'chef_cfn', '= 1.0.0', :supermarket
knife supermarket install chef_cfn
knife supermarket download chef_cfn
Chef_cfn Cookbook
Provide tools to aid in the integration of Chef with AWS Cloudformation.
Requirements
Cookbooks:
- chef_handler
- 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']['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::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.
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 |
Contingent cookbooks
There are no cookbooks that are contingent upon this one.
chef_cfn changelog
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
1.0.0 failed this metric
Failure: Cookbook has 0 collaborators. A cookbook must have at least 2 collaborators to pass this metric.
Foodcritic Metric
1.0.0 failed this metric
FC001: Use strings in preference to symbols to access node attributes: /tmp/4c3f48ba4ec8f85cbbd08f39/chef_cfn/attributes/ohai.rb:3
FC001: Use strings in preference to symbols to access node attributes: /tmp/4c3f48ba4ec8f85cbbd08f39/chef_cfn/attributes/tools.rb:2
FC001: Use strings in preference to symbols to access node attributes: /tmp/4c3f48ba4ec8f85cbbd08f39/chef_cfn/attributes/tools.rb:4
FC001: Use strings in preference to symbols to access node attributes: /tmp/4c3f48ba4ec8f85cbbd08f39/chef_cfn/attributes/tools.rb:5
FC001: Use strings in preference to symbols to access node attributes: /tmp/4c3f48ba4ec8f85cbbd08f39/chef_cfn/attributes/tools.rb:7
FC001: Use strings in preference to symbols to access node attributes: /tmp/4c3f48ba4ec8f85cbbd08f39/chef_cfn/providers/signal.rb:13
FC001: Use strings in preference to symbols to access node attributes: /tmp/4c3f48ba4ec8f85cbbd08f39/chef_cfn/recipes/handler.rb:8
FC001: Use strings in preference to symbols to access node attributes: /tmp/4c3f48ba4ec8f85cbbd08f39/chef_cfn/recipes/handler.rb:18
FC001: Use strings in preference to symbols to access node attributes: /tmp/4c3f48ba4ec8f85cbbd08f39/chef_cfn/recipes/handler.rb:19
FC001: Use strings in preference to symbols to access node attributes: /tmp/4c3f48ba4ec8f85cbbd08f39/chef_cfn/recipes/handler.rb:20
FC001: Use strings in preference to symbols to access node attributes: /tmp/4c3f48ba4ec8f85cbbd08f39/chef_cfn/recipes/handler.rb:21
FC001: Use strings in preference to symbols to access node attributes: /tmp/4c3f48ba4ec8f85cbbd08f39/chef_cfn/recipes/handler.rb:25
FC001: Use strings in preference to symbols to access node attributes: /tmp/4c3f48ba4ec8f85cbbd08f39/chef_cfn/recipes/mounts.rb:10
FC001: Use strings in preference to symbols to access node attributes: /tmp/4c3f48ba4ec8f85cbbd08f39/chef_cfn/recipes/mounts.rb:11
FC001: Use strings in preference to symbols to access node attributes: /tmp/4c3f48ba4ec8f85cbbd08f39/chef_cfn/recipes/mounts.rb:25
FC001: Use strings in preference to symbols to access node attributes: /tmp/4c3f48ba4ec8f85cbbd08f39/chef_cfn/recipes/mounts.rb:26
FC001: Use strings in preference to symbols to access node attributes: /tmp/4c3f48ba4ec8f85cbbd08f39/chef_cfn/recipes/mounts.rb:48
FC001: Use strings in preference to symbols to access node attributes: /tmp/4c3f48ba4ec8f85cbbd08f39/chef_cfn/recipes/shutdown.rb:12
FC001: Use strings in preference to symbols to access node attributes: /tmp/4c3f48ba4ec8f85cbbd08f39/chef_cfn/recipes/tools.rb:16
FC001: Use strings in preference to symbols to access node attributes: /tmp/4c3f48ba4ec8f85cbbd08f39/chef_cfn/recipes/tools.rb:36
FC001: Use strings in preference to symbols to access node attributes: /tmp/4c3f48ba4ec8f85cbbd08f39/chef_cfn/recipes/tools.rb:37
FC001: Use strings in preference to symbols to access node attributes: /tmp/4c3f48ba4ec8f85cbbd08f39/chef_cfn/recipes/tools.rb:38
FC001: Use strings in preference to symbols to access node attributes: /tmp/4c3f48ba4ec8f85cbbd08f39/chef_cfn/recipes/tools.rb:39
FC001: Use strings in preference to symbols to access node attributes: /tmp/4c3f48ba4ec8f85cbbd08f39/chef_cfn/recipes/tools.rb:43
FC001: Use strings in preference to symbols to access node attributes: /tmp/4c3f48ba4ec8f85cbbd08f39/chef_cfn/recipes/tools.rb:54
FC001: Use strings in preference to symbols to access node attributes: /tmp/4c3f48ba4ec8f85cbbd08f39/chef_cfn/recipes/tools.rb:55
FC001: Use strings in preference to symbols to access node attributes: /tmp/4c3f48ba4ec8f85cbbd08f39/chef_cfn/recipes/tools.rb:56
FC001: Use strings in preference to symbols to access node attributes: /tmp/4c3f48ba4ec8f85cbbd08f39/chef_cfn/recipes/tools.rb:57
FC001: Use strings in preference to symbols to access node attributes: /tmp/4c3f48ba4ec8f85cbbd08f39/chef_cfn/recipes/tools.rb:62
FC001: Use strings in preference to symbols to access node attributes: /tmp/4c3f48ba4ec8f85cbbd08f39/chef_cfn/resources/signal.rb:56
FC001: Use strings in preference to symbols to access node attributes: /tmp/4c3f48ba4ec8f85cbbd08f39/chef_cfn/resources/signal.rb:59
FC001: Use strings in preference to symbols to access node attributes: /tmp/4c3f48ba4ec8f85cbbd08f39/chef_cfn/resources/signal.rb:70
FC023: Prefer conditional attributes: /tmp/4c3f48ba4ec8f85cbbd08f39/chef_cfn/recipes/mounts.rb:24
FC023: Prefer conditional attributes: /tmp/4c3f48ba4ec8f85cbbd08f39/chef_cfn/recipes/mounts.rb:37
FC038: Invalid resource action: /tmp/4c3f48ba4ec8f85cbbd08f39/chef_cfn/recipes/mounts.rb:28
1.0.0 failed this metric
1.0.0 failed this metric
FC001: Use strings in preference to symbols to access node attributes: /tmp/4c3f48ba4ec8f85cbbd08f39/chef_cfn/attributes/ohai.rb:3
FC001: Use strings in preference to symbols to access node attributes: /tmp/4c3f48ba4ec8f85cbbd08f39/chef_cfn/attributes/tools.rb:2
FC001: Use strings in preference to symbols to access node attributes: /tmp/4c3f48ba4ec8f85cbbd08f39/chef_cfn/attributes/tools.rb:4
FC001: Use strings in preference to symbols to access node attributes: /tmp/4c3f48ba4ec8f85cbbd08f39/chef_cfn/attributes/tools.rb:5
FC001: Use strings in preference to symbols to access node attributes: /tmp/4c3f48ba4ec8f85cbbd08f39/chef_cfn/attributes/tools.rb:7
FC001: Use strings in preference to symbols to access node attributes: /tmp/4c3f48ba4ec8f85cbbd08f39/chef_cfn/providers/signal.rb:13
FC001: Use strings in preference to symbols to access node attributes: /tmp/4c3f48ba4ec8f85cbbd08f39/chef_cfn/recipes/handler.rb:8
FC001: Use strings in preference to symbols to access node attributes: /tmp/4c3f48ba4ec8f85cbbd08f39/chef_cfn/recipes/handler.rb:18
FC001: Use strings in preference to symbols to access node attributes: /tmp/4c3f48ba4ec8f85cbbd08f39/chef_cfn/recipes/handler.rb:19
FC001: Use strings in preference to symbols to access node attributes: /tmp/4c3f48ba4ec8f85cbbd08f39/chef_cfn/recipes/handler.rb:20
FC001: Use strings in preference to symbols to access node attributes: /tmp/4c3f48ba4ec8f85cbbd08f39/chef_cfn/recipes/handler.rb:21
FC001: Use strings in preference to symbols to access node attributes: /tmp/4c3f48ba4ec8f85cbbd08f39/chef_cfn/recipes/handler.rb:25
FC001: Use strings in preference to symbols to access node attributes: /tmp/4c3f48ba4ec8f85cbbd08f39/chef_cfn/recipes/mounts.rb:10
FC001: Use strings in preference to symbols to access node attributes: /tmp/4c3f48ba4ec8f85cbbd08f39/chef_cfn/recipes/mounts.rb:11
FC001: Use strings in preference to symbols to access node attributes: /tmp/4c3f48ba4ec8f85cbbd08f39/chef_cfn/recipes/mounts.rb:25
FC001: Use strings in preference to symbols to access node attributes: /tmp/4c3f48ba4ec8f85cbbd08f39/chef_cfn/recipes/mounts.rb:26
FC001: Use strings in preference to symbols to access node attributes: /tmp/4c3f48ba4ec8f85cbbd08f39/chef_cfn/recipes/mounts.rb:48
FC001: Use strings in preference to symbols to access node attributes: /tmp/4c3f48ba4ec8f85cbbd08f39/chef_cfn/recipes/shutdown.rb:12
FC001: Use strings in preference to symbols to access node attributes: /tmp/4c3f48ba4ec8f85cbbd08f39/chef_cfn/recipes/tools.rb:16
FC001: Use strings in preference to symbols to access node attributes: /tmp/4c3f48ba4ec8f85cbbd08f39/chef_cfn/recipes/tools.rb:36
FC001: Use strings in preference to symbols to access node attributes: /tmp/4c3f48ba4ec8f85cbbd08f39/chef_cfn/recipes/tools.rb:37
FC001: Use strings in preference to symbols to access node attributes: /tmp/4c3f48ba4ec8f85cbbd08f39/chef_cfn/recipes/tools.rb:38
FC001: Use strings in preference to symbols to access node attributes: /tmp/4c3f48ba4ec8f85cbbd08f39/chef_cfn/recipes/tools.rb:39
FC001: Use strings in preference to symbols to access node attributes: /tmp/4c3f48ba4ec8f85cbbd08f39/chef_cfn/recipes/tools.rb:43
FC001: Use strings in preference to symbols to access node attributes: /tmp/4c3f48ba4ec8f85cbbd08f39/chef_cfn/recipes/tools.rb:54
FC001: Use strings in preference to symbols to access node attributes: /tmp/4c3f48ba4ec8f85cbbd08f39/chef_cfn/recipes/tools.rb:55
FC001: Use strings in preference to symbols to access node attributes: /tmp/4c3f48ba4ec8f85cbbd08f39/chef_cfn/recipes/tools.rb:56
FC001: Use strings in preference to symbols to access node attributes: /tmp/4c3f48ba4ec8f85cbbd08f39/chef_cfn/recipes/tools.rb:57
FC001: Use strings in preference to symbols to access node attributes: /tmp/4c3f48ba4ec8f85cbbd08f39/chef_cfn/recipes/tools.rb:62
FC001: Use strings in preference to symbols to access node attributes: /tmp/4c3f48ba4ec8f85cbbd08f39/chef_cfn/resources/signal.rb:56
FC001: Use strings in preference to symbols to access node attributes: /tmp/4c3f48ba4ec8f85cbbd08f39/chef_cfn/resources/signal.rb:59
FC001: Use strings in preference to symbols to access node attributes: /tmp/4c3f48ba4ec8f85cbbd08f39/chef_cfn/resources/signal.rb:70
FC023: Prefer conditional attributes: /tmp/4c3f48ba4ec8f85cbbd08f39/chef_cfn/recipes/mounts.rb:24
FC023: Prefer conditional attributes: /tmp/4c3f48ba4ec8f85cbbd08f39/chef_cfn/recipes/mounts.rb:37
FC038: Invalid resource action: /tmp/4c3f48ba4ec8f85cbbd08f39/chef_cfn/recipes/mounts.rb:28