cookbook 'chef_cfn', '= 0.9.0'
chef_cfn (9) Versions 0.9.0 Follow1
Chef integration with AWS cloudformation
cookbook 'chef_cfn', '= 0.9.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 >= 0.0.0 |
Contingent cookbooks
There are no cookbooks that are contingent upon this one.
0.1.0
Initial release of chef_cfn
Foodcritic Metric
0.9.0 failed this metric
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/b4b24c1886135ad9e4793a8f/chef_cfn/attributes/ohai.rb:3
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/b4b24c1886135ad9e4793a8f/chef_cfn/attributes/tools.rb:2
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/b4b24c1886135ad9e4793a8f/chef_cfn/attributes/tools.rb:4
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/b4b24c1886135ad9e4793a8f/chef_cfn/attributes/tools.rb:5
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/b4b24c1886135ad9e4793a8f/chef_cfn/attributes/tools.rb:7
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/b4b24c1886135ad9e4793a8f/chef_cfn/providers/signal.rb:13
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/b4b24c1886135ad9e4793a8f/chef_cfn/recipes/handler.rb:8
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/b4b24c1886135ad9e4793a8f/chef_cfn/recipes/handler.rb:18
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/b4b24c1886135ad9e4793a8f/chef_cfn/recipes/handler.rb:19
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/b4b24c1886135ad9e4793a8f/chef_cfn/recipes/handler.rb:20
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/b4b24c1886135ad9e4793a8f/chef_cfn/recipes/handler.rb:21
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/b4b24c1886135ad9e4793a8f/chef_cfn/recipes/handler.rb:25
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/b4b24c1886135ad9e4793a8f/chef_cfn/recipes/mounts.rb:10
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/b4b24c1886135ad9e4793a8f/chef_cfn/recipes/mounts.rb:11
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/b4b24c1886135ad9e4793a8f/chef_cfn/recipes/mounts.rb:25
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/b4b24c1886135ad9e4793a8f/chef_cfn/recipes/mounts.rb:26
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/b4b24c1886135ad9e4793a8f/chef_cfn/recipes/mounts.rb:48
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/b4b24c1886135ad9e4793a8f/chef_cfn/recipes/shutdown.rb:12
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/b4b24c1886135ad9e4793a8f/chef_cfn/recipes/tools.rb:12
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/b4b24c1886135ad9e4793a8f/chef_cfn/recipes/tools.rb:32
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/b4b24c1886135ad9e4793a8f/chef_cfn/recipes/tools.rb:33
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/b4b24c1886135ad9e4793a8f/chef_cfn/recipes/tools.rb:34
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/b4b24c1886135ad9e4793a8f/chef_cfn/recipes/tools.rb:35
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/b4b24c1886135ad9e4793a8f/chef_cfn/recipes/tools.rb:39
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/b4b24c1886135ad9e4793a8f/chef_cfn/recipes/tools.rb:50
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/b4b24c1886135ad9e4793a8f/chef_cfn/recipes/tools.rb:51
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/b4b24c1886135ad9e4793a8f/chef_cfn/recipes/tools.rb:52
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/b4b24c1886135ad9e4793a8f/chef_cfn/recipes/tools.rb:53
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/b4b24c1886135ad9e4793a8f/chef_cfn/recipes/tools.rb:58
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/b4b24c1886135ad9e4793a8f/chef_cfn/resources/signal.rb:56
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/b4b24c1886135ad9e4793a8f/chef_cfn/resources/signal.rb:59
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/b4b24c1886135ad9e4793a8f/chef_cfn/resources/signal.rb:70
FC009: Resource attribute not recognised: /tmp/cook/b4b24c1886135ad9e4793a8f/chef_cfn/recipes/ohai.rb:13
FC023: Prefer conditional attributes: /tmp/cook/b4b24c1886135ad9e4793a8f/chef_cfn/recipes/mounts.rb:24
FC023: Prefer conditional attributes: /tmp/cook/b4b24c1886135ad9e4793a8f/chef_cfn/recipes/mounts.rb:37
FC038: Invalid resource action: /tmp/cook/b4b24c1886135ad9e4793a8f/chef_cfn/recipes/mounts.rb:28
0.9.0 failed this metric
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/b4b24c1886135ad9e4793a8f/chef_cfn/attributes/tools.rb:2
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/b4b24c1886135ad9e4793a8f/chef_cfn/attributes/tools.rb:4
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/b4b24c1886135ad9e4793a8f/chef_cfn/attributes/tools.rb:5
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/b4b24c1886135ad9e4793a8f/chef_cfn/attributes/tools.rb:7
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/b4b24c1886135ad9e4793a8f/chef_cfn/providers/signal.rb:13
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/b4b24c1886135ad9e4793a8f/chef_cfn/recipes/handler.rb:8
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/b4b24c1886135ad9e4793a8f/chef_cfn/recipes/handler.rb:18
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/b4b24c1886135ad9e4793a8f/chef_cfn/recipes/handler.rb:19
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/b4b24c1886135ad9e4793a8f/chef_cfn/recipes/handler.rb:20
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/b4b24c1886135ad9e4793a8f/chef_cfn/recipes/handler.rb:21
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/b4b24c1886135ad9e4793a8f/chef_cfn/recipes/handler.rb:25
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/b4b24c1886135ad9e4793a8f/chef_cfn/recipes/mounts.rb:10
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/b4b24c1886135ad9e4793a8f/chef_cfn/recipes/mounts.rb:11
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/b4b24c1886135ad9e4793a8f/chef_cfn/recipes/mounts.rb:25
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/b4b24c1886135ad9e4793a8f/chef_cfn/recipes/mounts.rb:26
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/b4b24c1886135ad9e4793a8f/chef_cfn/recipes/mounts.rb:48
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/b4b24c1886135ad9e4793a8f/chef_cfn/recipes/shutdown.rb:12
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/b4b24c1886135ad9e4793a8f/chef_cfn/recipes/tools.rb:12
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/b4b24c1886135ad9e4793a8f/chef_cfn/recipes/tools.rb:32
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/b4b24c1886135ad9e4793a8f/chef_cfn/recipes/tools.rb:33
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/b4b24c1886135ad9e4793a8f/chef_cfn/recipes/tools.rb:34
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/b4b24c1886135ad9e4793a8f/chef_cfn/recipes/tools.rb:35
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/b4b24c1886135ad9e4793a8f/chef_cfn/recipes/tools.rb:39
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/b4b24c1886135ad9e4793a8f/chef_cfn/recipes/tools.rb:50
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/b4b24c1886135ad9e4793a8f/chef_cfn/recipes/tools.rb:51
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/b4b24c1886135ad9e4793a8f/chef_cfn/recipes/tools.rb:52
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/b4b24c1886135ad9e4793a8f/chef_cfn/recipes/tools.rb:53
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/b4b24c1886135ad9e4793a8f/chef_cfn/recipes/tools.rb:58
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/b4b24c1886135ad9e4793a8f/chef_cfn/resources/signal.rb:56
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/b4b24c1886135ad9e4793a8f/chef_cfn/resources/signal.rb:59
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/b4b24c1886135ad9e4793a8f/chef_cfn/resources/signal.rb:70
FC009: Resource attribute not recognised: /tmp/cook/b4b24c1886135ad9e4793a8f/chef_cfn/recipes/ohai.rb:13
FC023: Prefer conditional attributes: /tmp/cook/b4b24c1886135ad9e4793a8f/chef_cfn/recipes/mounts.rb:24
FC023: Prefer conditional attributes: /tmp/cook/b4b24c1886135ad9e4793a8f/chef_cfn/recipes/mounts.rb:37
FC038: Invalid resource action: /tmp/cook/b4b24c1886135ad9e4793a8f/chef_cfn/recipes/mounts.rb:28