Skip to content
This repository has been archived by the owner on Jun 28, 2019. It is now read-only.

Allow instance_name env var to filter instances #56

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .ruby-version

This file was deleted.

5 changes: 4 additions & 1 deletion lib/cap-ec2/ec2-handler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,10 @@ def get_servers_for_role(role)
(fetch(:ec2_filter_by_status_ok?) ? instance_status_ok?(i) : true)
end
end
servers.flatten.sort_by {|s| s.tags["Name"] || ''}
servers.flatten.sort_by {|s| s.tags["Name"] || ''}.
select{|i| !ENV['instance_ip'] || (ENV['instance_ip'] == i.private_ip_address)}.
select{|i| !ENV['instance_name'] || (ENV['instance_name'] == i.tags['Name'])}.
select{|i| !ENV['role_name'] || i.tags['Roles'].split(/ *, */).include?(ENV['role_name'])}
end

def get_server(instance_id)
Expand Down
2 changes: 1 addition & 1 deletion lib/cap-ec2/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module CapEC2
VERSION = '1.0.0'
VERSION = '1.0.1'
end