<commit_before>Using AWS CodeDeploy to Orchestrate chef-solo
=============================================

[Chef](http://www.getchef.com/chef/) is a great tool for automating infrastructure management, but
sometimes running and maintaining a central Chef server – and ensuring that it's highly available –
can be cost-prohibitive. So you turn to chef-solo, where you are fully responsible for orchestrating
the distribution of cookbooks and running chef-solo. Up until now, you've used a set of custom
scripts (perhaps built on top of tools like Capistrano) to do that orchestration. Here, we'll show
you how AWS CodeDeploy can do all of the heavy lifting for you with almost no custom scripting.

For this post, we'll start with an instance that already has the CodeDeploy agent installed. If you
haven't already – or cleaned up afterwards – please complete *Step 1: Set Up a New Amazon EC2 Instance*
in the [AWS CodeDeploy Getting Started Guide](http://docs.aws.amazon.com/codedeploy/latest/userguide/how-to-set-up-new-instance.html).


Prepare the bundle
------------------

Next, we prepare the bundle, or source content, that will contain our Chef cookbooks and
configuration. Here, we use a simple "hello world" cookbook, but you're free to substitute your own.
The full source for this example bundle is also available 
[here](https://github.com/awslabs/aws-codedeploy-samples/tree/master/conf-mgmt/chef/solo).

First, create directories for our application and deploy hooks. The base of these will be the root
of our CodeDeploy revision:

```bash
mkdir -p chef-solo-example/deploy_hooks
cd chef-solo-example
```

Then create a simple AppSpec as `./appspec.yml`:

```yml
version: 0.0
os: linux
files:
  - source: chef/
    destination: /etc/chef/codedeploy
  - source: target/hello.war
    destination: /var/lib/tomcat6/webapps
hooks:
  BeforeInstall:
    - location: deploy_hooks/install-chef.sh
      timeout: 1800
      runas: root
  ApplicationStart:
    - location: deploy_hooks/chef-solo.sh
      runas: root
  ValidateService:
    - location: deploy_hooks/verify_service.sh
      runas: root
```<commit_msg>Added note about creating target/hello.war file<commit_after>Using AWS CodeDeploy to Orchestrate chef-solo
=============================================

[Chef](http://www.getchef.com/chef/) is a great tool for automating infrastructure management, but
sometimes running and maintaining a central Chef server – and ensuring that it's highly available –
can be cost-prohibitive. So you turn to chef-solo, where you are fully responsible for orchestrating
the distribution of cookbooks and running chef-solo. Up until now, you've used a set of custom
scripts (perhaps built on top of tools like Capistrano) to do that orchestration. Here, we'll show
you how AWS CodeDeploy can do all of the heavy lifting for you with almost no custom scripting.

For this post, we'll start with an instance that already has the CodeDeploy agent installed. If you
haven't already – or cleaned up afterwards – please complete *Step 1: Set Up a New Amazon EC2 Instance*
in the [AWS CodeDeploy Getting Started Guide](http://docs.aws.amazon.com/codedeploy/latest/userguide/how-to-set-up-new-instance.html).


Prepare the bundle
------------------

Next, we prepare the bundle, or source content, that will contain our Chef cookbooks and
configuration. Here, we use a simple "hello world" cookbook, but you're free to substitute your own.
The full source for this example bundle is also available 
[here](https://github.com/awslabs/aws-codedeploy-samples/tree/master/conf-mgmt/chef/solo).

Note:  You will have to use the Apache Maven command, "mvn package" to create the target/hello.war file.

First, create directories for our application and deploy hooks. The base of these will be the root
of our CodeDeploy revision:

```bash
mkdir -p chef-solo-example/deploy_hooks
cd chef-solo-example
```

Then create a simple AppSpec as `./appspec.yml`:

```yml
version: 0.0
os: linux
files:
  - source: chef/
    destination: /etc/chef/codedeploy
  - source: target/hello.war
    destination: /var/lib/tomcat6/webapps
hooks:
  BeforeInstall:
    - location: deploy_hooks/install-chef.sh
      timeout: 1800
      runas: root
  ApplicationStart:
    - location: deploy_hooks/chef-solo.sh
      runas: root
  ValidateService:
    - location: deploy_hooks/verify_service.sh
      runas: root
```
{'fraction_non_alphanumeric': 0.104242700729927, 'fraction_numerical': 0.004105839416058394, 'mean_word_length': 4.017162471395881, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4306126', 'n_tokens_mistral': 1295, 'n_tokens_neox': 1242, 'n_words': 524}