vagrant-sakura 0.0.5 → 0.0.6

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: 91ae77db719a831bfc178948c26fbe82e7df357a
4
- data.tar.gz: b354a3f5f56a44a814ac3465bdef5b566c08c1f4
3
+ metadata.gz: 7c61fa6c8644ac72445c9d5dd0982b8bf0643982
4
+ data.tar.gz: 167a4d696347a58a6481288b46affd9d1e419947
5
5
  SHA512:
6
- metadata.gz: 5dbc6a375afe6b557a9a20ae23ce293f8888b08c0c2e76523283feee697a8c39708ec728e6e456891de9f0ad29f4d46dfc6f4265a5b8776931530bec85e84687
7
- data.tar.gz: 2cc0c550aa9ecf306f90d2f680924b727cb31b5a6f253e138756bf493f052177f414a3180c64639d5a620dd9b842695e05e5030c624854505293dfc5b3325f1b
6
+ metadata.gz: 878ff0efe757034d392039fb4b8ae507efd39a57f770c1434ff68b3484ba145d3856fcb73b4f42aaaa9f9cc3445398009a0ca860fad786c9aab54ea46f013662
7
+ data.tar.gz: 0ad0dbda7287373dc57cc3f692d054ba6f992ced53b63c778606f129e956dd17677d78b65f6f1e9730c1e13dac98b14250a42f07048cb0381dedfe277f60050f
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ # 0.0.6 (2014/07/14)
2
+
3
+ - Add `public_key_path` and `use_insecure_key` configuration parameters.
4
+
1
5
  # 0.0.5 (2014/04/19)
2
6
 
3
7
  - Fix Vagrant 1.5 compatibility.
data/README.md CHANGED
@@ -44,17 +44,19 @@ $ vagrant box add dummy https://github.com/tsahara/vagrant-sakura/raw/master/dum
44
44
  ```
45
45
 
46
46
  次に、以下のような Vagrantfile を作成し、必要な情報を埋めてください。
47
+ **なお、以下の Vagrantfile は Vagrant 付属の "insecure key" でログインできる
48
+ サーバを作成します。実用する際は次節の「SSH 鍵の指定方法」を参考に安全な
49
+ SSH 鍵を設定してください。**
47
50
 
48
51
  ```Ruby
49
52
  Vagrant.configure("2") do |config|
50
53
  config.vm.box = "dummy"
51
54
  config.ssh.username = "ubuntu"
52
- config.ssh.private_key_path = File.expand_path "~/.ssh/id_rsa"
53
55
 
54
56
  config.vm.provider :sakura do |sakura|
55
57
  sakura.access_token = 'YOUR ACCESS TOKEN'
56
58
  sakura.access_token_secret = 'YOUR ACCESS TOKEN SECRET'
57
- sakura.sshkey_id = 'YOUR PUBLIC KEY ID'
59
+ sakura.use_insecure_key = true
58
60
  end
59
61
  end
60
62
  ```
@@ -71,6 +73,35 @@ end
71
73
  ``SAKURA_ACCESS_TOKEN`` と ``SAKURA_ACCESS_TOKEN_SECRET``で指定することも
72
74
  できます。
73
75
 
76
+ ## SSH 鍵の指定方法
77
+
78
+ vagrant-sakura では、サーバにログインするための SSH 公開鍵を 3通りの方法で
79
+ 設定できます。
80
+
81
+ 1. コントロールパネルで設定済みの SSH 公開鍵をリソース ID で指定する。
82
+ 対応する秘密鍵は ``override.ssh.private_key_path`` で指定できます。
83
+ ```
84
+ sakura.sshkey_id = '101234567890'
85
+ override.ssh.private_key_path = File.expand_path("~/.ssh/vagrant")
86
+ ```
87
+
88
+ 2. SSH 公開鍵のパスを指定する。この方法では、ひとつサーバを作成する度に SSH
89
+ 公開鍵リソースがひとつ作成されます。vagrant-sakura が SSH 公開鍵リソース
90
+ を削除することはないため、SSH 公開鍵リソースが不必要に増えてしまうことに
91
+ 注意が必要です。
92
+ ```
93
+ sakura.public_key_path = File.expand_path("~/.ssh/vagrant.pub")
94
+ override.ssh.private_key_path = File.expand_path("~/.ssh/vagrant")
95
+ ```
96
+
97
+ 3. Vagrant 付属の "insecure key" をそのまま使う。"insecure key" は安全性に
98
+ 懸念があるため、``sakura.use_insecure_key`` を `true` にセットした時に
99
+ のみ利用されます。
100
+ ```
101
+ sakura.use_insecure_key = true
102
+ ```
103
+
104
+
74
105
  ## コマンド
75
106
  `sakura-list-id` コマンドを使って、`Vagrantfile` で指定するリソース ID
76
107
  を調べることができます。
@@ -22,6 +22,8 @@ module VagrantPlugins
22
22
  disk_plan = env[:machine].provider_config.disk_plan
23
23
  disk_source_archive = env[:machine].provider_config.disk_source_archive
24
24
  sshkey_id = env[:machine].provider_config.sshkey_id
25
+ public_key_path = env[:machine].provider_config.public_key_path
26
+ use_insecure_key = env[:machine].provider_config.use_insecure_key
25
27
 
26
28
  env[:ui].info(I18n.t("vagrant_sakura.creating_instance"))
27
29
  env[:ui].info(" -- Server Name: #{server_name}")
@@ -97,9 +99,13 @@ module VagrantPlugins
97
99
  }
98
100
  if sshkey_id
99
101
  data["SSHKey"] = { "ID" => sshkey_id }
102
+ elsif public_key_path
103
+ data["SSHKey"] = { "PublicKey" => File.read(public_key_path) }
104
+ elsif use_insecure_key
105
+ pubkey = Vagrant.source_root.join("keys", "vagrant.pub").read.chomp
106
+ data["SSHKey"] = { "PublicKey" => pubkey }
100
107
  else
101
- path = env[:machine].ssh_info[:private_key_path] + '.pub'
102
- data["SSHKey"] = { "PublicKey" => File.read(path) }
108
+ raise 'failsafe'
103
109
  end
104
110
  response = api.put("/disk/#{diskid}/config", data)
105
111
  # Config
@@ -28,6 +28,11 @@ module VagrantPlugins
28
28
  # @return [String]
29
29
  attr_accessor :disk_source_archive
30
30
 
31
+ # The pathname of the SSH public key to register on the server.
32
+ #
33
+ # @return [String]
34
+ attr_accessor :public_key_path
35
+
31
36
  # The name of the server.
32
37
  #
33
38
  # @return [String]
@@ -43,6 +48,11 @@ module VagrantPlugins
43
48
  # @return [String]
44
49
  attr_accessor :sshkey_id
45
50
 
51
+ # Use insecure default key to login the server.
52
+ #
53
+ # @return [Boolean]
54
+ attr_accessor :use_insecure_key
55
+
46
56
  # The ID of the zone.
47
57
  attr_accessor :zone_id
48
58
 
@@ -52,9 +62,11 @@ module VagrantPlugins
52
62
  @disk_id = UNSET_VALUE
53
63
  @disk_plan = UNSET_VALUE
54
64
  @disk_source_archive = UNSET_VALUE
65
+ @public_key_path = UNSET_VALUE
55
66
  @server_name = UNSET_VALUE
56
67
  @server_plan = UNSET_VALUE
57
68
  @sshkey_id = UNSET_VALUE
69
+ @use_insecure_key = UNSET_VALUE
58
70
  @zone_id = UNSET_VALUE
59
71
  end
60
72
 
@@ -79,6 +91,8 @@ module VagrantPlugins
79
91
  @disk_source_archive = 112500459149 # Ubuntu Server 12.04.3 LTS 64bit
80
92
  end
81
93
 
94
+ @public_key_path = nil if @public_key_path == UNSET_VALUE
95
+
82
96
  if @server_name == UNSET_VALUE
83
97
  @server_name = nil
84
98
  end
@@ -87,9 +101,9 @@ module VagrantPlugins
87
101
  @server_plan = 1001 # 1Core-1GB - cheapest
88
102
  end
89
103
 
90
- if @sshkey_id == UNSET_VALUE
91
- @sshkey_id = nil
92
- end
104
+ @sshkey_id = nil if @sshkey_id == UNSET_VALUE
105
+
106
+ @use_insecure_key = false if @use_insecure_key == UNSET_VALUE
93
107
 
94
108
  if @zone_id == UNSET_VALUE
95
109
  @zone_id = "is1a" # the first zone
@@ -97,15 +111,19 @@ module VagrantPlugins
97
111
  end
98
112
 
99
113
  def validate(machine)
100
- errors = []
114
+ errors = _detected_errors
101
115
 
102
- if config.access_token.nil?
116
+ if @access_token.nil?
103
117
  errors << I18n.t("vagrant_sakura.config.access_token_required")
104
118
  end
105
- if config.access_token_secret.nil?
119
+ if @access_token_secret.nil?
106
120
  errors << I18n.t("vagrant_sakura.config.access_token_secret_required")
107
121
  end
108
122
 
123
+ if not (@sshkey_id or @public_key_path or @use_insecure_key)
124
+ errors << I18n.t("vagrant_sakura.config.need_ssh_key_config")
125
+ end
126
+
109
127
  { "Sakura Provider" => errors }
110
128
  end
111
129
  end
@@ -1,5 +1,5 @@
1
1
  module VagrantPlugins
2
2
  module Sakura
3
- VERSION = "0.0.5"
3
+ VERSION = "0.0.6"
4
4
  end
5
5
  end
data/locales/en.yml CHANGED
@@ -4,6 +4,10 @@ en:
4
4
  The server is already created.
5
5
  creating_instance: |-
6
6
  Creating a server with the following settings...
7
+ default_key_is_insecure: |-
8
+ Warning! You are using insecure default key to login to the server on
9
+ Sakura-no-cloud. The key is publicly available (bundled in Vagrant
10
+ distribution) so malicious people can login to your server.
7
11
  down: |-
8
12
  The server is down.
9
13
  not_created: |-
@@ -42,3 +46,5 @@ en:
42
46
  An access token is required via "access_token"
43
47
  access_token_secret_required: |-
44
48
  An access token secret is required via "access_token_secret"
49
+ need_ssh_key_config: |-
50
+ You must set one of "sshkey_id", "pubic_key_path", or "use_insecure_key".
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-sakura
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tomoyuki Sahara
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-19 00:00:00.000000000 Z
11
+ date: 2014-07-14 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Enables Vagrant to manage machines in Sakura Cloud.
14
14
  email: