<commit_before># bossimage

[![Build Status](https://travis-ci.org/cloudboss/bossimage.svg?branch=master)](https://travis-ci.org/cloudboss/bossimage)

Create a role with `ansible-galaxy` and drop a `.boss.yml` into the directory it created. Use `bi run` to create an EC2 instance and run the Ansible role on it. Modify the role and rerun as necessary until satisfied. Use `bi image` to bake it into an image. Clean up with `bi delete`.

`bossimage` is inspired by both [Packer](https://www.packer.io/) and [Test Kitchen](http://kitchen.ci/), but much simpler than either. If you use both Ansible and AWS, you may find it useful.

`bossimage` has been tested on both Linux and Windows targets in EC2.

# Installation

```
git clone https://github.com/cloudboss/bossimage.git
cd bossimage
pip install -r requirements.txt
pip install .
```

# Usage
## Quick start
After installation, the `bi` command is provided, which has four subcommands: `list`, `run`, `image`, and `delete`.

AWS region and credentials must be set.

```
export AWS_PROFILE=uhuru
export AWS_DEFAULT_REGION=us-west-1
```

#### ansible-galaxy
Create an Ansible role.

```
$ ansible-galaxy init test-role
$ cd test-role
$ cat > .boss.yml <<EOF
platforms:
  - name: amz-2015092
    instance_type: t2.micro
    source_ami: amzn-ami-hvm-2015.09.2.x86_64-gp2
EOF
```

Modify the role to add tasks, handlers, and vars as desired.

#### list
List instances available to be built that are configured in .boss.yml:
```
$ bi list
amz-2015092-default
```

#### run
Build an EC2 instance and run the Ansible role on it:
```
$ bi run amz-2015092-default
Created instance i-00000000
Instance is running
Waiting for connection to 54.xxx.xxx.xxx:22 ... ok

PLAY ***************************************************************************

TASK [setup] *******************************************************************
ok: [54.xxx.xxx.xxx]

TASK [test-role : add package httpd] *******************************************
changed: [54.xxx.xxx.xxx]

PLAY RECAP *********************************************************************
54.xxx.xxx.xxx             : ok=1    changed=1    unreachable=0    failed=0
```

More verbose output may be provided with `-v`, up to four times. This is passed through to `ansible-playbook`.

```
$ bi run amz-2015092-default -vvvv
```

#### image
Bake an image.

```
$ bi image amz-2015092-default
Created image ami-00000000
Waiting for image to be available ... ok
Image is available
```

#### delete
Clean up the EC2 instance and generated keypair.

```
$ bi delete amz-2015092-default
```

## More detail
### Authenticating with AWS
`bossimage` uses standard AWS SDK environment variables for authentication, which are described in the [boto3 documentation](http://boto3.readthedocs.org/en/latest/guide/configuration.html#configuration).
<commit_msg>Update documentation to show `version` subcommand<commit_after># bossimage

[![Build Status](https://travis-ci.org/cloudboss/bossimage.svg?branch=master)](https://travis-ci.org/cloudboss/bossimage)

Create a role with `ansible-galaxy` and drop a `.boss.yml` into the directory it created. Use `bi run` to create an EC2 instance and run the Ansible role on it. Modify the role and rerun as necessary until satisfied. Use `bi image` to bake it into an image. Clean up with `bi delete`.

`bossimage` is inspired by both [Packer](https://www.packer.io/) and [Test Kitchen](http://kitchen.ci/), but much simpler than either. If you use both Ansible and AWS, you may find it useful.

`bossimage` has been tested on both Linux and Windows targets in EC2.

# Installation

```
git clone https://github.com/cloudboss/bossimage.git
cd bossimage
pip install -r requirements.txt
pip install .
```

# Usage
## Quick start
After installation, the `bi` command is provided, which has five subcommands: `list`, `run`, `image`, `delete`, and `version`.

AWS region and credentials must be set.

```
export AWS_PROFILE=uhuru
export AWS_DEFAULT_REGION=us-west-1
```

#### ansible-galaxy
Create an Ansible role.

```
$ ansible-galaxy init test-role
$ cd test-role
$ cat > .boss.yml <<EOF
platforms:
  - name: amz-2015092
    instance_type: t2.micro
    source_ami: amzn-ami-hvm-2015.09.2.x86_64-gp2
EOF
```

Modify the role to add tasks, handlers, and vars as desired.

#### list
List instances available to be built that are configured in .boss.yml:
```
$ bi list
amz-2015092-default
```

#### run
Build an EC2 instance and run the Ansible role on it:
```
$ bi run amz-2015092-default
Created instance i-00000000
Instance is running
Waiting for connection to 54.xxx.xxx.xxx:22 ... ok

PLAY ***************************************************************************

TASK [setup] *******************************************************************
ok: [54.xxx.xxx.xxx]

TASK [test-role : add package httpd] *******************************************
changed: [54.xxx.xxx.xxx]

PLAY RECAP *********************************************************************
54.xxx.xxx.xxx             : ok=1    changed=1    unreachable=0    failed=0
```

More verbose output may be provided with `-v`, up to four times. This is passed through to `ansible-playbook`.

```
$ bi run amz-2015092-default -vvvv
```

#### image
Bake an image.

```
$ bi image amz-2015092-default
Created image ami-00000000
Waiting for image to be available ... ok
Image is available
```

#### delete
Clean up the EC2 instance and generated keypair.

```
$ bi delete amz-2015092-default
```

#### version
Show version.

```
$ bi version
0.1.5
```

## More detail
### Authenticating with AWS
`bossimage` uses standard AWS SDK environment variables for authentication, which are described in the [boto3 documentation](http://boto3.readthedocs.org/en/latest/guide/configuration.html#configuration).

{'fraction_non_alphanumeric': 0.1962584444829378, 'fraction_numerical': 0.03239217044864022, 'mean_word_length': 4.447169811320754, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 8, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 4, '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': '33107', 'n_tokens_mistral': 1921, 'n_tokens_neox': 1728, 'n_words': 620}