vagrant-aws-stsmith 0.5.0.dev
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +21 -0
- data/CHANGELOG.md +76 -0
- data/Gemfile +10 -0
- data/LICENSE +8 -0
- data/README.md +251 -0
- data/Rakefile +21 -0
- data/dummy.box +0 -0
- data/example_box/README.md +13 -0
- data/example_box/metadata.json +3 -0
- data/lib/vagrant-aws.rb +18 -0
- data/lib/vagrant-aws/action.rb +190 -0
- data/lib/vagrant-aws/action/connect_aws.rb +46 -0
- data/lib/vagrant-aws/action/is_created.rb +18 -0
- data/lib/vagrant-aws/action/is_stopped.rb +18 -0
- data/lib/vagrant-aws/action/message_already_created.rb +16 -0
- data/lib/vagrant-aws/action/message_not_created.rb +16 -0
- data/lib/vagrant-aws/action/message_will_not_destroy.rb +16 -0
- data/lib/vagrant-aws/action/read_ssh_info.rb +53 -0
- data/lib/vagrant-aws/action/read_state.rb +38 -0
- data/lib/vagrant-aws/action/run_instance.rb +247 -0
- data/lib/vagrant-aws/action/start_instance.rb +81 -0
- data/lib/vagrant-aws/action/stop_instance.rb +28 -0
- data/lib/vagrant-aws/action/sync_folders.rb +118 -0
- data/lib/vagrant-aws/action/terminate_instance.rb +47 -0
- data/lib/vagrant-aws/action/timed_provision.rb +21 -0
- data/lib/vagrant-aws/action/wait_for_state.rb +41 -0
- data/lib/vagrant-aws/action/warn_networks.rb +19 -0
- data/lib/vagrant-aws/config.rb +372 -0
- data/lib/vagrant-aws/errors.rb +31 -0
- data/lib/vagrant-aws/plugin.rb +73 -0
- data/lib/vagrant-aws/provider.rb +50 -0
- data/lib/vagrant-aws/util/timer.rb +17 -0
- data/lib/vagrant-aws/version.rb +5 -0
- data/locales/en.yml +122 -0
- data/spec/vagrant-aws/config_spec.rb +216 -0
- data/vagrant-aws.gemspec +59 -0
- metadata +149 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 248cdea6857135824d51568415f961f1e8abbde4
|
4
|
+
data.tar.gz: 09b65dc20103ebdad973a4ee1ef3c16427e67cd8
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b62e38936683304835b3e20b0e7afa49da484192f6b1c824e4e1345d4b55d2ba1d8ec51c00745cb35d437246ebc168d8475ede46754403893b0efb7bc7e3ff5f
|
7
|
+
data.tar.gz: 72e5bb1d7df2387ad46cf1ad240f0ddc5ec482d5e40d7f24e4a910fd99a4b9a40b6994a0bb0010c1843e09b0d2ccd3e77847b9b49367f73de3e611c8f6c9f8d7
|
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/CHANGELOG.md
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
# 0.5.0 (unreleased)
|
2
|
+
|
3
|
+
# 0.4.1 (December 17, 2013)
|
4
|
+
|
5
|
+
* Update fog.io to 1.18.0
|
6
|
+
* Fix sync folder user permissions (GH #175)
|
7
|
+
* Fix vagrant < 1.3.0 provisioner compatibility (GH #173)
|
8
|
+
* Add vagrant 1.4.0 multiple SSH key support (GH #172)
|
9
|
+
* Fix EIP deallocation bug (GH #164)
|
10
|
+
* Add (per shared folder) rsync exclude flag (GH #156)
|
11
|
+
|
12
|
+
# 0.4.0 (October 11, 2013)
|
13
|
+
|
14
|
+
* Handle EIP allocation error (GH #134)
|
15
|
+
* Implement halt and reload (GH #31)
|
16
|
+
* rsync ignores Vagrantfile
|
17
|
+
* warn if none of the security groups allows incoming SSH
|
18
|
+
* bump fog.io to 1.15.0
|
19
|
+
* Fix rsync on windows (GH #77)
|
20
|
+
* Add `ssh_host_attribute` config (GH #143)
|
21
|
+
|
22
|
+
# 0.3.0 (September 2, 2013)
|
23
|
+
|
24
|
+
* Parallelize multi-machine up on Vagrant 1.2+
|
25
|
+
* Show proper configuration errors if an invalid configuration key
|
26
|
+
is used.
|
27
|
+
* Request confirmation on `vagrant destroy`, like normal VirtualBox + Vagrant.
|
28
|
+
* If user data is configured, output is shown on "vagrant up" that
|
29
|
+
it is being set.
|
30
|
+
* Add EIP support (GH #65)
|
31
|
+
* Add block device mapping support (GH #93)
|
32
|
+
* README improvements (GH #120)
|
33
|
+
* Fix missing locale message (GH #73)
|
34
|
+
* SyncFolders creates hostpath if it doesn't exist and `:create` option is set (GH #17)
|
35
|
+
* Add IAM Instance Profile support (GH #68)
|
36
|
+
* Add shutdown behavior support (GH #125,#131)
|
37
|
+
|
38
|
+
# 0.2.2 (April 18, 2013)
|
39
|
+
|
40
|
+
* Fix crashing bug with incorrect provisioner arguments.
|
41
|
+
|
42
|
+
# 0.2.1 (April 16, 2013)
|
43
|
+
|
44
|
+
* Got rid of extranneous references to old SSH settings.
|
45
|
+
|
46
|
+
# 0.2.0 (April 16, 2013)
|
47
|
+
|
48
|
+
* Add support for `vagrant ssh -c` [GH-42]
|
49
|
+
* Ability to specify a timeout for waiting for instances to become ready. [GH-44]
|
50
|
+
* Better error message if instance didn't become ready in time.
|
51
|
+
* Connection can now be done using IAM profiles. [GH-41]
|
52
|
+
|
53
|
+
# 0.1.3 (April 9, 2013)
|
54
|
+
|
55
|
+
* The `AWS_ACCESS_KEY` and `AWS_SECRET_KEY` will be used if available
|
56
|
+
and no specific keys are set in the Vagrantfile. [GH-33]
|
57
|
+
* Fix issues with SSH on VPCs, the correct IP is used. [GH-30]
|
58
|
+
* Exclude the ".vagrant" directory from rsync.
|
59
|
+
* Implement `:disabled` flag support for shared folders. [GH-29]
|
60
|
+
* `aws.user_data` to specify user data on the instance. [GH-26]
|
61
|
+
|
62
|
+
# 0.1.2 (March 22, 2013)
|
63
|
+
|
64
|
+
* Choose the proper region when connecting to AWS. [GH-9]
|
65
|
+
* Configurable SSH port. [GH-13]
|
66
|
+
* Support other AWS-compatible API endpoints with `config.endpoint`
|
67
|
+
and `config.version`. [GH-6]
|
68
|
+
* Disable strict host key checking on rsync so known hosts aren't an issue. [GH-7]
|
69
|
+
|
70
|
+
# 0.1.1 (March 18, 2013)
|
71
|
+
|
72
|
+
* Up fog dependency for Vagrant 1.1.1
|
73
|
+
|
74
|
+
# 0.1.0 (March 14, 2013)
|
75
|
+
|
76
|
+
* Initial release.
|
data/Gemfile
ADDED
@@ -0,0 +1,10 @@
|
|
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
|
+
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,251 @@
|
|
1
|
+
# Vagrant AWS Provider
|
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
|
+
|
11
|
+
This is a [Vagrant](http://www.vagrantup.com) 1.2+ plugin that adds an [AWS](http://aws.amazon.com)
|
12
|
+
provider to Vagrant, allowing Vagrant to control and provision machines in
|
13
|
+
EC2 and VPC.
|
14
|
+
|
15
|
+
**NOTE:** This plugin requires Vagrant 1.2+,
|
16
|
+
|
17
|
+
## Features
|
18
|
+
|
19
|
+
* Boot EC2 or VPC instances.
|
20
|
+
* SSH into the instances.
|
21
|
+
* Provision the instances with any built-in Vagrant provisioner.
|
22
|
+
* Minimal synced folder support via `rsync`.
|
23
|
+
* Define region-specifc configurations so Vagrant can manage machines
|
24
|
+
in multiple regions.
|
25
|
+
|
26
|
+
## Usage
|
27
|
+
|
28
|
+
Install using standard Vagrant 1.1+ plugin installation methods. After
|
29
|
+
installing, `vagrant up` and specify the `aws` provider. An example is
|
30
|
+
shown below.
|
31
|
+
|
32
|
+
```
|
33
|
+
$ vagrant plugin install vagrant-aws
|
34
|
+
...
|
35
|
+
$ vagrant up --provider=aws
|
36
|
+
...
|
37
|
+
```
|
38
|
+
|
39
|
+
Of course prior to doing this, you'll need to obtain an AWS-compatible
|
40
|
+
box file for Vagrant.
|
41
|
+
|
42
|
+
## Quick Start
|
43
|
+
|
44
|
+
After installing the plugin (instructions above), the quickest way to get
|
45
|
+
started is to actually use a dummy AWS box and specify all the details
|
46
|
+
manually within a `config.vm.provider` block. So first, add the dummy
|
47
|
+
box using any name you want:
|
48
|
+
|
49
|
+
```
|
50
|
+
$ vagrant box add dummy https://github.com/mitchellh/vagrant-aws/raw/master/dummy.box
|
51
|
+
...
|
52
|
+
```
|
53
|
+
|
54
|
+
And then make a Vagrantfile that looks like the following, filling in
|
55
|
+
your information where necessary.
|
56
|
+
|
57
|
+
```
|
58
|
+
Vagrant.configure("2") do |config|
|
59
|
+
config.vm.box = "dummy"
|
60
|
+
|
61
|
+
config.vm.provider :aws do |aws, override|
|
62
|
+
aws.access_key_id = "YOUR KEY"
|
63
|
+
aws.secret_access_key = "YOUR SECRET KEY"
|
64
|
+
aws.keypair_name = "KEYPAIR NAME"
|
65
|
+
|
66
|
+
aws.ami = "ami-7747d01e"
|
67
|
+
|
68
|
+
override.ssh.username = "ubuntu"
|
69
|
+
override.ssh.private_key_path = "PATH TO YOUR PRIVATE KEY"
|
70
|
+
end
|
71
|
+
end
|
72
|
+
```
|
73
|
+
|
74
|
+
And then run `vagrant up --provider=aws`.
|
75
|
+
|
76
|
+
This will start an Ubuntu 12.04 instance in the us-east-1 region within
|
77
|
+
your account. And assuming your SSH information was filled in properly
|
78
|
+
within your Vagrantfile, SSH and provisioning will work as well.
|
79
|
+
|
80
|
+
Note that normally a lot of this boilerplate is encoded within the box
|
81
|
+
file, but the box file used for the quick start, the "dummy" box, has
|
82
|
+
no preconfigured defaults.
|
83
|
+
|
84
|
+
If you have issues with SSH connecting, make sure that the instances
|
85
|
+
are being launched with a security group that allows SSH access.
|
86
|
+
|
87
|
+
## Box Format
|
88
|
+
|
89
|
+
Every provider in Vagrant must introduce a custom box format. This
|
90
|
+
provider introduces `aws` boxes. You can view an example box in
|
91
|
+
the [example_box/ directory](https://github.com/mitchellh/vagrant-aws/tree/master/example_box).
|
92
|
+
That directory also contains instructions on how to build a box.
|
93
|
+
|
94
|
+
The box format is basically just the required `metadata.json` file
|
95
|
+
along with a `Vagrantfile` that does default settings for the
|
96
|
+
provider-specific configuration for this provider.
|
97
|
+
|
98
|
+
## Configuration
|
99
|
+
|
100
|
+
This provider exposes quite a few provider-specific configuration options:
|
101
|
+
|
102
|
+
* `access_key_id` - The access key for accessing AWS
|
103
|
+
* `ami` - The AMI id to boot, such as "ami-12345678"
|
104
|
+
* `availability_zone` - The availability zone within the region to launch
|
105
|
+
the instance. If nil, it will use the default set by Amazon.
|
106
|
+
* `instance_ready_timeout` - The number of seconds to wait for the instance
|
107
|
+
to become "ready" in AWS. Defaults to 120 seconds.
|
108
|
+
* `instance_type` - The type of instance, such as "m1.small". The default
|
109
|
+
value of this if not specified is "m1.small".
|
110
|
+
* `keypair_name` - The name of the keypair to use to bootstrap AMIs
|
111
|
+
which support it.
|
112
|
+
* `private_ip_address` - The private IP address to assign to an instance
|
113
|
+
within a [VPC](http://aws.amazon.com/vpc/)
|
114
|
+
* `region` - The region to start the instance in, such as "us-east-1"
|
115
|
+
* `secret_access_key` - The secret access key for accessing AWS
|
116
|
+
* `security_groups` - An array of security groups for the instance. If this
|
117
|
+
instance will be launched in VPC, this must be a list of security group
|
118
|
+
IDs.
|
119
|
+
* `iam_instance_profile_arn` - The Amazon resource name (ARN) of the IAM Instance
|
120
|
+
Profile to associate with the instance
|
121
|
+
* `iam_instance_profile_name` - The name of the IAM Instance Profile to associate
|
122
|
+
with the instance
|
123
|
+
* `subnet_id` - The subnet to boot the instance into, for VPC.
|
124
|
+
* `associate_public_ip` - If true, will associate a public IP address to an instance in a VPC.
|
125
|
+
* `tags` - A hash of tags to set on the machine.
|
126
|
+
* `use_iam_profile` - If true, will use [IAM profiles](http://docs.aws.amazon.com/IAM/latest/UserGuide/instance-profiles.html)
|
127
|
+
for credentials.
|
128
|
+
|
129
|
+
These can be set like typical provider-specific configuration:
|
130
|
+
|
131
|
+
```ruby
|
132
|
+
Vagrant.configure("2") do |config|
|
133
|
+
# ... other stuff
|
134
|
+
|
135
|
+
config.vm.provider :aws do |aws|
|
136
|
+
aws.access_key_id = "foo"
|
137
|
+
aws.secret_access_key = "bar"
|
138
|
+
end
|
139
|
+
end
|
140
|
+
```
|
141
|
+
|
142
|
+
In addition to the above top-level configs, you can use the `region_config`
|
143
|
+
method to specify region-specific overrides within your Vagrantfile. Note
|
144
|
+
that the top-level `region` config must always be specified to choose which
|
145
|
+
region you want to actually use, however. This looks like this:
|
146
|
+
|
147
|
+
```ruby
|
148
|
+
Vagrant.configure("2") do |config|
|
149
|
+
# ... other stuff
|
150
|
+
|
151
|
+
config.vm.provider :aws do |aws|
|
152
|
+
aws.access_key_id = "foo"
|
153
|
+
aws.secret_access_key = "bar"
|
154
|
+
aws.region = "us-east-1"
|
155
|
+
|
156
|
+
# Simple region config
|
157
|
+
aws.region_config "us-east-1", :ami => "ami-12345678"
|
158
|
+
|
159
|
+
# More comprehensive region config
|
160
|
+
aws.region_config "us-west-2" do |region|
|
161
|
+
region.ami = "ami-87654321"
|
162
|
+
region.keypair_name = "company-west"
|
163
|
+
end
|
164
|
+
end
|
165
|
+
end
|
166
|
+
```
|
167
|
+
|
168
|
+
The region-specific configurations will override the top-level
|
169
|
+
configurations when that region is used. They otherwise inherit
|
170
|
+
the top-level configurations, as you would probably expect.
|
171
|
+
|
172
|
+
## Networks
|
173
|
+
|
174
|
+
Networking features in the form of `config.vm.network` are not
|
175
|
+
supported with `vagrant-aws`, currently. If any of these are
|
176
|
+
specified, Vagrant will emit a warning, but will otherwise boot
|
177
|
+
the AWS machine.
|
178
|
+
|
179
|
+
## Synced Folders
|
180
|
+
|
181
|
+
There is minimal support for synced folders. Upon `vagrant up`,
|
182
|
+
`vagrant reload`, and `vagrant provision`, the AWS provider will use
|
183
|
+
`rsync` (if available) to uni-directionally sync the folder to
|
184
|
+
the remote machine over SSH.
|
185
|
+
|
186
|
+
This is good enough for all built-in Vagrant provisioners (shell,
|
187
|
+
chef, and puppet) to work!
|
188
|
+
|
189
|
+
## Other Examples
|
190
|
+
|
191
|
+
### Tags
|
192
|
+
|
193
|
+
To use tags, simply define a hash of key/value for the tags you want to associate to your instance, like:
|
194
|
+
|
195
|
+
```ruby
|
196
|
+
Vagrant.configure("2") do |config|
|
197
|
+
# ... other stuff
|
198
|
+
|
199
|
+
config.vm.provider "aws" do |aws|
|
200
|
+
aws.tags = {
|
201
|
+
'Name' => 'Some Name',
|
202
|
+
'Some Key' => 'Some Value'
|
203
|
+
}
|
204
|
+
end
|
205
|
+
end
|
206
|
+
```
|
207
|
+
|
208
|
+
### User data
|
209
|
+
|
210
|
+
You can specify user data for the instance being booted.
|
211
|
+
|
212
|
+
```ruby
|
213
|
+
Vagrant.configure("2") do |config|
|
214
|
+
# ... other stuff
|
215
|
+
|
216
|
+
config.vm.provider "aws" do |aws|
|
217
|
+
# Option 1: a single string
|
218
|
+
aws.user_data = "#!/bin/bash\necho 'got user data' > /tmp/user_data.log\necho"
|
219
|
+
|
220
|
+
# Option 2: use a file
|
221
|
+
aws.user_data = File.read("user_data.txt")
|
222
|
+
end
|
223
|
+
end
|
224
|
+
```
|
225
|
+
|
226
|
+
## Development
|
227
|
+
|
228
|
+
To work on the `vagrant-aws` plugin, clone this repository out, and use
|
229
|
+
[Bundler](http://gembundler.com) to get the dependencies:
|
230
|
+
|
231
|
+
```
|
232
|
+
$ bundle
|
233
|
+
```
|
234
|
+
|
235
|
+
Once you have the dependencies, verify the unit tests pass with `rake`:
|
236
|
+
|
237
|
+
```
|
238
|
+
$ bundle exec rake
|
239
|
+
```
|
240
|
+
|
241
|
+
If those pass, you're ready to start developing the plugin. You can test
|
242
|
+
the plugin without installing it into your Vagrant environment by just
|
243
|
+
creating a `Vagrantfile` in the top level of this directory (it is gitignored)
|
244
|
+
and add the following line to your `Vagrantfile`
|
245
|
+
```ruby
|
246
|
+
Vagrant.require_plugin "vagrant-aws"
|
247
|
+
```
|
248
|
+
Use bundler to execute Vagrant:
|
249
|
+
```
|
250
|
+
$ bundle exec vagrant up --provider=aws
|
251
|
+
```
|
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"
|
data/dummy.box
ADDED
Binary file
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# Vagrant AWS Example Box
|
2
|
+
|
3
|
+
Vagrant providers each require a custom provider-specific box format.
|
4
|
+
This folder shows the example contents of a box for the `aws` provider.
|
5
|
+
To turn this into a box:
|
6
|
+
|
7
|
+
```
|
8
|
+
$ tar cvzf aws.box ./metadata.json ./Vagrantfile
|
9
|
+
```
|
10
|
+
|
11
|
+
This box works by using Vagrant's built-in Vagrantfile merging to setup
|
12
|
+
defaults for AWS. These defaults can easily be overwritten by higher-level
|
13
|
+
Vagrantfiles (such as project root Vagrantfiles).
|
data/lib/vagrant-aws.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require "pathname"
|
2
|
+
|
3
|
+
require "vagrant-aws/plugin"
|
4
|
+
|
5
|
+
module VagrantPlugins
|
6
|
+
module AWS
|
7
|
+
lib_path = Pathname.new(File.expand_path("../vagrant-aws", __FILE__))
|
8
|
+
autoload :Action, lib_path.join("action")
|
9
|
+
autoload :Errors, lib_path.join("errors")
|
10
|
+
|
11
|
+
# This returns the path to the source of this plugin.
|
12
|
+
#
|
13
|
+
# @return [Pathname]
|
14
|
+
def self.source_root
|
15
|
+
@source_root ||= Pathname.new(File.expand_path("../../", __FILE__))
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,190 @@
|
|
1
|
+
require "pathname"
|
2
|
+
|
3
|
+
require "vagrant/action/builder"
|
4
|
+
|
5
|
+
module VagrantPlugins
|
6
|
+
module AWS
|
7
|
+
module Action
|
8
|
+
# Include the built-in modules so we can use them as top-level things.
|
9
|
+
include Vagrant::Action::Builtin
|
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
|
+
|
27
|
+
# This action is called to terminate the remote machine.
|
28
|
+
def self.action_destroy
|
29
|
+
Vagrant::Action::Builder.new.tap do |b|
|
30
|
+
b.use Call, DestroyConfirm do |env, b2|
|
31
|
+
if env[:result]
|
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
|
39
|
+
b2.use ConnectAWS
|
40
|
+
b2.use TerminateInstance
|
41
|
+
b2.use ProvisionerCleanup if defined?(ProvisionerCleanup)
|
42
|
+
else
|
43
|
+
b2.use MessageWillNotDestroy
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
# This action is called when `vagrant provision` is called.
|
50
|
+
def self.action_provision
|
51
|
+
Vagrant::Action::Builder.new.tap do |b|
|
52
|
+
b.use ConfigValidate
|
53
|
+
b.use Call, IsCreated do |env, b2|
|
54
|
+
if !env[:result]
|
55
|
+
b2.use MessageNotCreated
|
56
|
+
next
|
57
|
+
end
|
58
|
+
|
59
|
+
b2.use Provision
|
60
|
+
b2.use SyncFolders
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
# This action is called to read the SSH info of the machine. The
|
66
|
+
# resulting state is expected to be put into the `:machine_ssh_info`
|
67
|
+
# key.
|
68
|
+
def self.action_read_ssh_info
|
69
|
+
Vagrant::Action::Builder.new.tap do |b|
|
70
|
+
b.use ConfigValidate
|
71
|
+
b.use ConnectAWS
|
72
|
+
b.use ReadSSHInfo
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
# This action is called to read the state of the machine. The
|
77
|
+
# resulting state is expected to be put into the `:machine_state_id`
|
78
|
+
# key.
|
79
|
+
def self.action_read_state
|
80
|
+
Vagrant::Action::Builder.new.tap do |b|
|
81
|
+
b.use ConfigValidate
|
82
|
+
b.use ConnectAWS
|
83
|
+
b.use ReadState
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
# This action is called to SSH into the machine.
|
88
|
+
def self.action_ssh
|
89
|
+
Vagrant::Action::Builder.new.tap do |b|
|
90
|
+
b.use ConfigValidate
|
91
|
+
b.use Call, IsCreated do |env, b2|
|
92
|
+
if !env[:result]
|
93
|
+
b2.use MessageNotCreated
|
94
|
+
next
|
95
|
+
end
|
96
|
+
|
97
|
+
b2.use SSHExec
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
def self.action_ssh_run
|
103
|
+
Vagrant::Action::Builder.new.tap do |b|
|
104
|
+
b.use ConfigValidate
|
105
|
+
b.use Call, IsCreated do |env, b2|
|
106
|
+
if !env[:result]
|
107
|
+
b2.use MessageNotCreated
|
108
|
+
next
|
109
|
+
end
|
110
|
+
|
111
|
+
b2.use SSHRun
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
def self.action_prepare_boot
|
117
|
+
Vagrant::Action::Builder.new.tap do |b|
|
118
|
+
b.use Provision
|
119
|
+
b.use SyncFolders
|
120
|
+
b.use WarnNetworks
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
# This action is called to bring the box up from nothing.
|
125
|
+
def self.action_up
|
126
|
+
Vagrant::Action::Builder.new.tap do |b|
|
127
|
+
b.use HandleBoxUrl
|
128
|
+
b.use ConfigValidate
|
129
|
+
b.use ConnectAWS
|
130
|
+
b.use Call, IsCreated do |env1, b1|
|
131
|
+
if env1[:result]
|
132
|
+
b1.use Call, IsStopped do |env2, b2|
|
133
|
+
if env2[:result]
|
134
|
+
b2.use action_prepare_boot
|
135
|
+
b2.use StartInstance # restart this instance
|
136
|
+
else
|
137
|
+
b2.use MessageAlreadyCreated # TODO write a better message
|
138
|
+
end
|
139
|
+
end
|
140
|
+
else
|
141
|
+
b1.use action_prepare_boot
|
142
|
+
b1.use RunInstance # launch a new instance
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
def self.action_reload
|
149
|
+
Vagrant::Action::Builder.new.tap do |b|
|
150
|
+
b.use ConfigValidate
|
151
|
+
b.use ConnectAWS
|
152
|
+
b.use Call, IsCreated do |env, b2|
|
153
|
+
if !env[:result]
|
154
|
+
b2.use MessageNotCreated
|
155
|
+
next
|
156
|
+
end
|
157
|
+
|
158
|
+
b2.use action_halt
|
159
|
+
b2.use Call, WaitForState, :stopped, 120 do |env2, b3|
|
160
|
+
if env2[:result]
|
161
|
+
b3.use action_up
|
162
|
+
else
|
163
|
+
# TODO we couldn't reach :stopped, what now?
|
164
|
+
end
|
165
|
+
end
|
166
|
+
end
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
# The autoload farm
|
171
|
+
action_root = Pathname.new(File.expand_path("../action", __FILE__))
|
172
|
+
autoload :ConnectAWS, action_root.join("connect_aws")
|
173
|
+
autoload :IsCreated, action_root.join("is_created")
|
174
|
+
autoload :IsStopped, action_root.join("is_stopped")
|
175
|
+
autoload :MessageAlreadyCreated, action_root.join("message_already_created")
|
176
|
+
autoload :MessageNotCreated, action_root.join("message_not_created")
|
177
|
+
autoload :MessageWillNotDestroy, action_root.join("message_will_not_destroy")
|
178
|
+
autoload :ReadSSHInfo, action_root.join("read_ssh_info")
|
179
|
+
autoload :ReadState, action_root.join("read_state")
|
180
|
+
autoload :RunInstance, action_root.join("run_instance")
|
181
|
+
autoload :StartInstance, action_root.join("start_instance")
|
182
|
+
autoload :StopInstance, action_root.join("stop_instance")
|
183
|
+
autoload :SyncFolders, action_root.join("sync_folders")
|
184
|
+
autoload :TerminateInstance, action_root.join("terminate_instance")
|
185
|
+
autoload :TimedProvision, action_root.join("timed_provision") # some plugins now expect this action to exist
|
186
|
+
autoload :WaitForState, action_root.join("wait_for_state")
|
187
|
+
autoload :WarnNetworks, action_root.join("warn_networks")
|
188
|
+
end
|
189
|
+
end
|
190
|
+
end
|