cap-ec2 0.0.14 → 0.0.15

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Cap-EC2 changelog
2
2
 
3
+ ## 0.0.15
4
+
5
+ * Add `ec2_filter_by_status_ok?` to filter out instances that aren't returning `OK`
6
+ for their EC2 status checks. [@tomconroy](https://github.com/tomconroy)
7
+
3
8
  ## 0.0.14
4
9
 
5
10
  * Fix issue when tag was present in EC2 but had no value. [@tomconroy](https://github.com/tomconroy)
data/README.md CHANGED
@@ -52,6 +52,8 @@ set :ec2_access_key_id, nil
52
52
  set :ec2_secret_access_key, nil
53
53
  set :ec2_region, %w{}
54
54
  set :ec2_contact_point, nil
55
+
56
+ set :ec2_filter_by_status_ok?, nil
55
57
  ```
56
58
 
57
59
  #### Order of inheritance
@@ -84,6 +86,11 @@ If running on EC2 the IAM instance profile credentials will be used if credentia
84
86
  If this is defined, Cap-EC2 will look for a tag with this name to determine which instances belong to
85
87
  a given role. The tag name defaults to "Roles".
86
88
 
89
+ * filter_by_status_ok?
90
+
91
+ If this is set to `true`, then Cap-EC2 will not return instances which do not have both EC2 status
92
+ checks as `OK`. By default this is set to `nil`, so Cap-EC2 can return you instances which don't have
93
+ `OK` status checks. Be warned that just-launched instances take a while to start returning `OK`.
87
94
 
88
95
  ### YAML Configuration
89
96
 
@@ -67,7 +67,8 @@ module CapEC2
67
67
  servers << instances.select do |i|
68
68
  instance_has_tag?(i, roles_tag, role) &&
69
69
  instance_has_tag?(i, stages_tag, stage) &&
70
- instance_has_tag?(i, project_tag, application)
70
+ instance_has_tag?(i, project_tag, application) &&
71
+ (fetch(:ec2_filter_by_status_ok?) ? instance_status_ok?(i) : true)
71
72
  end
72
73
  end
73
74
  servers.flatten.sort_by {|s| s.tags["Name"]}
@@ -78,5 +79,15 @@ module CapEC2
78
79
  def instance_has_tag?(instance, key, value)
79
80
  (instance.tags[key] || '').split(',').map(&:strip).include?(value.to_s)
80
81
  end
82
+
83
+ def instance_status_ok?(instance)
84
+ @ec2.any? do |_, ec2|
85
+ response = ec2.client.describe_instance_status(
86
+ instance_ids: [instance.id],
87
+ filters: [{ name: 'instance-status.status', values: %w(ok) }]
88
+ )
89
+ response.data.has_key?(:instance_status_set) && response.data[:instance_status_set].any?
90
+ end
91
+ end
81
92
  end
82
93
  end
data/lib/cap-ec2/utils.rb CHANGED
@@ -40,6 +40,8 @@ module CapEC2
40
40
  set :ec2_access_key_id, config['access_key_id'] if config['access_key_id']
41
41
  set :ec2_secret_access_key, config['secret_access_key'] if config['secret_access_key']
42
42
  set :ec2_region, config['regions'] if config['regions']
43
+
44
+ set :ec2_filter_by_status_ok?, config['filter_by_status_ok?'] if config['filter_by_status_ok?']
43
45
  end
44
46
  end
45
47
  end
@@ -1,3 +1,3 @@
1
1
  module CapEC2
2
- VERSION = '0.0.14'
2
+ VERSION = '0.0.15'
3
3
  end
metadata CHANGED
@@ -1,7 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cap-ec2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.14
4
+ version: 0.0.15
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - Andy Sykes
@@ -9,90 +10,102 @@ authors:
9
10
  autorequire:
10
11
  bindir: bin
11
12
  cert_chain: []
12
- date: 2014-06-09 00:00:00.000000000 Z
13
+ date: 2014-07-07 00:00:00.000000000 Z
13
14
  dependencies:
14
15
  - !ruby/object:Gem::Dependency
15
16
  name: bundler
16
17
  requirement: !ruby/object:Gem::Requirement
18
+ none: false
17
19
  requirements:
18
- - - "~>"
20
+ - - ~>
19
21
  - !ruby/object:Gem::Version
20
22
  version: '1.3'
21
23
  type: :development
22
24
  prerelease: false
23
25
  version_requirements: !ruby/object:Gem::Requirement
26
+ none: false
24
27
  requirements:
25
- - - "~>"
28
+ - - ~>
26
29
  - !ruby/object:Gem::Version
27
30
  version: '1.3'
28
31
  - !ruby/object:Gem::Dependency
29
32
  name: rake
30
33
  requirement: !ruby/object:Gem::Requirement
34
+ none: false
31
35
  requirements:
32
- - - ">="
36
+ - - ! '>='
33
37
  - !ruby/object:Gem::Version
34
38
  version: '0'
35
39
  type: :development
36
40
  prerelease: false
37
41
  version_requirements: !ruby/object:Gem::Requirement
42
+ none: false
38
43
  requirements:
39
- - - ">="
44
+ - - ! '>='
40
45
  - !ruby/object:Gem::Version
41
46
  version: '0'
42
47
  - !ruby/object:Gem::Dependency
43
48
  name: aws-sdk
44
49
  requirement: !ruby/object:Gem::Requirement
50
+ none: false
45
51
  requirements:
46
- - - ">="
52
+ - - ! '>='
47
53
  - !ruby/object:Gem::Version
48
54
  version: '0'
49
55
  type: :runtime
50
56
  prerelease: false
51
57
  version_requirements: !ruby/object:Gem::Requirement
58
+ none: false
52
59
  requirements:
53
- - - ">="
60
+ - - ! '>='
54
61
  - !ruby/object:Gem::Version
55
62
  version: '0'
56
63
  - !ruby/object:Gem::Dependency
57
64
  name: capistrano
58
65
  requirement: !ruby/object:Gem::Requirement
66
+ none: false
59
67
  requirements:
60
- - - ">="
68
+ - - ! '>='
61
69
  - !ruby/object:Gem::Version
62
70
  version: '3.0'
63
71
  type: :runtime
64
72
  prerelease: false
65
73
  version_requirements: !ruby/object:Gem::Requirement
74
+ none: false
66
75
  requirements:
67
- - - ">="
76
+ - - ! '>='
68
77
  - !ruby/object:Gem::Version
69
78
  version: '3.0'
70
79
  - !ruby/object:Gem::Dependency
71
80
  name: terminal-table
72
81
  requirement: !ruby/object:Gem::Requirement
82
+ none: false
73
83
  requirements:
74
- - - ">="
84
+ - - ! '>='
75
85
  - !ruby/object:Gem::Version
76
86
  version: '0'
77
87
  type: :runtime
78
88
  prerelease: false
79
89
  version_requirements: !ruby/object:Gem::Requirement
90
+ none: false
80
91
  requirements:
81
- - - ">="
92
+ - - ! '>='
82
93
  - !ruby/object:Gem::Version
83
94
  version: '0'
84
95
  - !ruby/object:Gem::Dependency
85
96
  name: colored
86
97
  requirement: !ruby/object:Gem::Requirement
98
+ none: false
87
99
  requirements:
88
- - - ">="
100
+ - - ! '>='
89
101
  - !ruby/object:Gem::Version
90
102
  version: '0'
91
103
  type: :runtime
92
104
  prerelease: false
93
105
  version_requirements: !ruby/object:Gem::Requirement
106
+ none: false
94
107
  requirements:
95
- - - ">="
108
+ - - ! '>='
96
109
  - !ruby/object:Gem::Version
97
110
  version: '0'
98
111
  description: Cap-EC2 is used to generate Capistrano namespaces and tasks from Amazon
@@ -104,7 +117,7 @@ executables: []
104
117
  extensions: []
105
118
  extra_rdoc_files: []
106
119
  files:
107
- - ".gitignore"
120
+ - .gitignore
108
121
  - CHANGELOG.md
109
122
  - Gemfile
110
123
  - LICENSE.txt
@@ -120,26 +133,33 @@ files:
120
133
  homepage: https://github.com/forward3d/cap-ec2
121
134
  licenses:
122
135
  - MIT
123
- metadata: {}
124
136
  post_install_message:
125
137
  rdoc_options: []
126
138
  require_paths:
127
139
  - lib
128
140
  required_ruby_version: !ruby/object:Gem::Requirement
141
+ none: false
129
142
  requirements:
130
- - - ">="
143
+ - - ! '>='
131
144
  - !ruby/object:Gem::Version
132
145
  version: '0'
146
+ segments:
147
+ - 0
148
+ hash: -187489000278530207
133
149
  required_rubygems_version: !ruby/object:Gem::Requirement
150
+ none: false
134
151
  requirements:
135
- - - ">="
152
+ - - ! '>='
136
153
  - !ruby/object:Gem::Version
137
154
  version: '0'
155
+ segments:
156
+ - 0
157
+ hash: -187489000278530207
138
158
  requirements: []
139
159
  rubyforge_project:
140
- rubygems_version: 2.2.2
160
+ rubygems_version: 1.8.23
141
161
  signing_key:
142
- specification_version: 4
162
+ specification_version: 3
143
163
  summary: Cap-EC2 is used to generate Capistrano namespaces and tasks from Amazon EC2
144
164
  instance tags, dynamically building the list of servers to be deployed to.
145
165
  test_files: []
checksums.yaml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- SHA1:
3
- metadata.gz: 5b1a3bd6ad23645ae15eabc5f7f1bf641a921240
4
- data.tar.gz: 2458e03a181dcafbe535e1885a54c04715a14a95
5
- SHA512:
6
- metadata.gz: 6817287d6bcbc0a2e7faec15638e2b09d867040dd963f652157182f77e7eef1c1f078e007a2e95eb1e0fd276d4ad75214e73b661e47a85328d492397241ef931
7
- data.tar.gz: 6dd0b888bb606536668971f9d715576e42d2eeaacb3a4f18188a39a8292961d6f9b0b36d7e56bd5c3bccf02307dad711d78743c970f388820197baac2e206aef