From a63015a63f8587508156468ea133c624ef9a074c Mon Sep 17 00:00:00 2001 From: Pedro Garrett Date: Mon, 3 Aug 2015 15:36:48 -0400 Subject: [PATCH 1/4] Allow instance_name env var to filter instances --- lib/cap-ec2/ec2-handler.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/cap-ec2/ec2-handler.rb b/lib/cap-ec2/ec2-handler.rb index 2d54887..73522b8 100644 --- a/lib/cap-ec2/ec2-handler.rb +++ b/lib/cap-ec2/ec2-handler.rb @@ -71,7 +71,8 @@ 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_name'] || (ENV['instance_name'] == i.tags['Name'])} end def get_server(instance_id) From 681d9f1d184c7853345c971027ca69f024b89698 Mon Sep 17 00:00:00 2001 From: pedrogarrett Date: Sun, 7 Feb 2016 14:13:39 -0500 Subject: [PATCH 2/4] Allow selection of servers via role_name env var --- lib/cap-ec2/ec2-handler.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/cap-ec2/ec2-handler.rb b/lib/cap-ec2/ec2-handler.rb index 73522b8..f5b509f 100644 --- a/lib/cap-ec2/ec2-handler.rb +++ b/lib/cap-ec2/ec2-handler.rb @@ -72,7 +72,8 @@ def get_servers_for_role(role) end end servers.flatten.sort_by {|s| s.tags["Name"] || ''}. - select{|i| !ENV['instance_name'] || (ENV['instance_name'] == i.tags['Name'])} + 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) From 70df17acb614d3bf7d9f5246f0a31f3df33bdb20 Mon Sep 17 00:00:00 2001 From: Pedro Garrett Date: Mon, 10 Sep 2018 12:13:31 -0400 Subject: [PATCH 3/4] added private ip selector --- .ruby-version | 1 - lib/cap-ec2/ec2-handler.rb | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) delete mode 100644 .ruby-version diff --git a/.ruby-version b/.ruby-version deleted file mode 100644 index ccbccc3..0000000 --- a/.ruby-version +++ /dev/null @@ -1 +0,0 @@ -2.2.0 diff --git a/lib/cap-ec2/ec2-handler.rb b/lib/cap-ec2/ec2-handler.rb index f5b509f..fd4078e 100644 --- a/lib/cap-ec2/ec2-handler.rb +++ b/lib/cap-ec2/ec2-handler.rb @@ -72,6 +72,7 @@ def get_servers_for_role(role) end end 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 From 99341e4faa6fefe8bbdf4586282c26fa1071fd48 Mon Sep 17 00:00:00 2001 From: Pedro Garrett Date: Mon, 10 Sep 2018 12:26:44 -0400 Subject: [PATCH 4/4] bump version --- lib/cap-ec2/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/cap-ec2/version.rb b/lib/cap-ec2/version.rb index f09ea84..4271969 100644 --- a/lib/cap-ec2/version.rb +++ b/lib/cap-ec2/version.rb @@ -1,3 +1,3 @@ module CapEC2 - VERSION = '1.0.0' + VERSION = '1.0.1' end