vagrant-aws 0.3.0 → 0.4.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4875beff54192a4db1f2764ba37769f408a16c7c
4
- data.tar.gz: 8ccf174be6eb9fdc3994021f9ae6e85ce8d0a34c
3
+ metadata.gz: 3803f0158a41d9318f946ad121e223c1253bbb7e
4
+ data.tar.gz: 5b6bb91685fd27f06ea79c5a12ab6d35af62fdb1
5
5
  SHA512:
6
- metadata.gz: 00cc521c0d0cc6d04c3c13502c232b008fe06998de2847cd29c36db89611c4415e001f300cc99bd9bbac0bbf9d8af03fa13e8e410863e275200c998a14826c91
7
- data.tar.gz: 87d486bf65db0820f1d74cf9b1ac0108336a97ff3166d15b1fb156fce80d98eb7473597305fc91f9ad993de2b09d2bc8f7f56a4054ca79f406714f145c0b1ebf
6
+ metadata.gz: 9c44a7050a142a5c25a185d7589d8a391309a070eefabc53a1e609d78cfbd15edf510a1362268d762aac21af6d529ad95d33bfa43a23d4a9217b60ce92c23db1
7
+ data.tar.gz: cc06535af0698ac157ccf043e27561aa4e196807b5c392abd46eaddf72df887431b6171edf3b01ea8e024069478807d01eec6a6a715e4c691c90f23e5d84da4c
data/.gitignore CHANGED
@@ -1,6 +1,9 @@
1
1
  # OS-specific
2
2
  .DS_Store
3
3
 
4
+ # editors
5
+ *.swp
6
+
4
7
  # Bundler/Rubygems
5
8
  *.gem
6
9
  .bundle
data/CHANGELOG.md CHANGED
@@ -1,3 +1,13 @@
1
+ # 0.4.0 (October 11, 2013)
2
+
3
+ * Handle EIP allocation error (GH #134)
4
+ * Implement halt and reload (GH #31)
5
+ * rsync ignores Vagrantfile
6
+ * warn if none of the security groups allows incoming SSH
7
+ * bump fog.io to 0.15.0
8
+ * Fix rsync on windows (GH #77)
9
+ * Add `ssh_host_attribute` config (GH #143)
10
+
1
11
  # 0.3.0 (September 2, 2013)
2
12
 
3
13
  * Parallelize multi-machine up on Vagrant 1.2+
data/README.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Vagrant AWS Provider
2
2
 
3
+ <span class="badges">
4
+ [![Gem Version](https://badge.fury.io/rb/vagrant-aws.png)][gem]
5
+ [![Dependency Status](https://gemnasium.com/mitchellh/vagrant-aws.png)][gemnasium]
6
+ </span>
7
+
8
+ [gem]: https://rubygems.org/gems/vagrant-aws
9
+ [gemnasium]: https://gemnasium.com/mitchellh/vagrant-aws
10
+
3
11
  This is a [Vagrant](http://www.vagrantup.com) 1.2+ plugin that adds an [AWS](http://aws.amazon.com)
4
12
  provider to Vagrant, allowing Vagrant to control and provision machines in
5
13
  EC2 and VPC.
@@ -8,12 +8,34 @@ module VagrantPlugins
8
8
  # Include the built-in modules so we can use them as top-level things.
9
9
  include Vagrant::Action::Builtin
10
10
 
11
+ # This action is called to halt the remote machine.
12
+ def self.action_halt
13
+ Vagrant::Action::Builder.new.tap do |b|
14
+ b.use ConfigValidate
15
+ b.use Call, IsCreated do |env, b2|
16
+ if !env[:result]
17
+ b2.use MessageNotCreated
18
+ next
19
+ end
20
+
21
+ b2.use ConnectAWS
22
+ b2.use StopInstance
23
+ end
24
+ end
25
+ end
26
+
11
27
  # This action is called to terminate the remote machine.
12
28
  def self.action_destroy
13
29
  Vagrant::Action::Builder.new.tap do |b|
14
30
  b.use Call, DestroyConfirm do |env, b2|
15
31
  if env[:result]
16
32
  b2.use ConfigValidate
33
+ b.use Call, IsCreated do |env2, b3|
34
+ if !env2[:result]
35
+ b3.use MessageNotCreated
36
+ next
37
+ end
38
+ end
17
39
  b2.use ConnectAWS
18
40
  b2.use TerminateInstance
19
41
  else
@@ -90,22 +112,56 @@ module VagrantPlugins
90
112
  end
91
113
  end
92
114
 
115
+ def self.action_prepare_boot
116
+ Vagrant::Action::Builder.new.tap do |b|
117
+ b.use Provision
118
+ b.use SyncFolders
119
+ b.use WarnNetworks
120
+ end
121
+ end
122
+
93
123
  # This action is called to bring the box up from nothing.
94
124
  def self.action_up
95
125
  Vagrant::Action::Builder.new.tap do |b|
96
126
  b.use HandleBoxUrl
127
+ b.use ConfigValidate
128
+ b.use ConnectAWS
129
+ b.use Call, IsCreated do |env1, b1|
130
+ if env1[:result]
131
+ b1.use Call, IsStopped do |env2, b2|
132
+ if env2[:result]
133
+ b2.use action_prepare_boot
134
+ b2.use StartInstance # restart this instance
135
+ else
136
+ b2.use MessageAlreadyCreated # TODO write a better message
137
+ end
138
+ end
139
+ else
140
+ b1.use action_prepare_boot
141
+ b1.use RunInstance # launch a new instance
142
+ end
143
+ end
144
+ end
145
+ end
146
+
147
+ def self.action_reload
148
+ Vagrant::Action::Builder.new.tap do |b|
97
149
  b.use ConfigValidate
98
150
  b.use ConnectAWS
99
151
  b.use Call, IsCreated do |env, b2|
100
- if env[:result]
101
- b2.use MessageAlreadyCreated
152
+ if !env[:result]
153
+ b2.use MessageNotCreated
102
154
  next
103
155
  end
104
156
 
105
- b2.use TimedProvision
106
- b2.use SyncFolders
107
- b2.use WarnNetworks
108
- b2.use RunInstance
157
+ b2.use action_halt
158
+ b2.use Call, WaitForState, :stopped, 120 do |env2, b3|
159
+ if env2[:result]
160
+ b3.use action_up
161
+ else
162
+ # TODO we couldn't reach :stopped, what now?
163
+ end
164
+ end
109
165
  end
110
166
  end
111
167
  end
@@ -114,16 +170,20 @@ module VagrantPlugins
114
170
  action_root = Pathname.new(File.expand_path("../action", __FILE__))
115
171
  autoload :ConnectAWS, action_root.join("connect_aws")
116
172
  autoload :IsCreated, action_root.join("is_created")
173
+ autoload :IsStopped, action_root.join("is_stopped")
117
174
  autoload :MessageAlreadyCreated, action_root.join("message_already_created")
118
175
  autoload :MessageNotCreated, action_root.join("message_not_created")
119
176
  autoload :MessageWillNotDestroy, action_root.join("message_will_not_destroy")
120
177
  autoload :ReadSSHInfo, action_root.join("read_ssh_info")
121
178
  autoload :ReadState, action_root.join("read_state")
122
179
  autoload :RunInstance, action_root.join("run_instance")
180
+ autoload :StartInstance, action_root.join("start_instance")
181
+ autoload :StopInstance, action_root.join("stop_instance")
123
182
  autoload :SyncFolders, action_root.join("sync_folders")
124
- autoload :TimedProvision, action_root.join("timed_provision")
125
- autoload :WarnNetworks, action_root.join("warn_networks")
126
183
  autoload :TerminateInstance, action_root.join("terminate_instance")
184
+ autoload :TimedProvision, action_root.join("timed_provision") # some plugins now expect this action to exist
185
+ autoload :WaitForState, action_root.join("wait_for_state")
186
+ autoload :WarnNetworks, action_root.join("warn_networks")
127
187
  end
128
188
  end
129
189
  end
@@ -18,12 +18,12 @@ module VagrantPlugins
18
18
  region = env[:machine].provider_config.region
19
19
 
20
20
  # Get the configs
21
- region_config = env[:machine].provider_config.get_region_config(region)
21
+ region_config = env[:machine].provider_config.get_region_config(region)
22
22
 
23
23
  # Build the fog config
24
24
  fog_config = {
25
- :provider => :aws,
26
- :region => region
25
+ :provider => :aws,
26
+ :region => region
27
27
  }
28
28
  if region_config.use_iam_profile
29
29
  fog_config[:use_iam_profile] = true
@@ -0,0 +1,18 @@
1
+ module VagrantPlugins
2
+ module AWS
3
+ module Action
4
+ # This can be used with "Call" built-in to check if the machine
5
+ # is stopped and branch in the middleware.
6
+ class IsStopped
7
+ def initialize(app, env)
8
+ @app = app
9
+ end
10
+
11
+ def call(env)
12
+ env[:result] = env[:machine].state.id == :stopped
13
+ @app.call(env)
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -7,7 +7,7 @@ module VagrantPlugins
7
7
  end
8
8
 
9
9
  def call(env)
10
- env[:ui].info(I18n.t("vagrant_aws.already_created"))
10
+ env[:ui].info(I18n.t("vagrant_aws.already_status", :status => "created"))
11
11
  @app.call(env)
12
12
  end
13
13
  end
@@ -29,11 +29,23 @@ module VagrantPlugins
29
29
  return nil
30
30
  end
31
31
 
32
- # Read the DNS info
33
- return {
34
- :host => server.public_ip_address || server.dns_name || server.private_ip_address,
35
- :port => 22
36
- }
32
+ # read attribute override
33
+ ssh_host_attribute = machine.provider_config.
34
+ get_region_config(machine.provider_config.region).ssh_host_attribute
35
+ # default host attributes to try. NOTE: Order matters!
36
+ ssh_attrs = [:public_ip_address, :dns_name, :private_ip_address]
37
+ ssh_attrs = (Array(ssh_host_attribute) + ssh_attrs).uniq if ssh_host_attribute
38
+ # try each attribute, get out on first value
39
+ host_value = nil
40
+ while !host_value and attr_name = ssh_attrs.shift
41
+ begin
42
+ host_value = server.send(attr_name)
43
+ rescue NoMethodError
44
+ @logger.info("SSH host attribute not found #{attr_name}")
45
+ end
46
+ end
47
+
48
+ return { :host => host_value, :port => 22 }
37
49
  end
38
50
  end
39
51
  end
@@ -69,25 +69,27 @@ module VagrantPlugins
69
69
  env[:ui].info(" -- Block Device Mapping: #{block_device_mapping}") if block_device_mapping
70
70
  env[:ui].info(" -- Terminate On Shutdown: #{terminate_on_shutdown}")
71
71
 
72
+ options = {
73
+ :availability_zone => availability_zone,
74
+ :flavor_id => instance_type,
75
+ :image_id => ami,
76
+ :key_name => keypair,
77
+ :private_ip_address => private_ip_address,
78
+ :subnet_id => subnet_id,
79
+ :iam_instance_profile_arn => iam_instance_profile_arn,
80
+ :iam_instance_profile_name => iam_instance_profile_name,
81
+ :tags => tags,
82
+ :user_data => user_data,
83
+ :block_device_mapping => block_device_mapping,
84
+ :instance_initiated_shutdown_behavior => terminate_on_shutdown == true ? "terminate" : nil
85
+ }
86
+ if !security_groups.empty?
87
+ security_group_key = options[:subnet_id].nil? ? :groups : :security_group_ids
88
+ options[security_group_key] = security_groups
89
+ end
90
+
72
91
  begin
73
- options = {
74
- :availability_zone => availability_zone,
75
- :flavor_id => instance_type,
76
- :image_id => ami,
77
- :key_name => keypair,
78
- :private_ip_address => private_ip_address,
79
- :subnet_id => subnet_id,
80
- :iam_instance_profile_arn => iam_instance_profile_arn,
81
- :iam_instance_profile_name => iam_instance_profile_name,
82
- :tags => tags,
83
- :user_data => user_data,
84
- :block_device_mapping => block_device_mapping,
85
- :instance_initiated_shutdown_behavior => terminate_on_shutdown == true ? "terminate" : nil
86
- }
87
- if !security_groups.empty?
88
- security_group_key = options[:subnet_id].nil? ? :groups : :security_group_ids
89
- options[security_group_key] = security_groups
90
- end
92
+ env[:ui].warn(I18n.t("vagrant_aws.warn_ssh_access")) unless allows_ssh_port?(env, security_groups, subnet_id)
91
93
 
92
94
  server = env[:aws_compute].servers.create(options)
93
95
  rescue Fog::Compute::AWS::NotFound => e
@@ -174,35 +176,53 @@ module VagrantPlugins
174
176
  end
175
177
  end
176
178
 
179
+ def allows_ssh_port?(env, test_sec_groups, is_vpc)
180
+ port = 22 # TODO get ssh_info port
181
+ test_sec_groups = [ "default" ] if test_sec_groups.empty? # AWS default security group
182
+ # filter groups by name or group_id (vpc)
183
+ groups = test_sec_groups.map do |tsg|
184
+ env[:aws_compute].security_groups.all.select { |sg| tsg == (is_vpc ? sg.group_id : sg.name) }
185
+ end.flatten
186
+ # filter TCP rules
187
+ rules = groups.map { |sg| sg.ip_permissions.select { |r| r["ipProtocol"] == "tcp" } }.flatten
188
+ # test if any range includes port
189
+ !rules.select { |r| (r["fromPort"]..r["toPort"]).include?(port) }.empty?
190
+ end
191
+
177
192
  def do_elastic_ip(env, domain, server)
193
+ begin
178
194
  allocation = env[:aws_compute].allocate_address(domain)
179
- if allocation.body['publicIp'].nil?
180
- @logger.debug("Could not allocate Elastic IP.")
181
- return nil
182
- end
183
- @logger.debug("Public IP #{allocation.body['publicIp']}")
184
-
185
- # Associate the address and save the metadata to a hash
186
- if domain == 'vpc'
187
- # VPC requires an allocation ID to assign an IP
188
- association = env[:aws_compute].associate_address(server.id, nil, nil, allocation.body['allocationId'])
189
- h = { :allocation_id => allocation.body['allocationId'], :association_id => association.body['associationId'], :public_ip => allocation.body['publicIp'] }
190
- else
191
- # Standard EC2 instances only need the allocated IP address
192
- association = env[:aws_compute].associate_address(server.id, allocation.body['publicIp'])
193
- h = { :public_ip => allocation.body['publicIp'] }
194
- end
195
+ rescue
196
+ @logger.debug("Could not allocate Elastic IP.")
197
+ terminate(env)
198
+ raise Errors::FogError,
199
+ :message => "Could not allocate Elastic IP."
200
+ end
201
+ @logger.debug("Public IP #{allocation.body['publicIp']}")
202
+
203
+ # Associate the address and save the metadata to a hash
204
+ if domain == 'vpc'
205
+ # VPC requires an allocation ID to assign an IP
206
+ association = env[:aws_compute].associate_address(server.id, nil, nil, allocation.body['allocationId'])
207
+ h = { :allocation_id => allocation.body['allocationId'], :association_id => association.body['associationId'], :public_ip => allocation.body['publicIp'] }
208
+ else
209
+ # Standard EC2 instances only need the allocated IP address
210
+ association = env[:aws_compute].associate_address(server.id, allocation.body['publicIp'])
211
+ h = { :public_ip => allocation.body['publicIp'] }
212
+ end
195
213
 
196
- if !association.body['return']
197
- @logger.debug("Could not associate Elastic IP.")
198
- return nil
199
- end
214
+ unless association.body['return']
215
+ @logger.debug("Could not associate Elastic IP.")
216
+ terminate(env)
217
+ raise Errors::FogError,
218
+ :message => "Could not allocate Elastic IP."
219
+ end
200
220
 
201
- # Save this IP to the data dir so it can be released when the instance is destroyed
202
- ip_file = env[:machine].data_dir.join('elastic_ip')
203
- ip_file.open('w+') do |f|
204
- f.write(h.to_json)
205
- end
221
+ # Save this IP to the data dir so it can be released when the instance is destroyed
222
+ ip_file = env[:machine].data_dir.join('elastic_ip')
223
+ ip_file.open('w+') do |f|
224
+ f.write(h.to_json)
225
+ end
206
226
  end
207
227
 
208
228
  def terminate(env)
@@ -0,0 +1,81 @@
1
+ require "log4r"
2
+
3
+ require 'vagrant/util/retryable'
4
+
5
+ require 'vagrant-aws/util/timer'
6
+
7
+ module VagrantPlugins
8
+ module AWS
9
+ module Action
10
+ # This starts a stopped instance.
11
+ class StartInstance
12
+ include Vagrant::Util::Retryable
13
+
14
+ def initialize(app, env)
15
+ @app = app
16
+ @logger = Log4r::Logger.new("vagrant_aws::action::start_instance")
17
+ end
18
+
19
+ def call(env)
20
+ # Initialize metrics if they haven't been
21
+ env[:metrics] ||= {}
22
+
23
+ server = env[:aws_compute].servers.get(env[:machine].id)
24
+
25
+ env[:ui].info(I18n.t("vagrant_aws.starting"))
26
+
27
+ begin
28
+ server.start
29
+
30
+ region = env[:machine].provider_config.region
31
+ region_config = env[:machine].provider_config.get_region_config(region)
32
+
33
+ # Wait for the instance to be ready first
34
+ env[:metrics]["instance_ready_time"] = Util::Timer.time do
35
+ tries = region_config.instance_ready_timeout / 2
36
+
37
+ env[:ui].info(I18n.t("vagrant_aws.waiting_for_ready"))
38
+ begin
39
+ retryable(:on => Fog::Errors::TimeoutError, :tries => tries) do
40
+ # If we're interrupted don't worry about waiting
41
+ next if env[:interrupted]
42
+
43
+ # Wait for the server to be ready
44
+ server.wait_for(2) { ready? }
45
+ end
46
+ rescue Fog::Errors::TimeoutError
47
+ # Notify the user
48
+ raise Errors::InstanceReadyTimeout,
49
+ timeout: region_config.instance_ready_timeout
50
+ end
51
+ end
52
+ rescue Fog::Compute::AWS::Error => e
53
+ raise Errors::FogError, :message => e.message
54
+ end
55
+
56
+ @logger.info("Time to instance ready: #{env[:metrics]["instance_ready_time"]}")
57
+
58
+ if !env[:interrupted]
59
+ env[:metrics]["instance_ssh_time"] = Util::Timer.time do
60
+ # Wait for SSH to be ready.
61
+ env[:ui].info(I18n.t("vagrant_aws.waiting_for_ssh"))
62
+ while true
63
+ # If we're interrupted then just back out
64
+ break if env[:interrupted]
65
+ break if env[:machine].communicate.ready?
66
+ sleep 2
67
+ end
68
+ end
69
+
70
+ @logger.info("Time for SSH ready: #{env[:metrics]["instance_ssh_time"]}")
71
+
72
+ # Ready and booted!
73
+ env[:ui].info(I18n.t("vagrant_aws.ready"))
74
+ end
75
+
76
+ @app.call(env)
77
+ end
78
+ end
79
+ end
80
+ end
81
+ end
@@ -0,0 +1,28 @@
1
+ require "log4r"
2
+
3
+ module VagrantPlugins
4
+ module AWS
5
+ module Action
6
+ # This stops the running instance.
7
+ class StopInstance
8
+ def initialize(app, env)
9
+ @app = app
10
+ @logger = Log4r::Logger.new("vagrant_aws::action::stop_instance")
11
+ end
12
+
13
+ def call(env)
14
+ server = env[:aws_compute].servers.get(env[:machine].id)
15
+
16
+ if env[:machine].state.id == :stopped
17
+ env[:ui].info(I18n.t("vagrant_aws.already_status", :status => env[:machine].state.id))
18
+ else
19
+ env[:ui].info(I18n.t("vagrant_aws.stopping"))
20
+ server.stop(!!env[:force_halt])
21
+ end
22
+
23
+ @app.call(env)
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -4,6 +4,8 @@ require "vagrant/util/subprocess"
4
4
 
5
5
  require "vagrant/util/scoped_hash_override"
6
6
 
7
+ require "vagrant/util/which"
8
+
7
9
  module VagrantPlugins
8
10
  module AWS
9
11
  module Action
@@ -28,6 +30,11 @@ module VagrantPlugins
28
30
  # Ignore disabled shared folders
29
31
  next if data[:disabled]
30
32
 
33
+ unless Vagrant::Util::Which.which('rsync')
34
+ env[:ui].warn(I18n.t('vagrant_aws.rsync_not_found_warning'))
35
+ break
36
+ end
37
+
31
38
  hostpath = File.expand_path(data[:hostpath], env[:root_path])
32
39
  guestpath = data[:guestpath]
33
40
 
@@ -35,6 +42,11 @@ module VagrantPlugins
35
42
  # avoid creating an additional directory with rsync
36
43
  hostpath = "#{hostpath}/" if hostpath !~ /\/$/
37
44
 
45
+ # on windows rsync.exe requires cygdrive-style paths
46
+ if Vagrant::Util::Platform.windows?
47
+ hostpath = hostpath.gsub(/^(\w):/) { "/cygdrive/#{$1}" }
48
+ end
49
+
38
50
  env[:ui].info(I18n.t("vagrant_aws.rsync_folder",
39
51
  :hostpath => hostpath,
40
52
  :guestpath => guestpath))
@@ -58,11 +70,17 @@ module VagrantPlugins
58
70
  # Rsync over to the guest path using the SSH info
59
71
  command = [
60
72
  "rsync", "--verbose", "--archive", "-z",
61
- "--exclude", ".vagrant/",
73
+ "--exclude", ".vagrant/", "--exclude", "Vagrantfile",
62
74
  "-e", "ssh -p #{ssh_info[:port]} -o StrictHostKeyChecking=no -i '#{ssh_info[:private_key_path]}'",
63
75
  hostpath,
64
76
  "#{ssh_info[:username]}@#{ssh_info[:host]}:#{guestpath}"]
65
77
 
78
+ # we need to fix permissions when using rsync.exe on windows, see
79
+ # http://stackoverflow.com/questions/5798807/rsync-permission-denied-created-directories-have-no-permissions
80
+ if Vagrant::Util::Platform.windows?
81
+ command.insert(1, "--chmod", "ugo=rwX")
82
+ end
83
+
66
84
  r = Vagrant::Util::Subprocess.execute(*command)
67
85
  if r.exit_code != 0
68
86
  raise Errors::RsyncError,
@@ -18,12 +18,12 @@ module VagrantPlugins
18
18
  env[:ui].info(I18n.t("vagrant_aws.terminating"))
19
19
  server.destroy
20
20
  env[:machine].id = nil
21
-
21
+
22
22
  # Release the elastic IP
23
23
  ip_file = env[:machine].data_dir.join('elastic_ip')
24
24
  if ip_file.file?
25
25
  release_address(env,ip_file.read)
26
- ip_file.delete
26
+ ip_file.delete
27
27
  end
28
28
 
29
29
  @app.call(env)
@@ -0,0 +1,41 @@
1
+ require "log4r"
2
+ require "timeout"
3
+
4
+ module VagrantPlugins
5
+ module AWS
6
+ module Action
7
+ # This action will wait for a machine to reach a specific state or quit by timeout
8
+ class WaitForState
9
+ # env[:result] will be false in case of timeout.
10
+ # @param [Symbol] state Target machine state.
11
+ # @param [Number] timeout Timeout in seconds.
12
+ def initialize(app, env, state, timeout)
13
+ @app = app
14
+ @logger = Log4r::Logger.new("vagrant_aws::action::wait_for_state")
15
+ @state = state
16
+ @timeout = timeout
17
+ end
18
+
19
+ def call(env)
20
+ env[:result] = true
21
+ if env[:machine].state.id == @state
22
+ @logger.info(I18n.t("vagrant_aws.already_status", :status => @state))
23
+ else
24
+ @logger.info("Waiting for machine to reach state #{@state}")
25
+ begin
26
+ Timeout.timeout(@timeout) do
27
+ until env[:machine].state.id == @state
28
+ sleep 2
29
+ end
30
+ end
31
+ rescue Timeout::Error
32
+ env[:result] = false # couldn't reach state in time
33
+ end
34
+ end
35
+
36
+ @app.call(env)
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
@@ -113,6 +113,16 @@ module VagrantPlugins
113
113
  # @return [bool]
114
114
  attr_accessor :terminate_on_shutdown
115
115
 
116
+ # Specifies which address to connect to with ssh
117
+ # Must be one of:
118
+ # - :public_ip_address
119
+ # - :dns_name
120
+ # - :private_ip_address
121
+ # This attribute also accepts an array of symbols
122
+ #
123
+ # @return [Symbol]
124
+ attr_accessor :ssh_host_attribute
125
+
116
126
  def initialize(region_specific=false)
117
127
  @access_key_id = UNSET_VALUE
118
128
  @ami = UNSET_VALUE
@@ -135,6 +145,7 @@ module VagrantPlugins
135
145
  @iam_instance_profile_arn = UNSET_VALUE
136
146
  @iam_instance_profile_name = UNSET_VALUE
137
147
  @terminate_on_shutdown = UNSET_VALUE
148
+ @ssh_host_attribute = UNSET_VALUE
138
149
 
139
150
  # Internal state (prefix with __ so they aren't automatically
140
151
  # merged)
@@ -258,6 +269,9 @@ module VagrantPlugins
258
269
  # default false
259
270
  @terminate_on_shutdown = false if @terminate_on_shutdown == UNSET_VALUE
260
271
 
272
+ # default to nil
273
+ @ssh_host_attribute = nil if @ssh_host_attribute == UNSET_VALUE
274
+
261
275
  # Compile our region specific configurations only within
262
276
  # NON-REGION-SPECIFIC configurations.
263
277
  if !@__region_specific
@@ -1,5 +1,5 @@
1
1
  module VagrantPlugins
2
2
  module AWS
3
- VERSION = "0.3.0"
3
+ VERSION = "0.4.0"
4
4
  end
5
5
  end
data/locales/en.yml CHANGED
@@ -1,7 +1,7 @@
1
1
  en:
2
2
  vagrant_aws:
3
- already_created: |-
4
- The machine is already created.
3
+ already_status: |-
4
+ The machine is already %{status}.
5
5
  launching_instance: |-
6
6
  Launching an instance with the following settings...
7
7
  launch_no_keypair: |-
@@ -16,8 +16,15 @@ en:
16
16
  Instance is not created. Please run `vagrant up` first.
17
17
  ready: |-
18
18
  Machine is booted and ready for use!
19
+ rsync_not_found_warning: |-
20
+ Warning! Folder sync disabled because the rsync binary is missing.
21
+ Make sure rsync is installed and the binary can be found in the PATH.
19
22
  rsync_folder: |-
20
23
  Rsyncing folder: %{hostpath} => %{guestpath}
24
+ starting: |-
25
+ Starting the instance...
26
+ stopping: |-
27
+ Stopping the instance...
21
28
  terminating: |-
22
29
  Terminating the instance...
23
30
  waiting_for_ready: |-
@@ -28,6 +35,9 @@ en:
28
35
  Warning! The AWS provider doesn't support any of the Vagrant
29
36
  high-level network configurations (`config.vm.network`). They
30
37
  will be silently ignored.
38
+ warn_ssh_access: |-
39
+ Warning! Vagrant might not be able to SSH into the instance.
40
+ Please check your security groups settings.
31
41
  will_not_destroy: |-
32
42
  The instance '%{name}' will not be destroyed, since the confirmation
33
43
  was declined.
@@ -81,6 +91,22 @@ en:
81
91
  long_not_created: |-
82
92
  The EC2 instance is not created. Run `vagrant up` to create it.
83
93
 
94
+ short_stopped: |-
95
+ stopped
96
+ long_stopped: |-
97
+ The EC2 instance is stopped. Run `vagrant up` to start it.
98
+
99
+ short_stopping: |-
100
+ stopping
101
+ long_stopping: |-
102
+ The EC2 instance is stopping. Wait until is completely stopped to
103
+ run `vagrant up` and start it.
104
+
105
+ short_pending: |-
106
+ pending
107
+ long_pending: |-
108
+ The EC2 instance is pending a start (i.e. this is a transition state).
109
+
84
110
  short_running: |-
85
111
  running
86
112
  long_running: |-
@@ -34,6 +34,7 @@ describe VagrantPlugins::AWS::Config do
34
34
  its("block_device_mapping") {should == [] }
35
35
  its("elastic_ip") { should be_nil }
36
36
  its("terminate_on_shutdown") { should == false }
37
+ its("ssh_host_attribute") { should be_nil }
37
38
  end
38
39
 
39
40
  describe "overriding defaults" do
@@ -42,7 +43,7 @@ describe VagrantPlugins::AWS::Config do
42
43
  # each of these attributes to "foo" in isolation, and reads the value
43
44
  # and asserts the proper result comes back out.
44
45
  [:access_key_id, :ami, :availability_zone, :instance_ready_timeout,
45
- :instance_type, :keypair_name,
46
+ :instance_type, :keypair_name, :ssh_host_attribute,
46
47
  :region, :secret_access_key, :security_groups,
47
48
  :subnet_id, :tags, :elastic_ip, :terminate_on_shutdown,
48
49
  :iam_instance_profile_arn, :iam_instance_profile_name,
data/vagrant-aws.gemspec CHANGED
@@ -5,6 +5,7 @@ Gem::Specification.new do |s|
5
5
  s.name = "vagrant-aws"
6
6
  s.version = VagrantPlugins::AWS::VERSION
7
7
  s.platform = Gem::Platform::RUBY
8
+ s.license = "MIT"
8
9
  s.authors = "Mitchell Hashimoto"
9
10
  s.email = "mitchell@hashicorp.com"
10
11
  s.homepage = "http://www.vagrantup.com"
@@ -14,7 +15,7 @@ Gem::Specification.new do |s|
14
15
  s.required_rubygems_version = ">= 1.3.6"
15
16
  s.rubyforge_project = "vagrant-aws"
16
17
 
17
- s.add_runtime_dependency "fog", "~> 1.10.0"
18
+ s.add_runtime_dependency "fog", "~> 1.15.0"
18
19
 
19
20
  s.add_development_dependency "rake"
20
21
  s.add_development_dependency "rspec-core", "~> 2.12.2"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-aws
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mitchell Hashimoto
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-09-02 00:00:00.000000000 Z
11
+ date: 2013-10-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fog
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ~>
18
18
  - !ruby/object:Gem::Version
19
- version: 1.10.0
19
+ version: 1.15.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ~>
25
25
  - !ruby/object:Gem::Version
26
- version: 1.10.0
26
+ version: 1.15.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -86,42 +86,45 @@ executables: []
86
86
  extensions: []
87
87
  extra_rdoc_files: []
88
88
  files:
89
- - vagrant-aws.sublime-project
90
- - LICENSE
89
+ - vagrant-aws.gemspec
90
+ - Gemfile
91
+ - spec/vagrant-aws/config_spec.rb
91
92
  - dummy.box
92
- - lib/vagrant-aws/action.rb
93
+ - CHANGELOG.md
94
+ - LICENSE
95
+ - lib/vagrant-aws.rb
96
+ - lib/vagrant-aws/config.rb
93
97
  - lib/vagrant-aws/plugin.rb
98
+ - lib/vagrant-aws/errors.rb
99
+ - lib/vagrant-aws/action.rb
100
+ - lib/vagrant-aws/version.rb
101
+ - lib/vagrant-aws/provider.rb
94
102
  - lib/vagrant-aws/util/timer.rb
95
- - lib/vagrant-aws/action/run_instance.rb
96
- - lib/vagrant-aws/action/is_created.rb
97
- - lib/vagrant-aws/action/message_will_not_destroy.rb
98
- - lib/vagrant-aws/action/terminate_instance.rb
103
+ - lib/vagrant-aws/action/start_instance.rb
104
+ - lib/vagrant-aws/action/timed_provision.rb
105
+ - lib/vagrant-aws/action/message_already_created.rb
106
+ - lib/vagrant-aws/action/sync_folders.rb
107
+ - lib/vagrant-aws/action/is_stopped.rb
99
108
  - lib/vagrant-aws/action/read_ssh_info.rb
109
+ - lib/vagrant-aws/action/run_instance.rb
100
110
  - lib/vagrant-aws/action/read_state.rb
111
+ - lib/vagrant-aws/action/terminate_instance.rb
112
+ - lib/vagrant-aws/action/warn_networks.rb
101
113
  - lib/vagrant-aws/action/connect_aws.rb
102
- - lib/vagrant-aws/action/sync_folders.rb
114
+ - lib/vagrant-aws/action/wait_for_state.rb
115
+ - lib/vagrant-aws/action/is_created.rb
116
+ - lib/vagrant-aws/action/stop_instance.rb
103
117
  - lib/vagrant-aws/action/message_not_created.rb
104
- - lib/vagrant-aws/action/message_already_created.rb
105
- - lib/vagrant-aws/action/timed_provision.rb
106
- - lib/vagrant-aws/action/warn_networks.rb
107
- - lib/vagrant-aws/provider.rb
108
- - lib/vagrant-aws/config.rb
109
- - lib/vagrant-aws/errors.rb
110
- - lib/vagrant-aws/version.rb
111
- - lib/vagrant-aws.rb
112
- - Gemfile
113
- - CHANGELOG.md
114
- - spec/vagrant-aws/config_spec.rb
115
- - locales/en.yml
116
- - README.md
118
+ - lib/vagrant-aws/action/message_will_not_destroy.rb
117
119
  - Rakefile
118
120
  - example_box/metadata.json
119
121
  - example_box/README.md
120
- - vagrant-aws.gemspec
121
- - vagrant-aws.sublime-workspace
122
+ - locales/en.yml
123
+ - README.md
122
124
  - .gitignore
123
125
  homepage: http://www.vagrantup.com
124
- licenses: []
126
+ licenses:
127
+ - MIT
125
128
  metadata: {}
126
129
  post_install_message:
127
130
  rdoc_options: []
@@ -139,7 +142,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
139
142
  version: 1.3.6
140
143
  requirements: []
141
144
  rubyforge_project: vagrant-aws
142
- rubygems_version: 2.0.7
145
+ rubygems_version: 2.0.3
143
146
  signing_key:
144
147
  specification_version: 4
145
148
  summary: Enables Vagrant to manage machines in EC2 and VPC.
@@ -1,9 +0,0 @@
1
- {
2
- "folders":
3
- [
4
- {
5
- "follow_symlinks": true,
6
- "path": "/home/tralamazza/projects/vagrant-aws"
7
- }
8
- ]
9
- }
@@ -1,305 +0,0 @@
1
- {
2
- "auto_complete":
3
- {
4
- "selected_items":
5
- [
6
- ]
7
- },
8
- "buffers":
9
- [
10
- {
11
- "file": "lib/vagrant-aws/action/run_instance.rb",
12
- "settings":
13
- {
14
- "buffer_size": 8942,
15
- "line_ending": "Unix"
16
- }
17
- },
18
- {
19
- "file": "README.md",
20
- "settings":
21
- {
22
- "buffer_size": 7450,
23
- "line_ending": "Unix"
24
- }
25
- }
26
- ],
27
- "build_system": "",
28
- "command_palette":
29
- {
30
- "height": 92.0,
31
- "selected_items":
32
- [
33
- [
34
- "instal",
35
- "Package Control: Install Package"
36
- ],
37
- [
38
- "pul",
39
- "Git: Pull"
40
- ],
41
- [
42
- "pull",
43
- "Git: Pull"
44
- ],
45
- [
46
- "git pull",
47
- "Git: Pull"
48
- ],
49
- [
50
- "statu",
51
- "Git: Status"
52
- ],
53
- [
54
- "sssh",
55
- "Set Syntax: Shell Script (Bash)"
56
- ],
57
- [
58
- "ssruby",
59
- "Set Syntax: Ruby"
60
- ],
61
- [
62
- "space",
63
- "Indentation: Convert to Spaces"
64
- ],
65
- [
66
- "install",
67
- "Package Control: Install Package"
68
- ],
69
- [
70
- "upda",
71
- "Package Control: Upgrade Package"
72
- ],
73
- [
74
- "insta",
75
- "Package Control: Install Package"
76
- ]
77
- ],
78
- "width": 647.0
79
- },
80
- "console":
81
- {
82
- "height": 325.0,
83
- "history":
84
- [
85
- "import urllib.request,os; pf = 'Package Control.sublime-package'; ipp = sublime.installed_packages_path(); urllib.request.install_opener( urllib.request.build_opener( urllib.request.ProxyHandler()) ); open(os.path.join(ipp, pf), 'wb').write(urllib.request.urlopen( 'http://sublime.wbond.net/' + pf.replace(' ','%20')).read()) "
86
- ]
87
- },
88
- "distraction_free":
89
- {
90
- "menu_visible": true,
91
- "show_minimap": false,
92
- "show_open_files": false,
93
- "show_tabs": false,
94
- "side_bar_visible": false,
95
- "status_bar_visible": false
96
- },
97
- "file_history":
98
- [
99
- "/home/tralamazza/.config/sublime-text-3/Packages/GoSublime/CHANGELOG.md",
100
- "/home/tralamazza/.config/sublime-text-3/Packages/GoSublime/USAGE.md",
101
- "/home/tralamazza/.xinitrc",
102
- "/home/tralamazza/projects/vagrant-aws/Vagrantfile",
103
- "/home/tralamazza/.bash_profile",
104
- "/home/tralamazza/.Xresources",
105
- "/home/tralamazza/projects/vagrant-aws/README.md",
106
- "/home/tralamazza/.zshrc",
107
- "/home/tralamazza/.xmonad/xmonad.hs",
108
- "/home/tralamazza/projects/vagrant-aws/Gemfile",
109
- "/home/tralamazza/projects/vagrant-aws/lib/vagrant-aws/config.rb",
110
- "/home/tralamazza/.zprofile",
111
- "/home/tralamazza/projects/vagrant-aws/Rakefile",
112
- "/home/tralamazza/.xmobarrc",
113
- "/home/tralamazza/.vimrc",
114
- "/home/tralamazza/projects/vagrant-aws/CHANGELOG.md",
115
- "/home/tralamazza/projects/vagrant-aws/vagrant-aws.gemspec",
116
- "/home/tralamazza/projects/vagrant-aws/.gitignore"
117
- ],
118
- "find":
119
- {
120
- "height": 34.0
121
- },
122
- "find_in_files":
123
- {
124
- "height": 90.0,
125
- "where_history":
126
- [
127
- ""
128
- ]
129
- },
130
- "find_state":
131
- {
132
- "case_sensitive": false,
133
- "find_history":
134
- [
135
- "instance_ready_timeout",
136
- "backgroun",
137
- "back",
138
- "backgroun"
139
- ],
140
- "highlight": true,
141
- "in_selection": false,
142
- "preserve_case": false,
143
- "regex": false,
144
- "replace_history":
145
- [
146
- ],
147
- "reverse": false,
148
- "show_context": true,
149
- "use_buffer2": true,
150
- "whole_word": false,
151
- "wrap": true
152
- },
153
- "groups":
154
- [
155
- {
156
- "selected": 0,
157
- "sheets":
158
- [
159
- {
160
- "buffer": 0,
161
- "file": "lib/vagrant-aws/action/run_instance.rb",
162
- "semi_transient": false,
163
- "settings":
164
- {
165
- "buffer_size": 8942,
166
- "regions":
167
- {
168
- },
169
- "selection":
170
- [
171
- [
172
- 1633,
173
- 1633
174
- ]
175
- ],
176
- "settings":
177
- {
178
- "syntax": "Packages/Ruby/Ruby.tmLanguage",
179
- "tab_size": 2,
180
- "translate_tabs_to_spaces": true
181
- },
182
- "translation.x": 0.0,
183
- "translation.y": 0.0,
184
- "zoom_level": 1.0
185
- },
186
- "type": "text"
187
- },
188
- {
189
- "buffer": 1,
190
- "file": "README.md",
191
- "semi_transient": false,
192
- "settings":
193
- {
194
- "buffer_size": 7450,
195
- "regions":
196
- {
197
- },
198
- "selection":
199
- [
200
- [
201
- 888,
202
- 888
203
- ]
204
- ],
205
- "settings":
206
- {
207
- "syntax": "Packages/Markdown/Markdown.tmLanguage",
208
- "tab_size": 2,
209
- "translate_tabs_to_spaces": true
210
- },
211
- "translation.x": 0.0,
212
- "translation.y": 0.0,
213
- "zoom_level": 1.0
214
- },
215
- "type": "text"
216
- }
217
- ]
218
- }
219
- ],
220
- "incremental_find":
221
- {
222
- "height": 23.0
223
- },
224
- "input":
225
- {
226
- "height": 0.0
227
- },
228
- "layout":
229
- {
230
- "cells":
231
- [
232
- [
233
- 0,
234
- 0,
235
- 1,
236
- 1
237
- ]
238
- ],
239
- "cols":
240
- [
241
- 0.0,
242
- 1.0
243
- ],
244
- "rows":
245
- [
246
- 0.0,
247
- 1.0
248
- ]
249
- },
250
- "menu_visible": true,
251
- "output.GoSublime-output":
252
- {
253
- "height": 100.0
254
- },
255
- "output.MarGo-output":
256
- {
257
- "height": 100.0
258
- },
259
- "output.git":
260
- {
261
- "height": 185.0
262
- },
263
- "project": "vagrant-aws.sublime-project",
264
- "replace":
265
- {
266
- "height": 42.0
267
- },
268
- "save_all_on_build": true,
269
- "select_file":
270
- {
271
- "height": 0.0,
272
- "selected_items":
273
- [
274
- ],
275
- "width": 0.0
276
- },
277
- "select_project":
278
- {
279
- "height": 0.0,
280
- "selected_items":
281
- [
282
- ],
283
- "width": 0.0
284
- },
285
- "select_symbol":
286
- {
287
- "height": 0.0,
288
- "selected_items":
289
- [
290
- ],
291
- "width": 0.0
292
- },
293
- "settings":
294
- {
295
- },
296
- "show_minimap": false,
297
- "show_open_files": false,
298
- "show_tabs": true,
299
- "side_bar_visible": true,
300
- "side_bar_width": 172.0,
301
- "status_bar_visible": true,
302
- "template_settings":
303
- {
304
- }
305
- }