<commit_before># InstanceSelector

Remove the configuration pain when deploying to cloud servers.

When deploying applications with Capistrano, you need to itemize the servers for each role.  When you only have a server or two, this is easily managed. However, if you have many servers provisioned via a CM tool, keeping track of them becomes difficult.

By tagging servers with some meta data when they are created, you can filter
the server list to only the ones pertaining to the current deploy.

## Status

Currently, only EC2 instances are supported.

## Installation

Add this line to your application's Gemfile:

    gem 'instance_selector'

And then execute:

    $ bundle

Or install it yourself as:

    $ gem install instance_selector

## Usage

By default, only running instances will be included in the results.  Overriding this restriction is in the TODO section.

### Standalone

    require 'instance_selector/connection'
    conn = InstanceSelector::Connection.factory(:aws)
    instances = connection.instances(:tags => {"Environment" => "staging", "Role" => "web"})

### With Capistrano

    require 'instance_selector/capistrano'
    instance_selector :app, :aws, :tags => {"Environment" => "staging", "Role" => "web"}

### Filters

http://docs.aws.amazon.com/AWSEC2/latest/APIReference/ApiReference-query-DescribeInstances.html

## TODO

- Tests
- filters (e.g., :filters => {"instance-state-name" => nil to clear the running instance filter})
- AWS
  - ELB support
    - attach/detach<commit_msg>instructions for generic config in deploy.rb instead of stage files<commit_after># InstanceSelector

Remove the configuration pain when deploying to cloud servers.

When deploying applications with Capistrano, you need to itemize the servers for each role.  When you only have a server or two, this is easily managed. However, if you have many servers provisioned via a CM tool, keeping track of them becomes difficult.

By tagging servers with some meta data when they are created, you can filter
the server list to only the ones pertaining to the current deploy.

## Status

Currently, only EC2 instances are supported.

## Installation

Add this line to your application's Gemfile:

    gem 'instance_selector'

And then execute:

    $ bundle

Or install it yourself as:

    $ gem install instance_selector

## Usage

By default, only running instances will be included in the results.  Overriding this restriction is in the TODO section.

### Standalone

    require 'instance_selector/connection'
    conn = InstanceSelector::Connection.factory(:aws)
    instances = connection.instances(:tags => {"Environment" => "staging", "Role" => "web"})

### With Capistrano

    require 'instance_selector/capistrano'
    instance_selector :app, :aws, :tags => {"Environment" => "staging", "Role" => "web"}

### Generic with Capistrano

    # Centralized instance selector config
    on :after, only: stages do
      @logger.log 1, "Selecting instances from the cloud"
      instance_selector :app, :aws, tags: {"Environment" => stage, "Role" => "social-web"}
      instance_selector :sidekiq, :aws, tags: {"Environment" => stage, "Role" => "social-sidekiq"}
      # NOTE: Only one cron host is supported! Tag appropriately.
      instance_selector :cron, :aws, tags: {"Environment" => stage, "CronRole" => "social-web"}
    end

### Filters

http://docs.aws.amazon.com/AWSEC2/latest/APIReference/ApiReference-query-DescribeInstances.html

## TODO

- Tests
- filters (e.g., :filters => {"instance-state-name" => nil to clear the running instance filter})
- AWS
  - ELB support
    - attach/detach
{'fraction_non_alphanumeric': 0.09579180509413067, 'fraction_numerical': 0.0013842746400885937, 'mean_word_length': 4.146723646723647, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '3559597', 'n_tokens_mistral': 988, 'n_tokens_neox': 965, 'n_words': 403}