vagrant-mcs 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +21 -0
  3. data/.rspec +1 -0
  4. data/CHANGELOG.md +92 -0
  5. data/Gemfile +12 -0
  6. data/LICENSE +8 -0
  7. data/README.md +292 -0
  8. data/Rakefile +21 -0
  9. data/dummy.box +0 -0
  10. data/example_box/README.md +13 -0
  11. data/example_box/mcs.box +0 -0
  12. data/example_box/metadata.json +3 -0
  13. data/lib/vagrant-mcs/action/connect_mcs.rb +51 -0
  14. data/lib/vagrant-mcs/action/elb_deregister_instance.rb +24 -0
  15. data/lib/vagrant-mcs/action/elb_register_instance.rb +24 -0
  16. data/lib/vagrant-mcs/action/is_created.rb +18 -0
  17. data/lib/vagrant-mcs/action/is_stopped.rb +18 -0
  18. data/lib/vagrant-mcs/action/message_already_created.rb +16 -0
  19. data/lib/vagrant-mcs/action/message_not_created.rb +16 -0
  20. data/lib/vagrant-mcs/action/message_will_not_destroy.rb +16 -0
  21. data/lib/vagrant-mcs/action/package_instance.rb +192 -0
  22. data/lib/vagrant-mcs/action/read_ssh_info.rb +53 -0
  23. data/lib/vagrant-mcs/action/read_state.rb +38 -0
  24. data/lib/vagrant-mcs/action/run_instance.rb +274 -0
  25. data/lib/vagrant-mcs/action/start_instance.rb +81 -0
  26. data/lib/vagrant-mcs/action/stop_instance.rb +28 -0
  27. data/lib/vagrant-mcs/action/terminate_instance.rb +51 -0
  28. data/lib/vagrant-mcs/action/timed_provision.rb +21 -0
  29. data/lib/vagrant-mcs/action/wait_for_state.rb +41 -0
  30. data/lib/vagrant-mcs/action/warn_networks.rb +19 -0
  31. data/lib/vagrant-mcs/action.rb +210 -0
  32. data/lib/vagrant-mcs/config.rb +405 -0
  33. data/lib/vagrant-mcs/errors.rb +43 -0
  34. data/lib/vagrant-mcs/plugin.rb +73 -0
  35. data/lib/vagrant-mcs/provider.rb +50 -0
  36. data/lib/vagrant-mcs/util/elb.rb +56 -0
  37. data/lib/vagrant-mcs/util/timer.rb +17 -0
  38. data/lib/vagrant-mcs/version.rb +5 -0
  39. data/lib/vagrant-mcs.rb +18 -0
  40. data/locales/en.yml +153 -0
  41. data/mcs.box +0 -0
  42. data/spec/spec_helper.rb +1 -0
  43. data/spec/vagrant-aws/config_spec.rb +225 -0
  44. data/templates/metadata.json.erb +3 -0
  45. data/templates/vagrant-aws_package_Vagrantfile.erb +5 -0
  46. data/vagrant-mcs.gemspec +60 -0
  47. metadata +172 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f2cf10bfab44aed2c21f69261f66c10e145b85e2
4
+ data.tar.gz: 3b7506c97fabaea858b3564b45d9e2816f900df2
5
+ SHA512:
6
+ metadata.gz: f02d5d6fddf74dff0401c9da16f6e2f5c82019aa063bde980706318a65ab24f0bb1de47e9506af119048d5e019904521121b4efa63ca05771fbf6b3c6f1fa1ee
7
+ data.tar.gz: ea64fdb1df45981d562fa99a053e9a69592ee074320763c59e24a6b3c182df2ad5e3c4c3fbda3947b850b1a0b013e7c7c5643658f437a02d88d9e465d2019258
data/.gitignore ADDED
@@ -0,0 +1,21 @@
1
+ # OS-specific
2
+ .DS_Store
3
+
4
+ # editors
5
+ *.swp
6
+
7
+ # Bundler/Rubygems
8
+ *.gem
9
+ .bundle
10
+ pkg/*
11
+ tags
12
+ Gemfile.lock
13
+
14
+ # Vagrant
15
+ .vagrant
16
+ Vagrantfile
17
+ !example_box/Vagrantfile
18
+
19
+ # RVM files for gemset/ruby setting
20
+ .ruby-*
21
+ .rvmrc
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --format doc --order random --color --fail-fast
data/CHANGELOG.md ADDED
@@ -0,0 +1,92 @@
1
+ # 0.6.0 (December 13, 2014)
2
+
3
+ * Support static Elastic IP addresses.
4
+ * Support for creating AMIs with the `vagrant package`
5
+
6
+ # 0.5.0 (June 22, 2014)
7
+
8
+ * Support for associating public IPs for VMs inside of VPCs (GH
9
+ [#219](https://github.com/mitchellh/vagrant-mcs/pull/219), GH
10
+ [#205](https://github.com/mitchellh/vagrant-mcs/issues/205))
11
+ * Bug-fix for per region configs with `associate_public_ip` (GH
12
+ [#237](https://github.com/mitchellh/vagrant-mcs/pull/237))
13
+ * rsyncing folders uses `--delete` flag to better emulate "real shared folders
14
+ (GH [#194](https://github.com/mitchellh/vagrant-mcs/pull/194))
15
+ * fog gem version bumped to 1.22 (GH [#253](https://github.com/mitchellh/vagrant-mcs/pull/253))
16
+ * Simple ELB support (GH [#88](https://github.com/mitchellh/vagrant-mcs/pull/88),
17
+ GH [#238](https://github.com/mitchellh/vagrant-mcs/pull/238))
18
+
19
+ # 0.4.1 (December 17, 2013)
20
+
21
+ * Update fog.io to 1.18.0
22
+ * Fix sync folder user permissions (GH #175)
23
+ * Fix vagrant < 1.3.0 provisioner compatibility (GH #173)
24
+ * Add vagrant 1.4.0 multiple SSH key support (GH #172)
25
+ * Fix EIP deallocation bug (GH #164)
26
+ * Add (per shared folder) rsync exclude flag (GH #156)
27
+
28
+ # 0.4.0 (October 11, 2013)
29
+
30
+ * Handle EIP allocation error (GH #134)
31
+ * Implement halt and reload (GH #31)
32
+ * rsync ignores Vagrantfile
33
+ * warn if none of the security groups allows incoming SSH
34
+ * bump fog.io to 1.15.0
35
+ * Fix rsync on windows (GH #77)
36
+ * Add `ssh_host_attribute` config (GH #143)
37
+
38
+ # 0.3.0 (September 2, 2013)
39
+
40
+ * Parallelize multi-machine up on Vagrant 1.2+
41
+ * Show proper configuration errors if an invalid configuration key
42
+ is used.
43
+ * Request confirmation on `vagrant destroy`, like normal VirtualBox + Vagrant.
44
+ * If user data is configured, output is shown on "vagrant up" that
45
+ it is being set.
46
+ * Add EIP support (GH #65)
47
+ * Add block device mapping support (GH #93)
48
+ * README improvements (GH #120)
49
+ * Fix missing locale message (GH #73)
50
+ * SyncFolders creates hostpath if it doesn't exist and `:create` option is set (GH #17)
51
+ * Add IAM Instance Profile support (GH #68)
52
+ * Add shutdown behavior support (GH #125,#131)
53
+
54
+ # 0.2.2 (April 18, 2013)
55
+
56
+ * Fix crashing bug with incorrect provisioner arguments.
57
+
58
+ # 0.2.1 (April 16, 2013)
59
+
60
+ * Got rid of extranneous references to old SSH settings.
61
+
62
+ # 0.2.0 (April 16, 2013)
63
+
64
+ * Add support for `vagrant ssh -c` [GH-42]
65
+ * Ability to specify a timeout for waiting for instances to become ready. [GH-44]
66
+ * Better error message if instance didn't become ready in time.
67
+ * Connection can now be done using IAM profiles. [GH-41]
68
+
69
+ # 0.1.3 (April 9, 2013)
70
+
71
+ * The `MCS_ACCESS_KEY` and `MCS_SECRET_KEY` will be used if available
72
+ and no specific keys are set in the Vagrantfile. [GH-33]
73
+ * Fix issues with SSH on VPCs, the correct IP is used. [GH-30]
74
+ * Exclude the ".vagrant" directory from rsync.
75
+ * Implement `:disabled` flag support for shared folders. [GH-29]
76
+ * `mcs.user_data` to specify user data on the instance. [GH-26]
77
+
78
+ # 0.1.2 (March 22, 2013)
79
+
80
+ * Choose the proper region when connecting to MCS. [GH-9]
81
+ * Configurable SSH port. [GH-13]
82
+ * Support other MCS-compatible API endpoints with `config.endpoint`
83
+ and `config.version`. [GH-6]
84
+ * Disable strict host key checking on rsync so known hosts aren't an issue. [GH-7]
85
+
86
+ # 0.1.1 (March 18, 2013)
87
+
88
+ * Up fog dependency for Vagrant 1.1.1
89
+
90
+ # 0.1.0 (March 14, 2013)
91
+
92
+ * Initial release.
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
4
+
5
+ group :development do
6
+ # We depend on Vagrant for development, but we don't add it as a
7
+ # gem dependency because we expect to be installed within the
8
+ # Vagrant environment itself using `vagrant plugin`.
9
+ gem "vagrant", :git => "git://github.com/mitchellh/vagrant.git"
10
+ gem 'mos_sdk'
11
+ gem 'crack', '~> 0.4.2'
12
+ end
data/LICENSE ADDED
@@ -0,0 +1,8 @@
1
+ The MIT License (MIT)
2
+ Copyright (c) 2014 Mitchell Hashimoto
3
+
4
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
5
+
6
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
7
+
8
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,292 @@
1
+ # Vagrant MCS Provider
2
+ [![Gitter](https://badges.gitter.im/Join Chat.svg)](https://gitter.im/mitchellh/vagrant-mcs?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
3
+
4
+ <span class="badges">
5
+ [![Gem Version](https://badge.fury.io/rb/vagrant-mcs.png)][gem]
6
+ [![Dependency Status](https://gemnasium.com/mitchellh/vagrant-mcs.png)][gemnasium]
7
+ </span>
8
+
9
+ [gem]: https://rubygems.org/gems/vagrant-mcs
10
+ [gemnasium]: https://gemnasium.com/mitchellh/vagrant-mcs
11
+
12
+ This is a [Vagrant](http://www.vagrantup.com) 1.2+ plugin that adds an [MCS](http://mcs.amazon.com)
13
+ provider to Vagrant, allowing Vagrant to control and provision machines in
14
+ EC2 and VPC.
15
+
16
+ **NOTE:** This plugin requires Vagrant 1.2+,
17
+
18
+ ## Features
19
+
20
+ * Boot EC2 or VPC instances.
21
+ * SSH into the instances.
22
+ * Provision the instances with any built-in Vagrant provisioner.
23
+ * Minimal synced folder support via `rsync`.
24
+ * Define region-specific configurations so Vagrant can manage machines
25
+ in multiple regions.
26
+ * Package running instances into new vagrant-mcs friendly boxes
27
+
28
+ ## Usage
29
+
30
+ Install using standard Vagrant 1.1+ plugin installation methods. After
31
+ installing, `vagrant up` and specify the `mcs` provider. An example is
32
+ shown below.
33
+
34
+ ```
35
+ $ vagrant plugin install vagrant-mcs
36
+ ...
37
+ $ vagrant up --provider=mcs
38
+ ...
39
+ ```
40
+
41
+ Of course prior to doing this, you'll need to obtain an MCS-compatible
42
+ box file for Vagrant.
43
+
44
+ ## Quick Start
45
+
46
+ After installing the plugin (instructions above), the quickest way to get
47
+ started is to actually use a dummy MCS box and specify all the details
48
+ manually within a `config.vm.provider` block. So first, add the dummy
49
+ box using any name you want:
50
+
51
+ ```
52
+ $ vagrant box add dummy https://github.com/mitchellh/vagrant-mcs/raw/master/dummy.box
53
+ ...
54
+ ```
55
+
56
+ And then make a Vagrantfile that looks like the following, filling in
57
+ your information where necessary.
58
+
59
+ ```
60
+ Vagrant.configure("2") do |config|
61
+ config.vm.box = "dummy"
62
+
63
+ config.vm.provider :mcs do |mcs, override|
64
+ mcs.access_key_id = "YOUR KEY"
65
+ mcs.secret_access_key = "YOUR SECRET KEY"
66
+ mcs.session_token = "SESSION TOKEN"
67
+ mcs.keypair_name = "KEYPAIR NAME"
68
+
69
+ mcs.ami = "ami-7747d01e"
70
+
71
+ override.ssh.username = "ubuntu"
72
+ override.ssh.private_key_path = "PATH TO YOUR PRIVATE KEY"
73
+ end
74
+ end
75
+ ```
76
+
77
+ And then run `vagrant up --provider=mcs`.
78
+
79
+ This will start an Ubuntu 12.04 instance in the us-east-1 region within
80
+ your account. And assuming your SSH information was filled in properly
81
+ within your Vagrantfile, SSH and provisioning will work as well.
82
+
83
+ Note that normally a lot of this boilerplate is encoded within the box
84
+ file, but the box file used for the quick start, the "dummy" box, has
85
+ no preconfigured defaults.
86
+
87
+ If you have issues with SSH connecting, make sure that the instances
88
+ are being launched with a security group that allows SSH access.
89
+
90
+ ## Box Format
91
+
92
+ Every provider in Vagrant must introduce a custom box format. This
93
+ provider introduces `mcs` boxes. You can view an example box in
94
+ the [example_box/ directory](https://github.com/mitchellh/vagrant-mcs/tree/master/example_box).
95
+ That directory also contains instructions on how to build a box.
96
+
97
+ The box format is basically just the required `metadata.json` file
98
+ along with a `Vagrantfile` that does default settings for the
99
+ provider-specific configuration for this provider.
100
+
101
+ ## Configuration
102
+
103
+ This provider exposes quite a few provider-specific configuration options:
104
+
105
+ * `access_key_id` - The access key for accessing MCS
106
+ * `ami` - The AMI id to boot, such as "ami-12345678"
107
+ * `availability_zone` - The availability zone within the region to launch
108
+ the instance. If nil, it will use the default set by Amazon.
109
+ * `instance_ready_timeout` - The number of seconds to wait for the instance
110
+ to become "ready" in MCS. Defaults to 120 seconds.
111
+ * `instance_package_timeout` - The number of seconds to wait for the instance
112
+ to be burnt into an AMI during packaging. Defaults to 600 seconds.
113
+ * `instance_type` - The type of instance, such as "m3.medium". The default
114
+ value of this if not specified is "m3.medium". "m1.small" has been
115
+ deprecated in "us-east-1" and "m3.medium" is the smallest instance
116
+ type to support both paravirtualization and hvm AMIs
117
+ * `keypair_name` - The name of the keypair to use to bootstrap AMIs
118
+ which support it.
119
+ * `session_token` - The session token provided by STS
120
+ * `private_ip_address` - The private IP address to assign to an instance
121
+ within a [VPC](http://mcs.amazon.com/vpc/)
122
+ * `elastic_ip` - Can be set to 'true', or to an existing Elastic IP address.
123
+ If true, allocate a new Elastic IP address to the instance. If set
124
+ to an existing Elastic IP address, assign the address to the instance.
125
+ * `region` - The region to start the instance in, such as "us-east-1"
126
+ * `secret_access_key` - The secret access key for accessing MCS
127
+ * `security_groups` - An array of security groups for the instance. If this
128
+ instance will be launched in VPC, this must be a list of security group
129
+ Name. For a nondefault VPC, you must use security group IDs instead (http://docs.mcs.amazon.com/cli/latest/reference/ec2/run-instances.html).
130
+ * `iam_instance_profile_arn` - The Amazon resource name (ARN) of the IAM Instance
131
+ Profile to associate with the instance
132
+ * `iam_instance_profile_name` - The name of the IAM Instance Profile to associate
133
+ with the instance
134
+ * `subnet_id` - The subnet to boot the instance into, for VPC.
135
+ * `associate_public_ip` - If true, will associate a public IP address to an instance in a VPC.
136
+ * `tags` - A hash of tags to set on the machine.
137
+ * `use_iam_profile` - If true, will use [IAM profiles](http://docs.mcs.amazon.com/IAM/latest/UserGuide/instance-profiles.html)
138
+ for credentials.
139
+ * `block_device_mapping` - Amazon EC2 Block Device Mapping Property
140
+ * `elb` - The ELB name to attach to the instance.
141
+
142
+ These can be set like typical provider-specific configuration:
143
+
144
+ ```ruby
145
+ Vagrant.configure("2") do |config|
146
+ # ... other stuff
147
+
148
+ config.vm.provider :mcs do |mcs|
149
+ mcs.access_key_id = "foo"
150
+ mcs.secret_access_key = "bar"
151
+ end
152
+ end
153
+ ```
154
+
155
+ In addition to the above top-level configs, you can use the `region_config`
156
+ method to specify region-specific overrides within your Vagrantfile. Note
157
+ that the top-level `region` config must always be specified to choose which
158
+ region you want to actually use, however. This looks like this:
159
+
160
+ ```ruby
161
+ Vagrant.configure("2") do |config|
162
+ # ... other stuff
163
+
164
+ config.vm.provider :mcs do |mcs|
165
+ mcs.access_key_id = "foo"
166
+ mcs.secret_access_key = "bar"
167
+ mcs.region = "us-east-1"
168
+
169
+ # Simple region config
170
+ mcs.region_config "us-east-1", :ami => "ami-12345678"
171
+
172
+ # More comprehensive region config
173
+ mcs.region_config "us-west-2" do |region|
174
+ region.ami = "ami-87654321"
175
+ region.keypair_name = "company-west"
176
+ end
177
+ end
178
+ end
179
+ ```
180
+
181
+ The region-specific configurations will override the top-level
182
+ configurations when that region is used. They otherwise inherit
183
+ the top-level configurations, as you would probably expect.
184
+
185
+ ## Networks
186
+
187
+ Networking features in the form of `config.vm.network` are not
188
+ supported with `vagrant-mcs`, currently. If any of these are
189
+ specified, Vagrant will emit a warning, but will otherwise boot
190
+ the MCS machine.
191
+
192
+ ## Synced Folders
193
+
194
+ There is minimal support for synced folders. Upon `vagrant up`,
195
+ `vagrant reload`, and `vagrant provision`, the MCS provider will use
196
+ `rsync` (if available) to uni-directionally sync the folder to
197
+ the remote machine over SSH.
198
+
199
+ See [Vagrant Synced folders: rsync](https://docs.vagrantup.com/v2/synced-folders/rsync.html)
200
+
201
+
202
+ ## Other Examples
203
+
204
+ ### Tags
205
+
206
+ To use tags, simply define a hash of key/value for the tags you want to associate to your instance, like:
207
+
208
+ ```ruby
209
+ Vagrant.configure("2") do |config|
210
+ # ... other stuff
211
+
212
+ config.vm.provider "mcs" do |mcs|
213
+ mcs.tags = {
214
+ 'Name' => 'Some Name',
215
+ 'Some Key' => 'Some Value'
216
+ }
217
+ end
218
+ end
219
+ ```
220
+
221
+ ### User data
222
+
223
+ You can specify user data for the instance being booted.
224
+
225
+ ```ruby
226
+ Vagrant.configure("2") do |config|
227
+ # ... other stuff
228
+
229
+ config.vm.provider "mcs" do |mcs|
230
+ # Option 1: a single string
231
+ mcs.user_data = "#!/bin/bash\necho 'got user data' > /tmp/user_data.log\necho"
232
+
233
+ # Option 2: use a file
234
+ mcs.user_data = File.read("user_data.txt")
235
+ end
236
+ end
237
+ ```
238
+
239
+ ### Disk size
240
+
241
+ Need more space on your instance disk? Increase the disk size.
242
+
243
+ ```ruby
244
+ Vagrant.configure("2") do |config|
245
+ # ... other stuff
246
+
247
+ config.vm.provider "mcs" do |mcs|
248
+ mcs.block_device_mapping = [{ 'DeviceName' => '/dev/sda1', 'Ebs.VolumeSize' => 50 }]
249
+ end
250
+ end
251
+ ```
252
+
253
+ ### ELB (Elastic Load Balancers)
254
+
255
+ You can automatically attach an instance to an ELB during boot and detach on destroy.
256
+
257
+ ```ruby
258
+ Vagrant.configure("2") do |config|
259
+ # ... other stuff
260
+
261
+ config.vm.provider "mcs" do |mcs|
262
+ mcs.elb = "production-web"
263
+ end
264
+ end
265
+ ```
266
+
267
+ ## Development
268
+
269
+ To work on the `vagrant-mcs` plugin, clone this repository out, and use
270
+ [Bundler](http://gembundler.com) to get the dependencies:
271
+
272
+ ```
273
+ $ bundle
274
+ ```
275
+
276
+ Once you have the dependencies, verify the unit tests pass with `rake`:
277
+
278
+ ```
279
+ $ bundle exec rake
280
+ ```
281
+
282
+ If those pass, you're ready to start developing the plugin. You can test
283
+ the plugin without installing it into your Vagrant environment by just
284
+ creating a `Vagrantfile` in the top level of this directory (it is gitignored)
285
+ and add the following line to your `Vagrantfile`
286
+ ```ruby
287
+ Vagrant.require_plugin "vagrant-mcs"
288
+ ```
289
+ Use bundler to execute Vagrant:
290
+ ```
291
+ $ bundle exec vagrant up --provider=mcs
292
+ ```
data/Rakefile ADDED
@@ -0,0 +1,21 @@
1
+ require 'rubygems'
2
+ require 'bundler/setup'
3
+ require 'rspec/core/rake_task'
4
+
5
+ # Immediately sync all stdout so that tools like buildbot can
6
+ # immediately load in the output.
7
+ $stdout.sync = true
8
+ $stderr.sync = true
9
+
10
+ # Change to the directory of this file.
11
+ Dir.chdir(File.expand_path("../", __FILE__))
12
+
13
+ # This installs the tasks that help with gem creation and
14
+ # publishing.
15
+ Bundler::GemHelper.install_tasks
16
+
17
+ # Install the `spec` task so that we can run tests.
18
+ RSpec::Core::RakeTask.new
19
+
20
+ # Default task is to run the unit tests
21
+ task :default => "spec"