vagrant-digitalocean 0.0.4 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. data/.gitignore +1 -1
  2. data/Gemfile +1 -4
  3. data/LICENSE.txt +2 -1
  4. data/README.md +114 -96
  5. data/Rakefile +8 -10
  6. data/box/digital_ocean.box +0 -0
  7. data/lib/vagrant-digitalocean.rb +12 -4
  8. data/lib/vagrant-digitalocean/actions.rb +159 -0
  9. data/lib/vagrant-digitalocean/actions/check_state.rb +19 -0
  10. data/lib/vagrant-digitalocean/actions/create.rb +36 -21
  11. data/lib/vagrant-digitalocean/actions/destroy.rb +10 -8
  12. data/lib/vagrant-digitalocean/actions/modify_provision_path.rb +15 -17
  13. data/lib/vagrant-digitalocean/actions/power_off.rb +33 -0
  14. data/lib/vagrant-digitalocean/actions/power_on.rb +34 -0
  15. data/lib/vagrant-digitalocean/actions/rebuild.rb +9 -9
  16. data/lib/vagrant-digitalocean/actions/reload.rb +31 -0
  17. data/lib/vagrant-digitalocean/actions/setup_key.rb +56 -0
  18. data/lib/vagrant-digitalocean/actions/setup_provisioner.rb +26 -15
  19. data/lib/vagrant-digitalocean/actions/setup_sudo.rb +19 -12
  20. data/lib/vagrant-digitalocean/actions/setup_user.rb +25 -27
  21. data/lib/vagrant-digitalocean/actions/sync_folders.rb +18 -17
  22. data/lib/vagrant-digitalocean/commands/rebuild.rb +2 -3
  23. data/lib/vagrant-digitalocean/config.rb +30 -33
  24. data/lib/vagrant-digitalocean/errors.rb +0 -2
  25. data/lib/vagrant-digitalocean/helpers/client.rb +13 -15
  26. data/lib/vagrant-digitalocean/plugin.rb +5 -14
  27. data/lib/vagrant-digitalocean/provider.rb +48 -34
  28. data/lib/vagrant-digitalocean/version.rb +1 -1
  29. data/locales/en.yml +32 -40
  30. data/test/Vagrantfile +37 -0
  31. data/test/cookbooks/test/recipes/default.rb +1 -1
  32. data/test/scripts/provision.sh +3 -0
  33. data/test/test.sh +14 -0
  34. metadata +15 -27
  35. data/bin/build.sh +0 -39
  36. data/bin/test_run.sh +0 -15
  37. data/box/Vagrantfile +0 -20
  38. data/box/cookbooks/foo/recipes/default.rb +0 -1
  39. data/lib/vagrant-digitalocean/action.rb +0 -105
  40. data/lib/vagrant-digitalocean/actions/check_ssh_user.rb +0 -46
  41. data/lib/vagrant-digitalocean/actions/is_active.rb +0 -16
  42. data/lib/vagrant-digitalocean/actions/message_is_active.rb +0 -18
  43. data/lib/vagrant-digitalocean/actions/read_state.rb +0 -33
  44. data/lib/vagrant-digitalocean/actions/setup_ssh_key.rb +0 -60
  45. data/lib/vagrant-digitalocean/helpers/file.rb +0 -41
  46. data/lib/vagrant-digitalocean/helpers/translator.rb +0 -20
  47. data/scripts/chef/debian.sh +0 -5
  48. data/scripts/chef/redhat.sh +0 -5
  49. data/scripts/nfs/debian.sh +0 -4
  50. data/scripts/nfs/redhat.sh +0 -11
  51. data/scripts/sudo/redhat.sh +0 -2
  52. data/test/Vagrantfile.centos +0 -19
  53. data/test/Vagrantfile.ubuntu +0 -21
  54. data/test/provision.sh +0 -3
  55. data/test/scripts/setup_user.sh +0 -18
@@ -1,5 +1,5 @@
1
1
  module VagrantPlugins
2
2
  module DigitalOcean
3
- VERSION = "0.0.4"
3
+ VERSION = '0.1.0'
4
4
  end
5
5
  end
data/locales/en.yml CHANGED
@@ -1,13 +1,35 @@
1
1
  en:
2
2
  vagrant_digital_ocean:
3
+ info:
4
+ off: "Droplet is off"
5
+ not_created: "Droplet has not been created"
6
+ already_active: "Droplet is already active"
7
+ already_off: "Droplet is already off"
8
+ creating: "Creating a new droplet..."
9
+ droplet_ip: "Assigned IP address: %{ip}"
10
+ destroying: "Destroying the droplet..."
11
+ powering_off: "Powering off the droplet..."
12
+ powering_on: "Powering on the droplet..."
13
+ rebuilding: "Rebuilding the droplet..."
14
+ reloading: "Rebooting the droplet..."
15
+ creating_user: "Creating user account: %{user}..."
16
+ modifying_sudo: "Modifying sudoers file to remove tty requirement..."
17
+ installing_provisioner: "Installing provisioner: %{provisioner}..."
18
+ using_key: "Using existing SSH key: %{name}"
19
+ creating_key: "Creating new SSH key: %{name}..."
20
+ rsyncing: "Rsyncing folder: %{hostpath} => %{guestpath}..."
3
21
  config:
4
- client_id_required: "Client ID required"
5
- api_key_required: "API key required"
6
- private_key_required: "SSH private key path required"
7
- private_key_missing: "SSH private key is missing: %{key}"
8
- public_key_missing: "SSH public key is missing: %{key}.pub"
22
+ client_id: "Client ID is required"
23
+ api_key: "API key is required"
24
+ private_key: "SSH private key path is required"
25
+ public_key: "SSH public key not found: %{key}"
9
26
  errors:
10
- public_key: "Failed to read public key: %{path}"
27
+ public_key: |-
28
+ There was an issue reading the public key at:
29
+
30
+ Path: %{path}
31
+
32
+ Please check the file's permissions.
11
33
  api_status: |-
12
34
  There was an issue with the request made to the Digital Ocean
13
35
  API at:
@@ -19,7 +41,6 @@ en:
19
41
 
20
42
  Status: %{status}
21
43
  Response: %{response}
22
-
23
44
  rsync: |-
24
45
  There was an error when attemping to rsync a share folder.
25
46
  Please inspect the error message below for more info.
@@ -27,8 +48,7 @@ en:
27
48
  Host path: %{hostpath}
28
49
  Guest path: %{guestpath}
29
50
  Error: %{stderr}
30
-
31
- :json: |-
51
+ json: |-
32
52
  There was an issue with the JSON response from the Digital Ocean
33
53
  API at:
34
54
 
@@ -38,7 +58,7 @@ en:
38
58
  The response JSON from the API was:
39
59
 
40
60
  Response: %{response}
41
- :result_match: |-
61
+ result_match: |-
42
62
  The result collection for %{collection_name}:
43
63
 
44
64
  %{sub_obj}
@@ -47,7 +67,7 @@ en:
47
67
  key "%{key}".
48
68
 
49
69
  Please ensure that the configured value exists in the collection.
50
- :certificate: |-
70
+ certificate: |-
51
71
  The secure connection to the Digital Ocean API has failed. Please
52
72
  ensure that your local certificates directory is defined in the
53
73
  provider config.
@@ -59,33 +79,5 @@ en:
59
79
  This is generally caused by the OpenSSL configuration associated
60
80
  with the Ruby install being unaware of the system specific ca
61
81
  certs.
62
- :local_ip: |-
82
+ local_ip: |-
63
83
  The Digital Ocean provider was unable to determine the host's IP.
64
-
65
- actions:
66
- create:
67
- create_droplet: "Creating the droplet"
68
- wait_active: "Waiting for the droplet to become active (>= 1 min)"
69
- rebuild:
70
- rebuild: "Rebuilding the droplet"
71
- wait: "Waiting for the droplet to rebuild (>= 1 min)"
72
- destroy:
73
- destroying: "Destroying droplet"
74
- wait_off: "Waiting for the droplet to be destroyed"
75
- setup_sudo:
76
- exec: "Making alterations to the sudoers file where necessary"
77
- setup_provisioner:
78
- install: "Installing provisioner: %{provisioner} (>= 2 min)"
79
- sync_folders:
80
- rsync_folder: "Rsyncing folder: %{hostpath} => %{guestpath}"
81
- setup_ssh_key:
82
- existing_key: "Using existing SSH key: %{name}"
83
- insecure_key: "Using default insecure vagrant SSH key"
84
- new_key: "Creating new SSH key: %{name} (%{path})"
85
- message_is_active:
86
- active: "Droplet is already active"
87
- not_active: "Droplet is not active"
88
- check_ssh_user:
89
- fallback: "Failed to authenticate with '%{user}', falling back to 'root'"
90
- modify_provision_path:
91
- modify: "Modifying provisioning path to '/home/%{user}/tmp'"
data/test/Vagrantfile ADDED
@@ -0,0 +1,37 @@
1
+ Vagrant.require_plugin('vagrant-digitalocean')
2
+
3
+ Vagrant.configure('2') do |config|
4
+ config.vm.box = 'digital_ocean'
5
+
6
+ config.ssh.username = 'tester'
7
+ config.ssh.private_key_path = 'test_id_rsa'
8
+
9
+ config.vm.synced_folder '/vagrant', '.', :id => 'vagrant-root', :disabled => true
10
+
11
+ config.vm.provider :digital_ocean do |provider|
12
+ provider.client_id = ENV['DO_CLIENT_ID']
13
+ provider.api_key = ENV['DO_API_KEY']
14
+ provider.region = 'New York 1'
15
+ provider.size = '512MB'
16
+ provider.ssh_key_name = 'Test Key'
17
+ end
18
+
19
+ config.vm.provision :shell, :path => 'scripts/provision.sh'
20
+
21
+ config.vm.provision :chef_solo do |chef|
22
+ chef.cookbooks_path = 'cookbooks'
23
+ chef.add_recipe 'test'
24
+ end
25
+
26
+ config.vm.define :ubuntu do |ubuntu|
27
+ ubuntu.vm.provider :digital_ocean do |provider|
28
+ provider.image = 'Ubuntu 12.04 x64 Server'
29
+ end
30
+ end
31
+
32
+ config.vm.define :centos do |centos|
33
+ centos.vm.provider :digital_ocean do |provider|
34
+ provider.image = 'CentOS 6.3 x64'
35
+ end
36
+ end
37
+ end
@@ -1 +1 @@
1
- log "Testing 1 2 3!"
1
+ log 'Testing 1 2 3!'
@@ -0,0 +1,3 @@
1
+ #!/bin/bash
2
+
3
+ echo 'Testing 1 2 3!'
data/test/test.sh ADDED
@@ -0,0 +1,14 @@
1
+ if ! vagrant box list | grep digital_ocean 1>/dev/null; then
2
+ vagrant box add digital_ocean box/digital_ocean.box
3
+ fi
4
+
5
+ cd test
6
+
7
+ vagrant up --provider=digital_ocean
8
+ vagrant up
9
+ vagrant provision
10
+ vagrant rebuild
11
+ vagrant halt
12
+ vagrant destroy
13
+
14
+ cd ..
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-digitalocean
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-04-02 00:00:00.000000000 Z
12
+ date: 2013-04-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: faraday
@@ -71,24 +71,20 @@ files:
71
71
  - LICENSE.txt
72
72
  - README.md
73
73
  - Rakefile
74
- - bin/build.sh
75
- - bin/test_run.sh
76
- - box/Vagrantfile
77
- - box/cookbooks/foo/recipes/default.rb
78
74
  - box/digital_ocean.box
79
75
  - box/metadata.json
80
76
  - lib/vagrant-digitalocean.rb
81
- - lib/vagrant-digitalocean/action.rb
82
- - lib/vagrant-digitalocean/actions/check_ssh_user.rb
77
+ - lib/vagrant-digitalocean/actions.rb
78
+ - lib/vagrant-digitalocean/actions/check_state.rb
83
79
  - lib/vagrant-digitalocean/actions/create.rb
84
80
  - lib/vagrant-digitalocean/actions/destroy.rb
85
- - lib/vagrant-digitalocean/actions/is_active.rb
86
- - lib/vagrant-digitalocean/actions/message_is_active.rb
87
81
  - lib/vagrant-digitalocean/actions/modify_provision_path.rb
88
- - lib/vagrant-digitalocean/actions/read_state.rb
82
+ - lib/vagrant-digitalocean/actions/power_off.rb
83
+ - lib/vagrant-digitalocean/actions/power_on.rb
89
84
  - lib/vagrant-digitalocean/actions/rebuild.rb
85
+ - lib/vagrant-digitalocean/actions/reload.rb
86
+ - lib/vagrant-digitalocean/actions/setup_key.rb
90
87
  - lib/vagrant-digitalocean/actions/setup_provisioner.rb
91
- - lib/vagrant-digitalocean/actions/setup_ssh_key.rb
92
88
  - lib/vagrant-digitalocean/actions/setup_sudo.rb
93
89
  - lib/vagrant-digitalocean/actions/setup_user.rb
94
90
  - lib/vagrant-digitalocean/actions/sync_folders.rb
@@ -96,23 +92,15 @@ files:
96
92
  - lib/vagrant-digitalocean/config.rb
97
93
  - lib/vagrant-digitalocean/errors.rb
98
94
  - lib/vagrant-digitalocean/helpers/client.rb
99
- - lib/vagrant-digitalocean/helpers/file.rb
100
95
  - lib/vagrant-digitalocean/helpers/result.rb
101
- - lib/vagrant-digitalocean/helpers/translator.rb
102
96
  - lib/vagrant-digitalocean/plugin.rb
103
97
  - lib/vagrant-digitalocean/provider.rb
104
98
  - lib/vagrant-digitalocean/version.rb
105
99
  - locales/en.yml
106
- - scripts/chef/debian.sh
107
- - scripts/chef/redhat.sh
108
- - scripts/nfs/debian.sh
109
- - scripts/nfs/redhat.sh
110
- - scripts/sudo/redhat.sh
111
- - test/Vagrantfile.centos
112
- - test/Vagrantfile.ubuntu
100
+ - test/Vagrantfile
113
101
  - test/cookbooks/test/recipes/default.rb
114
- - test/provision.sh
115
- - test/scripts/setup_user.sh
102
+ - test/scripts/provision.sh
103
+ - test/test.sh
116
104
  - test/test_id_rsa
117
105
  - test/test_id_rsa.pub
118
106
  - vagrant-digitalocean.gemspec
@@ -141,10 +129,10 @@ signing_key:
141
129
  specification_version: 3
142
130
  summary: Enables Vagrant to manage Digital Ocean droplets
143
131
  test_files:
144
- - test/Vagrantfile.centos
145
- - test/Vagrantfile.ubuntu
132
+ - test/Vagrantfile
146
133
  - test/cookbooks/test/recipes/default.rb
147
- - test/provision.sh
148
- - test/scripts/setup_user.sh
134
+ - test/scripts/provision.sh
135
+ - test/test.sh
149
136
  - test/test_id_rsa
150
137
  - test/test_id_rsa.pub
138
+ has_rdoc:
data/bin/build.sh DELETED
@@ -1,39 +0,0 @@
1
- #!/bin/bash
2
-
3
- # uninstall existing versions
4
- gem uninstall -a vagrant-digitalocean
5
-
6
- # clean old gem builds
7
- rm *.gem
8
-
9
- # build the gem
10
- gem build *.gemspec
11
-
12
- # make the gem available for installation as a vagrant plugin
13
- gem install *.gem
14
-
15
- # make sure bsdtar is installed
16
- if ! `which bsdtar > /dev/null`; then
17
- echo "!! Install bsdtar"
18
- exit 1
19
- fi
20
-
21
- # install the plugin
22
- vagrant plugin install vagrant-digitalocean
23
-
24
- # move into the dummy box dir
25
- cd box
26
-
27
- # create the dummy box
28
- tar cvzf digital_ocean.box ./metadata.json
29
-
30
- # remove an old version of the dummy box
31
- if `vagrant box list | grep -q digital_ocean`; then
32
- vagrant box remove digital_ocean digital_ocean
33
- fi
34
-
35
- # add the new version of the dummy box
36
- vagrant box add digital_ocean digital_ocean.box
37
-
38
- # back out of the box dir
39
- cd -
data/bin/test_run.sh DELETED
@@ -1,15 +0,0 @@
1
- function run_test_for {
2
- cp Vagrantfile.$1 Vagrantfile
3
- vagrant up --provider=digital_ocean
4
- vagrant up
5
- vagrant provision
6
- vagrant rebuild
7
- vagrant destroy
8
- vagrant destroy
9
- }
10
-
11
- set -e
12
-
13
- cd test
14
- run_test_for centos
15
- run_test_for ubuntu
data/box/Vagrantfile DELETED
@@ -1,20 +0,0 @@
1
- # -*- mode: ruby -*-
2
- # vi: set ft=ruby :
3
-
4
- Vagrant.configure("2") do |config|
5
- config.vm.box = "digital_ocean"
6
- config.ssh.private_key_path = "../test/test_id_rsa"
7
-
8
- config.vm.provider :digital_ocean do |vm|
9
- vm.client_id = ENV["DO_CLIENT_ID"]
10
- vm.api_key = ENV["DO_API_KEY"]
11
- vm.image = "Ubuntu 12.04 x32 Server"
12
- vm.region = "New York 1"
13
- vm.size = "512MB"
14
- end
15
-
16
- config.vm.provision :chef_solo do |chef|
17
- chef.cookbooks_path = "cookbooks"
18
- chef.add_recipe "foo"
19
- end
20
- end
@@ -1 +0,0 @@
1
- log "Foo!"
@@ -1,105 +0,0 @@
1
- require "vagrant-digitalocean/actions/destroy"
2
- require "vagrant-digitalocean/actions/read_state"
3
- require "vagrant-digitalocean/actions/setup_provisioner"
4
- require "vagrant-digitalocean/actions/setup_sudo"
5
- require "vagrant-digitalocean/actions/create"
6
- require "vagrant-digitalocean/actions/setup_ssh_key"
7
- require "vagrant-digitalocean/actions/sync_folders"
8
- require "vagrant-digitalocean/actions/rebuild"
9
- require "vagrant-digitalocean/actions/is_active"
10
- require "vagrant-digitalocean/actions/message_is_active"
11
- require "vagrant-digitalocean/actions/check_ssh_user"
12
- require "vagrant-digitalocean/actions/modify_provision_path"
13
-
14
- module VagrantPlugins
15
- module DigitalOcean
16
- class Action
17
- include Vagrant::Action::Builtin
18
-
19
- def action(name)
20
- send(name)
21
- end
22
-
23
- def destroy
24
- return Vagrant::Action::Builder.new.tap do |builder|
25
- builder.use ConfigValidate
26
- builder.use Call, Actions::IsActive do |env, b|
27
- if !env[:is_active]
28
- b.use Actions::MessageIsActive
29
- next
30
- end
31
- b.use Actions::Destroy
32
- end
33
- end
34
- end
35
-
36
- def read_state
37
- return Vagrant::Action::Builder.new.tap do |builder|
38
- builder.use ConfigValidate
39
- builder.use Actions::ReadState
40
- end
41
- end
42
-
43
- def ssh
44
- return Vagrant::Action::Builder.new.tap do |builder|
45
- builder.use ConfigValidate
46
- builder.use Call, Actions::IsActive do |env, b|
47
- if !env[:is_active]
48
- b.use Actions::MessageIsActive
49
- next
50
- end
51
- b.use Actions::CheckSSHUser
52
- b.use SSHExec
53
- end
54
- end
55
- end
56
-
57
- def provision
58
- return Vagrant::Action::Builder.new.tap do |builder|
59
- builder.use ConfigValidate
60
- builder.use Call, Actions::IsActive do |env, b|
61
- if !env[:is_active]
62
- b.use Actions::MessageIsActive
63
- next
64
- end
65
- b.use Actions::CheckSSHUser
66
- b.use Actions::ModifyProvisionPath
67
- b.use Provision
68
- b.use Actions::SetupSudo
69
- b.use Actions::SetupProvisioner
70
- b.use Actions::SyncFolders
71
- end
72
- end
73
- end
74
-
75
- def up
76
- return Vagrant::Action::Builder.new.tap do |builder|
77
- builder.use ConfigValidate
78
- builder.use Call, Actions::IsActive do |env, b|
79
- if env[:is_active]
80
- b.use Actions::MessageIsActive
81
- next
82
- end
83
- b.use Actions::SetupSSHKey
84
- b.use Actions::Create
85
- b.use provision
86
- end
87
- end
88
- end
89
-
90
- def rebuild
91
- return Vagrant::Action::Builder.new.tap do |builder|
92
- builder.use ConfigValidate
93
- builder.use Call, Actions::IsActive do |env, b|
94
- if !env[:is_active]
95
- b.use Actions::MessageIsActive
96
- next
97
- end
98
- b.use Actions::Rebuild
99
- b.use provision
100
- end
101
- end
102
- end
103
- end
104
- end
105
- end