cap-ec2 0.0.10 → 0.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Cap-EC2 changelog
2
2
 
3
+ ## 0.0.11
4
+
5
+ * Allow instances to have multiple projects deployed to them. [@rsslldnphy](https://github.com/rsslldnphy)
6
+ * Fix the way instance tag matching works; the previous regex was not sufficient to ensure
7
+ absolute matching of a given tag. [@rsslldnphy](https://github.com/rsslldnphy)
8
+
3
9
  ## 0.0.10
4
10
 
5
11
  * Allow configurable setting of the EC2 contact point [@christianblunden](https://github.com/christianblunden)
data/README.md CHANGED
@@ -167,6 +167,13 @@ role would apply to `server-3`.
167
167
 
168
168
  In the "staging" stage, all roles would apply *only* to `server-4`.
169
169
 
170
+ ### Servers belonging to multiple projects
171
+
172
+ If you require your servers to have multiple projects deployed to them, you can simply specify
173
+ all the project names you want to the server to be part of in the 'Projects' tag, separated
174
+ by commas. For example, you could place a server in the `testapp` and `myapp` projects by
175
+ setting the 'Projects' tag to `testapp,myapp`.
176
+
170
177
  ### Servers in multiple stages
171
178
 
172
179
  If your use-case requires servers to be in multiple stages, simply specify all the stages you want
@@ -42,7 +42,7 @@ module CapEC2
42
42
  end
43
43
 
44
44
  def defined_roles
45
- Capistrano::Configuration.env.send(:servers).send(:available_roles)
45
+ Capistrano::Configuration.env.send(:servers).send(:available_roles).sort
46
46
  end
47
47
 
48
48
  def stage
@@ -61,14 +61,21 @@ module CapEC2
61
61
  servers = []
62
62
  @ec2.each do |_, ec2|
63
63
  instances = ec2.instances
64
- .filter(tag(project_tag), application)
64
+ .filter(tag(project_tag), "*#{application}*")
65
65
  .filter('instance-state-code', '16')
66
66
  servers << instances.select do |i|
67
- i.tags[roles_tag] =~ /,{0,1}#{role}(,|$)/ && i.tags[stages_tag] =~ /,{0,1}#{stage}(,|$)/
67
+ instance_has_tag?(i, roles_tag, role) &&
68
+ instance_has_tag?(i, stages_tag, stage) &&
69
+ instance_has_tag?(i, project_tag, application)
68
70
  end
69
71
  end
70
- servers.flatten
72
+ servers.flatten.sort_by {|s| s.tags["Name"]}
71
73
  end
72
74
 
75
+ private
76
+
77
+ def instance_has_tag?(instance, key, value)
78
+ instance.tags[key].split(',').map(&:strip).include?(value.to_s)
79
+ end
73
80
  end
74
81
  end
@@ -1,3 +1,3 @@
1
1
  module CapEC2
2
- VERSION = "0.0.10"
2
+ VERSION = "0.0.11"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cap-ec2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.10
4
+ version: 0.0.11
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2014-03-25 00:00:00.000000000 Z
13
+ date: 2014-03-28 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bundler
@@ -145,7 +145,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
145
145
  version: '0'
146
146
  segments:
147
147
  - 0
148
- hash: 2648474451787322254
148
+ hash: 179278271654884480
149
149
  required_rubygems_version: !ruby/object:Gem::Requirement
150
150
  none: false
151
151
  requirements:
@@ -154,7 +154,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
154
154
  version: '0'
155
155
  segments:
156
156
  - 0
157
- hash: 2648474451787322254
157
+ hash: 179278271654884480
158
158
  requirements: []
159
159
  rubyforge_project:
160
160
  rubygems_version: 1.8.23