Meta

Maintainers

Open source project that allows users to test applying states to roles using AWS ECS (Docker).Great for integrating within your CI/CD environment!

Technologies used:* Python2.6/2.7* Docker* AWS ECS

## Before we begin

Setting up a CI/CD pipeline is beyond the scope of this README. There are many tools you can use.The following assumptions are made in utilizing this project: 1. You are using AWS and your region contains a(n): * VPC that houses your CI resources * Security group that is used by your CI nodes * Subnet that your CI nodes are using * Key pair you have access to * IAM key credentials with permissions including: AmazonEC2FullAccess and AmazonEC2ContainerServiceFullAccess

## Running SIT from root directory of SIT project ```bash python -m sit.launch_review_job <job_name> <build_number> <ci_node_private_ip_address> </path> ``` * Job name and build number are used to generate a naming convention for the Docker image minion. * Private IP is used by the minion to point to its salt-master, the CI node. For this to work, you’ll need to do a few things...

3. Set your configs 1. Configuration files can either be stored within the SIT repository, or anywhere else with your file system. We recommend storing the config file in /etc/sit/configs and managing via a salt state. 2. boto3 AWS credentials Time to set a profile. In this example, we are using “sit” as the profile. You may use the default profile if you like

~/.aws/configs ```python [profile sit] region=<region> ``` If you are using a profile other than default, you will have to change the default inside configs/sit.yml 3. /path/to/configs/troposphere.yml

You will need to find the following values and add them: * Security group that your CI instances are using * Subnet that your CI instances are provisioned within * key pair you have access to * Ami_id from: [AWS Marketplace](https://aws.amazon.com/marketplace/search/results/ref=dtl_navgno_search_box?page=1&searchTerms=Amazon+ECS-Optimized+Amazon+Linux+AMI)

## Initiate/Teardown SIT You will have to do the following (potentially each build, but depends on your setup) before and after running SIT: 1. Initiation Script: create an initiation script that will run inside the CI node before any SIT-like job is to be run * Edit CI Node's master configs (file_roots and pillar_roots) to point to the workspace of the salt repo. (via SED) * Start salt-master on the CI node * Start Redis service on the CI node * Copy down the roles.yml file from your salt project workspace into the sit configs directory. * Install the SIT requirements.

```python pip install -r /path/to/sit/requirements.txt ```

Once your job is done, you will want the CI node to be able to run other jobs, and even run SIT-like jobs again. This resets the work that the Initiate did. 2. Teardown script: create a teardown script that will run after SIT tool is done running * Delete all keys accepted by salt-master (CI node) * Flush Redis of data * Stop salt-master service * Stop redis * Return CI node salt-master configs (file_roots and pillar_roots) to an easy to edit target (via SED)

## Contributing to SIT * Please create a pull-request (preferably referring to an issue) with a single, meaningful commit message stating what you are accomplishing. * Add unit tests to new code * Ensure all unit tests pass and coverage has not dropped ``` python setup.py test ```