vagrant-simplecloud 0.0.1

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.
Files changed (43) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +3 -0
  3. data/CHANGELOG.md +6 -0
  4. data/Gemfile +11 -0
  5. data/LICENSE.txt +23 -0
  6. data/README.md +143 -0
  7. data/Rakefile +22 -0
  8. data/box/metadata.json +3 -0
  9. data/box/simple_cloud.box +0 -0
  10. data/lib/vagrant-simplecloud.rb +20 -0
  11. data/lib/vagrant-simplecloud/actions.rb +165 -0
  12. data/lib/vagrant-simplecloud/actions/check_state.rb +19 -0
  13. data/lib/vagrant-simplecloud/actions/create.rb +84 -0
  14. data/lib/vagrant-simplecloud/actions/destroy.rb +32 -0
  15. data/lib/vagrant-simplecloud/actions/modify_provision_path.rb +38 -0
  16. data/lib/vagrant-simplecloud/actions/power_off.rb +33 -0
  17. data/lib/vagrant-simplecloud/actions/power_on.rb +36 -0
  18. data/lib/vagrant-simplecloud/actions/rebuild.rb +56 -0
  19. data/lib/vagrant-simplecloud/actions/reload.rb +33 -0
  20. data/lib/vagrant-simplecloud/actions/setup_key.rb +53 -0
  21. data/lib/vagrant-simplecloud/actions/setup_sudo.rb +48 -0
  22. data/lib/vagrant-simplecloud/actions/setup_user.rb +66 -0
  23. data/lib/vagrant-simplecloud/actions/shut_down.rb +34 -0
  24. data/lib/vagrant-simplecloud/actions/sync_folders.rb +89 -0
  25. data/lib/vagrant-simplecloud/commands/list.rb +89 -0
  26. data/lib/vagrant-simplecloud/commands/rebuild.rb +29 -0
  27. data/lib/vagrant-simplecloud/config.rb +64 -0
  28. data/lib/vagrant-simplecloud/errors.rb +37 -0
  29. data/lib/vagrant-simplecloud/helpers/client.rb +151 -0
  30. data/lib/vagrant-simplecloud/helpers/result.rb +40 -0
  31. data/lib/vagrant-simplecloud/plugin.rb +31 -0
  32. data/lib/vagrant-simplecloud/provider.rb +102 -0
  33. data/lib/vagrant-simplecloud/version.rb +5 -0
  34. data/locales/en.yml +90 -0
  35. data/test/Vagrantfile +41 -0
  36. data/test/cookbooks/test/recipes/default.rb +1 -0
  37. data/test/scripts/provision.sh +3 -0
  38. data/test/test.sh +14 -0
  39. data/test/test_id_rsa +27 -0
  40. data/test/test_id_rsa.pub +1 -0
  41. data/testkit.rb +40 -0
  42. data/vagrant-simplecloud.gemspec +22 -0
  43. metadata +146 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f375943b185d2d11912d1b377fd48b175e0f0fdf
4
+ data.tar.gz: 14eb29009783fb3f39a33cfaa0470da9ae0fa96a
5
+ SHA512:
6
+ metadata.gz: b797329c016f36b9bd3b4484a0e7fef389c9661fb67558dfff8b7eb5447a7dde49b4adf0751cfcc4abf0ec2b986c8488c9b6e0a4ecc89c0aa46b7ee05840d662
7
+ data.tar.gz: 9dda738e598ba6a9eae3f465b6f8de05e05c7b727ae57fed0ba2f84eed0d13c24159e987319195e19d26655012f675ea81140e5769f7bb34a5e904b0a6f94e63
data/.gitignore ADDED
@@ -0,0 +1,3 @@
1
+ .vagrant/
2
+ test/.vagrant/
3
+ *.lock
data/CHANGELOG.md ADDED
@@ -0,0 +1,6 @@
1
+ Changelog
2
+ =========
3
+
4
+ 0.0.1
5
+ -----
6
+ - first test
data/Gemfile ADDED
@@ -0,0 +1,11 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'vagrant', :git => 'git://github.com/mitchellh/vagrant.git', :tag => 'v1.7.2'
4
+ #gem 'vagrant', :git => 'git://github.com/mitchellh/vagrant.git'
5
+ gem 'rake'
6
+
7
+ group :plugins do
8
+ gem 'vagrant-omnibus'
9
+ # gem 'vagrant-simplecloud', :path => '.'
10
+ gemspec
11
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,23 @@
1
+ Copyright (c) 2013 John Bender
2
+ Copyright (c) 2013 Shawn Dahlen
3
+
4
+ MIT License
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining
7
+ a copy of this software and associated documentation files (the
8
+ "Software"), to deal in the Software without restriction, including
9
+ without limitation the rights to use, copy, modify, merge, publish,
10
+ distribute, sublicense, and/or sell copies of the Software, and to
11
+ permit persons to whom the Software is furnished to do so, subject to
12
+ the following conditions:
13
+
14
+ The above copyright notice and this permission notice shall be
15
+ included in all copies or substantial portions of the Software.
16
+
17
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,143 @@
1
+ Simple Cloud Vagrant Provider
2
+ ==============================
3
+
4
+ `vagrant-simplecloud` is a provider plugin for Vagrant that supports the management of [Simple Cloud](https://www.simplecloud.ru/) droplets (instances).
5
+
6
+ Features include:
7
+ - create and destroy droplets
8
+ - power on and off droplets
9
+ - rebuild a droplet (destroys and ups with same IP address)
10
+ - provision a droplet with shell
11
+ - setup a SSH public key for authentication
12
+ - create a new user account during droplet creation
13
+
14
+ The provider has been tested with Vagrant 1.1.5+ using Ubuntu 12.04 and CentOS 6.3 guest operating systems.
15
+
16
+
17
+ Install
18
+ -------
19
+ Install the provider plugin using the Vagrant command-line interface:
20
+
21
+ `vagrant plugin install vagrant-simplecloud`
22
+
23
+
24
+ Configure
25
+ ---------
26
+ Once the provider has been installed, you will need to configure your project to use it. The most basic `Vagrantfile` to create a droplet on Simple Cloud is shown below:
27
+
28
+ ```ruby
29
+ Vagrant.configure('2') do |config|
30
+
31
+ config.vm.provider :simple_cloud do |provider, override|
32
+ override.ssh.private_key_path = '~/.ssh/id_rsa'
33
+ override.vm.box = 'simple_cloud'
34
+ override.vm.box_url = "https://github.com/vadikgo/vagrant-simplecloud/raw/master/box/simple_cloud.box"
35
+
36
+ provider.token = ENV['DO_TOKEN']
37
+ provider.image = '123'
38
+ provider.region = 'base'
39
+ provider.size = '1'
40
+ end
41
+ end
42
+ ```
43
+
44
+ **Configuration Requirements**
45
+ - You *must* specify the `override.ssh.private_key_path` to enable authentication with the droplet. The provider will create a new Simple Cloud SSH key using your public key which is assumed to be the `private_key_path` with a *.pub* extension.
46
+ - You *must* specify your Simple Cloud Personal Access Token at `provider.token`. This may be found on the control panel within the *Apps & API* section.
47
+
48
+ **Supported Configuration Attributes**
49
+
50
+ The following attributes are available to further configure the provider:
51
+ - `provider.image`
52
+ * A string representing the image to use when creating a new droplet. It defaults to `ubuntu-14-04-x64`.
53
+ List available images with the `simplecloud-list images $DIGITAL_OCEAN_TOKEN` command. Like when using the SimpleCloud API directly, [it can be an image ID or slug](http://simplecloud.ru/features/api-manual/#_Create-new-VPS).
54
+ - `provider.ipv6`
55
+ * A boolean flag indicating whether to enable IPv6
56
+ - `provider.region`
57
+ * A string representing the region to create the new droplet in. It defaults to `base`. List available regions with the `simplecloud-list regions $DIGITAL_OCEAN_TOKEN` command.
58
+ - `provider.size`
59
+ * A string representing the size to use when creating a new droplet (e.g. `1gb`). It defaults to `512mb`. List available sizes with the `simplecloud-list sizes $DIGITAL_OCEAN_TOKEN` command.
60
+ - `provider.private_networking`
61
+ * A boolean flag indicating whether to enable a private network interface (if the region supports private networking). It defaults to `false`.
62
+ - `provider.backups_enabled`
63
+ * A boolean flag indicating whether to enable backups for the droplet. It defaults to `false`.
64
+ - `provider.ssh_key_name`
65
+ * A string representing the name to use when creating a Simple Cloud SSH key for droplet authentication. It defaults to `Vagrant`.
66
+ - `provider.setup`
67
+ * A boolean flag indicating whether to setup a new user account and modify sudo to disable tty requirement. It defaults to `true`. If you are using a tool like [Packer](https://packer.io) to create reusable snapshots with user accounts already provisioned, set to `false`.
68
+ - `config.vm.synced_folder`
69
+ * Supports both rsync__args and rsync__exclude, see the [Vagrant Docs](http://docs.vagrantup.com/v2/synced-folders/rsync.html) for more information. rsync__args default to `["--verbose", "--archive", "--delete", "-z", "--copy-links"]` and rsync__exclude defaults to `[".vagrant/"]`.
70
+
71
+ The provider will create a new user account with the specified SSH key for authorization if `config.ssh.username` is set and the `provider.setup` attribute is `true`.
72
+
73
+
74
+ Run
75
+ ---
76
+ After creating your project's `Vagrantfile` with the required configuration
77
+ attributes described above, you may create a new droplet with the following
78
+ command:
79
+
80
+ $ vagrant up --provider=simple_cloud
81
+
82
+ This command will create a new droplet, setup your SSH key for authentication,
83
+ create a new user account, and run the provisioners you have configured.
84
+
85
+ **Supported Commands**
86
+
87
+ The provider supports the following Vagrant sub-commands:
88
+ - `vagrant destroy` - Destroys the droplet instance.
89
+ - `vagrant ssh` - Logs into the droplet instance using the configured user account.
90
+ - `vagrant halt` - Powers off the droplet instance.
91
+ - `vagrant provision` - Runs the configured provisioners and rsyncs any specified `config.vm.synced_folder`.
92
+ - `vagrant reload` - Reboots the droplet instance.
93
+ - `vagrant rebuild` - Destroys the droplet instance and recreates it with the same IP address which was previously assigned.
94
+ - `vagrant status` - Outputs the status (active, off, not created) for the droplet instance.
95
+
96
+
97
+ Troubleshooting
98
+ ---------------
99
+
100
+ * `vagrant plugin install vagrant-simplecloud`
101
+ * Installation on OS X may not working due to a SSL certificate problem, and you may need to specify a certificate path explicitly. To do so, run `ruby -ropenssl -e "p OpenSSL::X509::DEFAULT_CERT_FILE"`. Then, add the following environment variable to your `.bash_profile` script and `source` it: `export SSL_CERT_FILE=/usr/local/etc/openssl/cert.pem`.
102
+
103
+
104
+ FAQ
105
+ ---
106
+
107
+ * The Chef provisioner is no longer supported by default (as of 0.2.0). Please use the `vagrant-omnibus` plugin to install Chef on Vagrant-managed machines. This plugin provides control over the specific version of Chef to install.
108
+
109
+
110
+ Contribute
111
+ ----------
112
+ To contribute, fork then clone the repository, and then the following:
113
+
114
+ **Developing**
115
+
116
+ 1. Install [Bundler](http://bundler.io/)
117
+ 2. Currently the Bundler version is locked to 1.7.9, please install this version.
118
+ * `sudo gem install bundler -v '1.7.9'`
119
+ 3. Then install vagrant-simplecloud dependancies:
120
+ * `bundle _1.7.9_ install`
121
+ 4. Do your development and run a few commands, one to get started would be:
122
+ * `export DO_TOKEN="digital ocean type token"`
123
+ * `VAGRANT_LOG=info bundle _1.7.9_ exec vagrant simplecloud-list images $DO_TOKEN`
124
+ 5. You can then run a test:
125
+ * `bundle _1.7.9_ exec rake test`
126
+ 6. Once you are satisfied with your changes, please submit a pull request.
127
+
128
+ **Releasing**
129
+
130
+ To release a new version of vagrant-simplecloud you will need to do the following:
131
+
132
+ *(only contributors of the GitHub repo and owners of the project at RubyGems will have rights to do this)*
133
+
134
+ 1. First, create a tag and push:
135
+ * `git tag -a v0.7.6 -m 'v0.7.6'`
136
+ 2. Then, create a release on Github with the same versioning convention:
137
+ * https://github.com/vadikgo/vagrant-simplecloud/releases
138
+ 3. You will then need to build and push the new gem to RubyGems:
139
+ * `rake gem:build`
140
+ * `gem push pkg/vagrant-simplecloud-0.7.6.gem`
141
+ 4. Then, when John Doe runs the following, they will receive the updated vagrant-simplecloud plugin:
142
+ * `vagrant plugin update`
143
+ * `vagrant plugin update vagrant-simplecloud`
data/Rakefile ADDED
@@ -0,0 +1,22 @@
1
+ require 'bundler/gem_helper'
2
+
3
+ namespace :gem do
4
+ Bundler::GemHelper.install_tasks
5
+ end
6
+
7
+ task :test do
8
+ result = sh 'bash test/test.sh'
9
+
10
+ if result
11
+ puts 'Success!'
12
+ else
13
+ puts 'Failure!'
14
+ exit 1
15
+ end
16
+ end
17
+
18
+ def env
19
+ ['DO_CLIENT_ID', 'DO_API_KEY', 'VAGRANT_LOG'].inject('') do |acc, key|
20
+ acc += "#{key}=#{ENV[key] || 'error'} "
21
+ end
22
+ end
data/box/metadata.json ADDED
@@ -0,0 +1,3 @@
1
+ {
2
+ "provider": "simple_cloud"
3
+ }
Binary file
@@ -0,0 +1,20 @@
1
+ require 'vagrant-simplecloud/version'
2
+ require 'vagrant-simplecloud/plugin'
3
+ require 'vagrant-simplecloud/errors'
4
+
5
+ module VagrantPlugins
6
+ module SimpleCloud
7
+ def self.source_root
8
+ @source_root ||= Pathname.new(File.expand_path('../../', __FILE__))
9
+ end
10
+
11
+ def self.public_key(private_key_path)
12
+ File.read("#{private_key_path}.pub")
13
+ rescue
14
+ raise Errors::PublicKeyError, :path => "#{private_key_path}.pub"
15
+ end
16
+
17
+ I18n.load_path << File.expand_path('locales/en.yml', source_root)
18
+ I18n.reload!
19
+ end
20
+ end
@@ -0,0 +1,165 @@
1
+ require 'vagrant-simplecloud/actions/check_state'
2
+ require 'vagrant-simplecloud/actions/create'
3
+ require 'vagrant-simplecloud/actions/destroy'
4
+ require 'vagrant-simplecloud/actions/shut_down'
5
+ require 'vagrant-simplecloud/actions/power_off'
6
+ require 'vagrant-simplecloud/actions/power_on'
7
+ require 'vagrant-simplecloud/actions/rebuild'
8
+ require 'vagrant-simplecloud/actions/reload'
9
+ require 'vagrant-simplecloud/actions/setup_user'
10
+ require 'vagrant-simplecloud/actions/setup_sudo'
11
+ require 'vagrant-simplecloud/actions/setup_key'
12
+ require 'vagrant-simplecloud/actions/sync_folders'
13
+ require 'vagrant-simplecloud/actions/modify_provision_path'
14
+
15
+ module VagrantPlugins
16
+ module SimpleCloud
17
+ module Actions
18
+ include Vagrant::Action::Builtin
19
+
20
+ def self.destroy
21
+ return Vagrant::Action::Builder.new.tap do |builder|
22
+ builder.use ConfigValidate
23
+ builder.use Call, CheckState do |env, b|
24
+ case env[:machine_state]
25
+ when :not_created
26
+ env[:ui].info I18n.t('vagrant_simple_cloud.info.not_created')
27
+ else
28
+ b.use Call, DestroyConfirm do |env2, b2|
29
+ if env2[:result]
30
+ b2.use Destroy
31
+ b2.use ProvisionerCleanup if defined?(ProvisionerCleanup)
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
38
+
39
+ def self.ssh
40
+ return Vagrant::Action::Builder.new.tap do |builder|
41
+ builder.use ConfigValidate
42
+ builder.use Call, CheckState do |env, b|
43
+ case env[:machine_state]
44
+ when :active
45
+ b.use SSHExec
46
+ when :off
47
+ env[:ui].info I18n.t('vagrant_simple_cloud.info.off')
48
+ when :not_created
49
+ env[:ui].info I18n.t('vagrant_simple_cloud.info.not_created')
50
+ end
51
+ end
52
+ end
53
+ end
54
+
55
+ def self.ssh_run
56
+ return Vagrant::Action::Builder.new.tap do |builder|
57
+ builder.use ConfigValidate
58
+ builder.use Call, CheckState do |env, b|
59
+ case env[:machine_state]
60
+ when :active
61
+ b.use SSHRun
62
+ when :off
63
+ env[:ui].info I18n.t('vagrant_simple_cloud.info.off')
64
+ when :not_created
65
+ env[:ui].info I18n.t('vagrant_simple_cloud.info.not_created')
66
+ end
67
+ end
68
+ end
69
+ end
70
+
71
+ def self.provision
72
+ return Vagrant::Action::Builder.new.tap do |builder|
73
+ builder.use ConfigValidate
74
+ builder.use Call, CheckState do |env, b|
75
+ case env[:machine_state]
76
+ when :active
77
+ b.use Provision
78
+ b.use ModifyProvisionPath
79
+ b.use SyncFolders
80
+ when :off
81
+ env[:ui].info I18n.t('vagrant_simple_cloud.info.off')
82
+ when :not_created
83
+ env[:ui].info I18n.t('vagrant_simple_cloud.info.not_created')
84
+ end
85
+ end
86
+ end
87
+ end
88
+
89
+ def self.up
90
+ return Vagrant::Action::Builder.new.tap do |builder|
91
+ builder.use ConfigValidate
92
+ builder.use Call, CheckState do |env, b|
93
+ case env[:machine_state]
94
+ when :active
95
+ env[:ui].info I18n.t('vagrant_simple_cloud.info.already_active')
96
+ when :off
97
+ b.use PowerOn
98
+ b.use provision
99
+ when :not_created
100
+ b.use SetupKey
101
+ b.use Create
102
+ b.use SetupSudo
103
+ b.use SetupUser
104
+ b.use provision
105
+ end
106
+ end
107
+ end
108
+ end
109
+
110
+ def self.halt
111
+ return Vagrant::Action::Builder.new.tap do |builder|
112
+ builder.use ConfigValidate
113
+ builder.use Call, CheckState do |env, b|
114
+ case env[:machine_state]
115
+ when :active
116
+ if env[:force_halt]
117
+ b.use PowerOff
118
+ else
119
+ b.use ShutDown
120
+ end
121
+ when :off
122
+ env[:ui].info I18n.t('vagrant_simple_cloud.info.already_off')
123
+ when :not_created
124
+ env[:ui].info I18n.t('vagrant_simple_cloud.info.not_created')
125
+ end
126
+ end
127
+ end
128
+ end
129
+
130
+ def self.reload
131
+ return Vagrant::Action::Builder.new.tap do |builder|
132
+ builder.use ConfigValidate
133
+ builder.use Call, CheckState do |env, b|
134
+ case env[:machine_state]
135
+ when :active
136
+ b.use Reload
137
+ b.use provision
138
+ when :off
139
+ env[:ui].info I18n.t('vagrant_simple_cloud.info.off')
140
+ when :not_created
141
+ env[:ui].info I18n.t('vagrant_simple_cloud.info.not_created')
142
+ end
143
+ end
144
+ end
145
+ end
146
+
147
+ def self.rebuild
148
+ return Vagrant::Action::Builder.new.tap do |builder|
149
+ builder.use ConfigValidate
150
+ builder.use Call, CheckState do |env, b|
151
+ case env[:machine_state]
152
+ when :active, :off
153
+ b.use Rebuild
154
+ b.use SetupSudo
155
+ b.use SetupUser
156
+ b.use provision
157
+ when :not_created
158
+ env[:ui].info I18n.t('vagrant_simple_cloud.info.not_created')
159
+ end
160
+ end
161
+ end
162
+ end
163
+ end
164
+ end
165
+ end
@@ -0,0 +1,19 @@
1
+ module VagrantPlugins
2
+ module SimpleCloud
3
+ module Actions
4
+ class CheckState
5
+ def initialize(app, env)
6
+ @app = app
7
+ @machine = env[:machine]
8
+ @logger = Log4r::Logger.new('vagrant::simplecloud::check_state')
9
+ end
10
+
11
+ def call(env)
12
+ env[:machine_state] = @machine.state.id
13
+ @logger.info "Machine state is '#{@machine.state.id}'"
14
+ @app.call(env)
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,84 @@
1
+ require 'vagrant-simplecloud/helpers/client'
2
+
3
+ module VagrantPlugins
4
+ module SimpleCloud
5
+ module Actions
6
+ class Create
7
+ include Helpers::Client
8
+ include Vagrant::Util::Retryable
9
+
10
+ def initialize(app, env)
11
+ @app = app
12
+ @machine = env[:machine]
13
+ @client = client
14
+ @simple_client = simple_client
15
+ @logger = Log4r::Logger.new('vagrant::simplecloud::create')
16
+ end
17
+
18
+ def call(env)
19
+ ssh_key_id = [env[:ssh_key_id]]
20
+
21
+ # submit new droplet request
22
+ droplet = DropletKit::Droplet.new(name: @machine.config.vm.hostname || @machine.name, \
23
+ region: @machine.provider_config.region,\
24
+ size: @machine.provider_config.size, image: @machine.provider_config.image)
25
+ result = JSON.parse(@simple_client.droplets.create(droplet))
26
+
27
+ # wait for request to complete
28
+ env[:ui].info I18n.t('vagrant_simple_cloud.info.creating')
29
+
30
+ raise 'droplet not ready, no actions_ids' unless result['droplet'].has_key?('action_ids')
31
+ @client.wait_for_event(env, result['droplet']['action_ids'].first)
32
+
33
+ # assign the machine id for reference in other commands
34
+ @machine.id = result['droplet']['id'].to_s
35
+
36
+ # refresh droplet state with provider and output ip address
37
+ droplet = Provider.droplet(@machine, :refresh => true)
38
+ public_network = droplet['networks']['v4'].find { |network| network['type'] == 'public' }
39
+ private_network = droplet['networks']['v4'].find { |network| network['type'] == 'private' }
40
+ env[:ui].info I18n.t('vagrant_simple_cloud.info.droplet_ip', {
41
+ :ip => public_network['ip_address']
42
+ })
43
+ if private_network
44
+ env[:ui].info I18n.t('vagrant_simple_cloud.info.droplet_private_ip', {
45
+ :ip => private_network['ip_address']
46
+ })
47
+ end
48
+
49
+ # wait for ssh to be ready
50
+ switch_user = @machine.provider_config.setup?
51
+ user = @machine.config.ssh.username
52
+ @machine.config.ssh.username = 'root' if switch_user
53
+
54
+ retryable(:tries => 120, :sleep => 10) do
55
+ next if env[:interrupted]
56
+ raise 'not ready' if !@machine.communicate.ready?
57
+ end
58
+
59
+ @machine.config.ssh.username = user
60
+
61
+ @app.call(env)
62
+ end
63
+
64
+ # Both the recover and terminate are stolen almost verbatim from
65
+ # the Vagrant AWS provider up action
66
+ def recover(env)
67
+ return if env['vagrant.error'].is_a?(Vagrant::Errors::VagrantError)
68
+
69
+ if @machine.state.id != :not_created
70
+ terminate(env)
71
+ end
72
+ end
73
+
74
+ def terminate(env)
75
+ destroy_env = env.dup
76
+ destroy_env.delete(:interrupted)
77
+ destroy_env[:config_validate] = false
78
+ destroy_env[:force_confirm_destroy] = true
79
+ env[:action_runner].run(Actions.destroy, destroy_env)
80
+ end
81
+ end
82
+ end
83
+ end
84
+ end