NOTE: This project is no longer being maintained.
This cookbook provides tools which aid in the integration of Chef and AWS, specifically with CloudFormation.
- This cookbook will shortly be undergoing a refactor and cleanup
- chef_handler
- python
- ohai
The recipes included within default.rb
my be selectively enabled by toggling
the appropriate feature flags.
Attribute | Description | Default |
node['cfn']['recipes']['awslogs'] |
Install the cloudwatch logs daemon named awslogs | false |
node['cfn']['recipes']['cloudinit'] |
Configure a stripped down cloud-init to speed up cloud instance startup time | false |
node['cfn']['recipes']['coudwatch'] |
Install a cloudwatch event handler to report chef runs back to cloudwatch events. | true |
node['cfn']['recipes']['handler'] |
**Deprecated** Install a cfn-init chef handler which will report chef-run success to cloudformatin. | true |
node['cfn']['recipes']['mounts'] |
Format and mount volumes based on metadata provided in cloudformation | true |
node['cfn']['recipes']['ohai'] |
Install an ohai plugin to fetch instance, stack and metadata from ec2. | true |
node['cfn']['recipes']['shutdown'] |
**Deprecated** Install a service which will delete the chef client and node on shutdown | true |
node['cfn']['recipes']['tools'] |
Install the cfn-init and cfn-signal tools | true |
Attribute | Description | Default |
node['cfn']['vpc'] |
Informaiton related to the VPC | {} |
node['cfn']['tags'] |
Hash of the EC2 instance tags | {} |
node['cfn']['stack'] |
Hash of Cloudformation stack parameters | {} |
node['cfn']['properties'] |
Hash of arbitrary metadata provided in cloudformation | {} |
Installs dependencies and includes additional recipes based on feature flags.
Install and configure the cloudwatch logs service
Configure cloud-init in a more stripped down ec2-specific way. This recipe is mostly of use when packaging AMIs with Packer.
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.
(optional) Provides a basic knife.rb
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.
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "Stmt1434370036000",
"Effect": "Allow",
"Action": [
"cloudformation:DescribeStackResource",
"ec2:DescribeInstances"
],
"Resource": [
"*"
]
}
]
}
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.
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "Stmt1434370036000",
"Effect": "Allow",
"Action": [
"cloudformation:SignalResource",
],
"Resource": [
"*"
]
}
]
}
{
"AutoScailingGroup": {
"CreationPolicy": {
"ResourceSignal": {
"Count": 1,
"Timeout": "PT10M"
}
},
"UpdatePolicy": {
"AutoScalingRollingUpdate": {
"WaitOnResourceSignals": "true"
}
}
}
}
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.
{
"AutoScailingGroup": {
"Metadata": {
"Mounts": {
"xvdb3": {
"mount_point": "/var/log",
"mount_options": "",
"filesystem": ""
}
}
}
}
}
Installs cloudformation cfn-init tools such as :
- cfn-init
- cfn-hup: Periodic polling of cloudformation resource metadata to determine when triggered actions should run.
Installs a service which will delete the node when the instance shuts down.
Provides an interface to trigger cloudformation signals from within recipes. This is designed to be used with cloudformation WaitConditions.
- signal: Default action
- url: Url of the resource or WaitHandler to signal
- unique_id: Unique id of the notification
- data: Defaults to
""
. - success: Defaults to
true
. - reason: Defaults to
"Chef triggered signal from resource"
. - once: Defaults to
true
.
Fetches instance attributes from Cloudformation:DescribeResource as well as EC2:DescribeInstances.
Author:: Jonathan Serafini ([email protected])
Copyright:: 2015, Jonathan Serafini
License:: Apache 2.0