vagrant-rackspace 0.1.9 → 0.1.10

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c154b6d9ba1e6a974a32630ee8772c5fc85ec9d1
4
- data.tar.gz: 74eb7ba525a976cda9b66a2509200b5581ecaf7b
3
+ metadata.gz: 30e398c24dbf1f93ba132f6e0f2d11e8743c844e
4
+ data.tar.gz: 8d9a766ee9c1f70c16af9e4d2dd413e1977368ad
5
5
  SHA512:
6
- metadata.gz: 33ce385cd1ec29e0d141f8cbbd0ae84d0907c6f35ef698071bd9653e86a902dac0273b732d23ebb7b03b8dc5fdbf72c31d742244ef93e7b336ba322d0ac07bd8
7
- data.tar.gz: 52a4d2b9a4bee5d33c3dca0ce1bf426ddebd567c65bbfe1078f163e3134d39a6847377031dcca20bdf806a038da0cbf7f85eb407460a12d4437b9087c8969bc7
6
+ metadata.gz: 048872d42e9256cd3a450fcfaa8b85c00191cfcb4b0570219564633621bf6493e514eee7d4d663ce4138837c14faab1508cca84a367f335bd91d33405b9a61d2
7
+ data.tar.gz: 16b4f1da93721f358f59418bef42edc47a68118ad91faf40a1fbfa36334df5253a555537a7a20c540f5cdfb17a55b059ba2371444760278a59fce52abfde05b6
@@ -9,4 +9,4 @@ gemfile:
9
9
  - gemfiles/latest_stable.gemfile
10
10
  - gemfiles/oldest_current.gemfile
11
11
  - gemfiles/previous_release.gemfile
12
-
12
+ - gemfiles/windows_wip.gemfile
data/Appraisals CHANGED
@@ -1,14 +1,26 @@
1
1
  appraise "latest-stable" do
2
- gem "vagrant", :git => 'git://github.com/mitchellh/vagrant.git', :branch => 'v1.4.2'
2
+ group :plugins do
3
+ gem "vagrant", :git => 'git://github.com/mitchellh/vagrant.git', :branch => 'v1.4.2'
4
+ end
3
5
  end
4
6
 
5
7
  # Oldest (current release)
6
8
  appraise "oldest-current" do
7
- gem "vagrant", :git => 'git://github.com/mitchellh/vagrant.git', :branch => 'v1.4.0'
9
+ group :plugins do
10
+ gem "vagrant", :git => 'git://github.com/mitchellh/vagrant.git', :branch => 'v1.4.0'
11
+ end
8
12
  end
9
13
 
10
14
  # Latest patch (previous release)
11
15
  appraise "previous-release" do
12
- gem "vagrant", :git => 'git://github.com/mitchellh/vagrant.git', :branch => 'v1.3.5'
16
+ group :plugins do
17
+ gem "vagrant", :git => 'git://github.com/mitchellh/vagrant.git', :branch => 'v1.3.5'
18
+ end
19
+ end
20
+
21
+ appraise "windows-wip" do
22
+ group :plugins do
23
+ gem "vagrant", :git => 'git://github.com/maxlinc/vagrant.git', :branch => 'winrmssl'
24
+ end
13
25
  end
14
26
 
data/Gemfile CHANGED
@@ -1,19 +1,13 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
-
4
- group :plugins do
5
- gemspec
6
- gem 'vagrant', :git => 'https://github.com/mitchellh/vagrant'
7
- end
8
-
9
- gem "appraisal", "1.0.0.beta2"
10
-
11
3
  group :development do
12
- # We depend on Vagrant for development, but we don't add it as a
13
- # gem dependency because we expect to be installed within the
14
- # Vagrant environment itself using `vagrant plugin`.
15
4
  gem 'coveralls', require: false
16
5
  gem 'pry'
6
+ # My branch contains a fix for https://github.com/thoughtbot/appraisal/issues/76
7
+ gem 'appraisal', '~> 1.0', git: 'https://github.com/maxlinc/appraisal', branch: 'gemspec_in_group'
17
8
  end
18
9
 
19
-
10
+ group :plugins do
11
+ gem "vagrant", git: "https://github.com/mitchellh/vagrant.git", :branch => 'master'
12
+ gemspec
13
+ end
data/README.md CHANGED
@@ -35,11 +35,56 @@ box file for Vagrant.
35
35
  The default configuration of the RHEL family of Linux distributions requires a tty in order to run sudo. Vagrant does not connect with a tty by default, so you may experience the error:
36
36
  > sudo: sorry, you must have a tty to run sudo
37
37
 
38
- The best way to deal with this error is to upgrade to Vagrant 1.4 or later, and enable:
38
+ If you are using Vagrant 1.4 or later you can tell it to use a pty for SSH connections. However,
39
+ RSync doesn't work very well with a pty, so you would still have trouble. The best approach is to
40
+ use an `init_script` setting to modify the sudoers file and disable the require_tty requirement.
41
+
42
+ The following settings show an example of how you can workaround the issue:
39
43
  ```ruby
40
- config.ssh.pty = true
44
+ Vagrant.configure("2") do |config|
45
+ config.vm.box = "dummy"
46
+ config.ssh.pty = true
47
+
48
+ config.vm.provider :rackspace do |rs|
49
+ rs.username = "YOUR USERNAME"
50
+ rs.api_key = "YOUR API KEY"
51
+ rs.flavor = /1 GB Performance/
52
+ rs.image = /^CentOS/
53
+ rs.init_script = 'sed -i\'.bk\' -e \'s/^\(Defaults\s\+requiretty\)/# \1/\' /etc/sudoers'
54
+ end
55
+ end
41
56
  ```
42
57
 
58
+ ### Windows (enabling WinRM)
59
+
60
+ Vagrant 1.6 and later support WinRM as an alternative to SSH for communicating with Windows machines. However, WinRM is not enabled by default on the Rackspace images for Windows. You can use the `init_script
61
+ to enable and secure WinRM so Vagrant will be able to connect. This example enables WinRM for both HTTP and HTTPS traffic.
62
+
63
+ Security warnings:
64
+ - Vagrant's WinRM support is not as secure as SSH. You should only use it for testing purposes where these warnings are acceptible. If you require a more secure setup you'll need to either configure SSH on Windows, or to wait until for future Vagrant releases with better WinRM security.
65
+ - The current Vagrant release (v1.6.5) only supports WinRM as plaintext over HTTP, but [SSL support is in progress](https://github.com/mitchellh/vagrant/pull/4236) and should hopefully be included in the next release.
66
+ - The default setup, even with SSL support, uses self-signed certificates. If you want to use a real Certificate Authority you'll need to customize your Windows images or `init_script`.
67
+
68
+ If you're okay with those warnings, you can create a Windows server using these settings:
69
+
70
+ ```ruby
71
+ Vagrant.configure("2") do |config|
72
+ config.vm.box = "dummy"
73
+ config.ssh.pty = true
74
+
75
+ config.vm.provider :rackspace do |rs|
76
+ rs.username = "YOUR USERNAME"
77
+ rs.api_key = "YOUR API KEY"
78
+ rs.flavor = /1 GB Performance/
79
+ rs.image = 'Windows Server 2012'
80
+ rs.init_script = File.read 'bootstrap.cmd'
81
+ end
82
+ end
83
+ ```
84
+
85
+ You can get a sample [bootstrap.cmd](bootstrap.cmd) file from this repo.
86
+
87
+
43
88
  ## Quick Start
44
89
 
45
90
  After installing the plugin (instructions above), the quickest way to get
@@ -96,21 +141,20 @@ If you are using RackConnect with vagrant, you will need to add the following li
96
141
  The plugin includes several Rackspace-specific vagrant commands. You can get the
97
142
  list of available commands with `vagrant rackspace -h`.
98
143
 
99
- If you want to know what images or flavors are available for a machine, you can use:
144
+ For example to list all available images for a machine you can use:
100
145
 
101
146
  ```
102
147
  $ vagrant rackspace images
103
- $ vagrant rackspace flavors
104
148
  ```
105
149
 
106
150
  In a multi-machine Vagrantfile you can also query for a single machine:
151
+
107
152
  ```
108
153
  $ vagrant rackspace images <name>
109
- $ vagrant rackspace flavors <name>
110
154
  ```
111
155
 
112
- These command will connect to Rackspace using the settings associated with the machine,
113
- and query the region to get the list of available images or flavors.
156
+ These commands will connect to Rackspace using the settings associated with the machine,
157
+ and query the region to get the list of available flavors, images, keypairs, networks and servers.
114
158
 
115
159
  ## Box Format
116
160
 
@@ -134,9 +178,9 @@ This provider exposes quite a few provider-specific configuration options:
134
178
  * `image` - The server image to boot. This can be a string matching the
135
179
  exact ID or name of the image, or this can be a regular expression to
136
180
  partially match some image.
137
- * `rackspace_region` - The region to hit. By default this is :dfw. Valid options are:
181
+ * `rackspace_region` - The region to hit. By default this is :dfw. Valid options are:
138
182
  :dfw, :ord, :lon, :iad, :syd. Users should preference using this setting over `rackspace_compute_url` setting.
139
- * `rackspace_compute_url` - The compute_url to hit. This is good for custom endpoints.
183
+ * `rackspace_compute_url` - The compute_url to hit. This is good for custom endpoints.
140
184
  * `rackspace_auth_url` - The endpoint to authentication against. By default, vagrant will use the global
141
185
  rackspace authentication endpoint for all regions with the exception of :lon. IF :lon region is specified
142
186
  vagrant will authenticate against the UK authentication endpoint.
@@ -4,125 +4,66 @@
4
4
  # Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
5
5
  VAGRANTFILE_API_VERSION = "2"
6
6
 
7
+ %w{RAX_USERNAME RAX_API_KEY VAGRANT_ADMIN_PASSWORD}.each do |var|
8
+ abort "Please set the environment variable #{var} in order to run the test" unless ENV.key? var
9
+ end
10
+
7
11
  Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
8
- Vagrant.require_plugin "vagrant-rackspace"
9
12
  # All Vagrant configuration is done here. The most common configuration
10
13
  # options are documented and commented below. For a complete reference,
11
14
  # please see the online documentation at vagrantup.com.
12
15
 
13
16
  # Every Vagrant virtual environment requires a box to build off of.
14
17
  config.vm.box = "dummy"
15
- config.vm.provider :rackspace do |rs|
16
- rs.username = ENV['RAX_USERNAME']
17
- rs.admin_password = ENV['VAGRANT_ADMIN_PASSWORD']
18
- rs.api_key = ENV['RAX_API_KEY']
19
- rs.flavor = /1 GB Performance/
20
- rs.image = /Ubuntu/
21
- rs.rackspace_region = :iad
22
18
 
23
- # rs.rsync_include 'PATTERN' # per man page for rsync
19
+ config.vm.define :ubuntu do |ubuntu|
20
+ ubuntu.ssh.private_key_path = '~/.ssh/id_rsa'
21
+ ubuntu.vm.provider :rackspace do |rs|
22
+ rs.username = ENV['RAX_USERNAME']
23
+ rs.admin_password = ENV['VAGRANT_ADMIN_PASSWORD']
24
+ rs.api_key = ENV['RAX_API_KEY']
25
+ rs.flavor = /1 GB Performance/
26
+ rs.image = /Ubuntu/
27
+ rs.rackspace_region = :iad
28
+ rs.public_key_path = '~/.ssh/id_rsa.pub'
29
+ end
24
30
  end
25
- # The url from where the 'config.vm.box' box will be fetched if it
26
- # doesn't already exist on the user's system.
27
- # config.vm.box_url = "http://domain.com/path/to/above.box"
28
-
29
- # Create a forwarded port mapping which allows access to a specific port
30
- # within the machine from a port on the host machine. In the example below,
31
- # accessing "localhost:8080" will access port 80 on the guest machine.
32
- # config.vm.network :forwarded_port, guest: 80, host: 8080
33
-
34
- # Create a private network, which allows host-only access to the machine
35
- # using a specific IP.
36
- # config.vm.network :private_network, ip: "192.168.33.10"
37
-
38
- # Create a public network, which generally matched to bridged network.
39
- # Bridged networks make the machine appear as another physical device on
40
- # your network.
41
- # config.vm.network :public_network
42
-
43
- # If true, then any SSH connections made will enable agent forwarding.
44
- # Default value: false
45
- # config.ssh.forward_agent = true
46
31
 
47
- # Share an additional folder to the guest VM. The first argument is
48
- # the path on the host to the actual folder. The second argument is
49
- # the path on the guest to mount the folder. And the optional third
50
- # argument is a set of non-required options.
51
- # config.vm.synced_folder "../data", "/vagrant_data"
52
-
53
- # Provider-specific configuration so you can fine-tune various
54
- # backing providers for Vagrant. These expose provider-specific options.
55
- # Example for VirtualBox:
56
- #
57
- # config.vm.provider :virtualbox do |vb|
58
- # # Don't boot with headless mode
59
- # vb.gui = true
60
- #
61
- # # Use VBoxManage to customize the VM. For example to change memory:
62
- # vb.customize ["modifyvm", :id, "--memory", "1024"]
63
- # end
64
- #
65
- # View the documentation for the provider you're using for more
66
- # information on available options.
67
-
68
- # Enable provisioning with Puppet stand alone. Puppet manifests
69
- # are contained in a directory path relative to this Vagrantfile.
70
- # You will need to create the manifests directory and a manifest in
71
- # the file base.pp in the manifests_path directory.
72
- #
73
- # An example Puppet manifest to provision the message of the day:
74
- #
75
- # # group { "puppet":
76
- # # ensure => "present",
77
- # # }
78
- # #
79
- # # File { owner => 0, group => 0, mode => 0644 }
80
- # #
81
- # # file { '/etc/motd':
82
- # # content => "Welcome to your Vagrant-built virtual machine!
83
- # # Managed by Puppet.\n"
84
- # # }
85
- #
86
- # config.vm.provision :puppet do |puppet|
87
- # puppet.manifests_path = "manifests"
88
- # puppet.manifest_file = "init.pp"
89
- # end
90
-
91
- # Enable provisioning with chef solo, specifying a cookbooks path, roles
92
- # path, and data_bags path (all relative to this Vagrantfile), and adding
93
- # some recipes and/or roles.
94
- #
95
- # config.vm.provision :chef_solo do |chef|
96
- # chef.cookbooks_path = "../my-recipes/cookbooks"
97
- # chef.roles_path = "../my-recipes/roles"
98
- # chef.data_bags_path = "../my-recipes/data_bags"
99
- # chef.add_recipe "mysql"
100
- # chef.add_role "web"
101
- #
102
- # # You may also specify custom JSON attributes:
103
- # chef.json = { :mysql_password => "foo" }
104
- # end
32
+ config.vm.define :centos do |centos|
33
+ centos.ssh.private_key_path = '~/.ssh/id_rsa'
34
+ centos.ssh.pty = true
35
+ centos.vm.provider :rackspace do |rs|
36
+ rs.username = ENV['RAX_USERNAME']
37
+ rs.admin_password = ENV['VAGRANT_ADMIN_PASSWORD']
38
+ rs.api_key = ENV['RAX_API_KEY']
39
+ rs.flavor = /1 GB Performance/
40
+ rs.image = /^CentOS/ # Don't match OnMetal - CentOS
41
+ rs.rackspace_region = :iad
42
+ rs.public_key_path = '~/.ssh/id_rsa.pub'
43
+ rs.init_script = 'sed -i\'.bk\' -e \'s/^\(Defaults\s\+requiretty\)/# \1/\' /etc/sudoers'
44
+ end
45
+ end
105
46
 
106
- # Enable provisioning with chef server, specifying the chef server URL,
107
- # and the path to the validation key (relative to this Vagrantfile).
108
- #
109
- # The Opscode Platform uses HTTPS. Substitute your organization for
110
- # ORGNAME in the URL and validation key.
111
- #
112
- # If you have your own Chef Server, use the appropriate URL, which may be
113
- # HTTP instead of HTTPS depending on your configuration. Also change the
114
- # validation key to validation.pem.
115
- #
116
- # config.vm.provision :chef_client do |chef|
117
- # chef.chef_server_url = "https://api.opscode.com/organizations/ORGNAME"
118
- # chef.validation_key_path = "ORGNAME-validator.pem"
119
- # end
120
- #
121
- # If you're using the Opscode platform, your validator client is
122
- # ORGNAME-validator, replacing ORGNAME with your organization name.
123
- #
124
- # If you have your own Chef Server, the default validation client name is
125
- # chef-validator, unless you changed the configuration.
126
- #
127
- # chef.validation_client_name = "ORGNAME-validator"
47
+ config.vm.define :windows do |windows|
48
+ windows.vm.provision :shell, :inline => 'Write-Output "WinRM is working!"'
49
+ windows.vm.communicator = :winrm
50
+ windows.winrm.username = 'Administrator'
51
+ windows.winrm.password = ENV['VAGRANT_ADMIN_PASSWORD']
52
+ begin
53
+ windows.winrm.transport = :ssl
54
+ windows.winrm.ssl_peer_verification = false
55
+ rescue
56
+ puts "Warning: Vagrant #{Vagrant::VERSION} does not support WinRM over SSL."
57
+ end
58
+ windows.vm.synced_folder ".", "/vagrant", disabled: true
59
+ windows.vm.provider :rackspace do |rs|
60
+ rs.username = ENV['RAX_USERNAME']
61
+ rs.api_key = ENV['RAX_API_KEY']
62
+ rs.admin_password = ENV['VAGRANT_ADMIN_PASSWORD']
63
+ rs.flavor = /2 GB Performance/
64
+ rs.image = 'Windows Server 2012'
65
+ rs.rackspace_region = ENV['RAX_REGION'] ||= 'dfw'
66
+ rs.init_script = File.read 'bootstrap.cmd'
67
+ end
68
+ end
128
69
  end
@@ -0,0 +1,16 @@
1
+ Function SetupWinRM
2
+ {
3
+ Param(
4
+ [String]$hostname,
5
+ [String]$thumbprint
6
+ )
7
+ netsh advfirewall firewall set rule group="remote administration" new enable=yes
8
+ netsh advfirewall firewall add rule name="WinRM HTTP" dir=in action=allow protocol=TCP localport=5985
9
+ netsh advfirewall firewall add rule name="WinRM HTTPS" dir=in action=allow protocol=TCP localport=5986
10
+ winrm create winrm/config/Listener?Address=*+Transport=HTTPS "@{Hostname=`"${hostname}`"; CertificateThumbprint=`"${thumbprint}`"}"
11
+ }
12
+
13
+ $hostname = $env:COMPUTERNAME
14
+ $cert = New-SelfSignedCertificate -CertStoreLocation cert:\LocalMachine\My -DnsName $hostname
15
+ $thumbprint = $cert.Thumbprint
16
+ SetupWinRM -hostname $hostname -thumbprint $thumbprint
@@ -2,11 +2,14 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "appraisal", "1.0.0.beta2"
6
- gem "vagrant", :git=>"git://github.com/mitchellh/vagrant.git", :branch=>"v1.4.2"
7
-
8
5
  group :development do
9
- gem "coveralls", :require=>false
6
+ gem "coveralls", :require => false
7
+ gem "pry"
8
+ gem "appraisal", "~> 1.0", :git => "https://github.com/maxlinc/appraisal", :branch => "gemspec_in_group"
10
9
  end
11
10
 
12
- gemspec :path=>".././"
11
+ group :plugins do
12
+ gem "vagrant", :git => "git://github.com/mitchellh/vagrant.git", :branch => "v1.4.2"
13
+
14
+ gemspec :path => "../"
15
+ end
@@ -2,11 +2,14 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "appraisal", "1.0.0.beta2"
6
- gem "vagrant", :git=>"git://github.com/mitchellh/vagrant.git", :branch=>"v1.4.0"
7
-
8
5
  group :development do
9
- gem "coveralls", :require=>false
6
+ gem "coveralls", :require => false
7
+ gem "pry"
8
+ gem "appraisal", "~> 1.0", :git => "https://github.com/maxlinc/appraisal", :branch => "gemspec_in_group"
10
9
  end
11
10
 
12
- gemspec :path=>".././"
11
+ group :plugins do
12
+ gem "vagrant", :git => "git://github.com/mitchellh/vagrant.git", :branch => "v1.4.0"
13
+
14
+ gemspec :path => "../"
15
+ end
@@ -2,11 +2,14 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "appraisal", "1.0.0.beta2"
6
- gem "vagrant", :git=>"git://github.com/mitchellh/vagrant.git", :branch=>"v1.3.5"
7
-
8
5
  group :development do
9
- gem "coveralls", :require=>false
6
+ gem "coveralls", :require => false
7
+ gem "pry"
8
+ gem "appraisal", "~> 1.0", :git => "https://github.com/maxlinc/appraisal", :branch => "gemspec_in_group"
10
9
  end
11
10
 
12
- gemspec :path=>".././"
11
+ group :plugins do
12
+ gem "vagrant", :git => "git://github.com/mitchellh/vagrant.git", :branch => "v1.3.5"
13
+
14
+ gemspec :path => "../"
15
+ end
@@ -0,0 +1,15 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ group :development do
6
+ gem "coveralls", :require => false
7
+ gem "pry"
8
+ gem "appraisal", "~> 1.0", :git => "https://github.com/maxlinc/appraisal", :branch => "gemspec_in_group"
9
+ end
10
+
11
+ group :plugins do
12
+ gem "vagrant", :git => "git://github.com/maxlinc/vagrant.git", :branch => "winrmssl"
13
+
14
+ gemspec :path => "../"
15
+ end
@@ -12,15 +12,22 @@ module VagrantPlugins
12
12
  def self.action_destroy
13
13
  Vagrant::Action::Builder.new.tap do |b|
14
14
  b.use ConfigValidate
15
- b.use Call, IsCreated do |env, b2|
15
+ b.use Call, IsCreated do |env, b1|
16
16
  if !env[:result]
17
- b2.use MessageNotCreated
17
+ b1.use MessageNotCreated
18
18
  next
19
19
  end
20
20
 
21
- b2.use ConnectRackspace
22
- b2.use DeleteServer
23
- b2.use ProvisionerCleanup if defined?(ProvisionerCleanup)
21
+ b1.use Call, DestroyConfirm do |env1, b2|
22
+ if env1[:result]
23
+ b2.use ConnectRackspace
24
+ b2.use DeleteServer
25
+ b2.use ProvisionerCleanup if defined?(ProvisionerCleanup)
26
+ else
27
+ b2.use Message, I18n.t("vagrant_rackspace.will_not_destroy")
28
+ next
29
+ end
30
+ end
24
31
  end
25
32
  end
26
33
  end
@@ -121,7 +128,7 @@ module VagrantPlugins
121
128
  b.use ConfigValidate
122
129
  b.use Call, IsCreated do |env, b2|
123
130
  created = env[:result]
124
-
131
+
125
132
  if !created
126
133
  b2.use MessageNotCreated
127
134
  next
@@ -150,6 +157,13 @@ module VagrantPlugins
150
157
  end
151
158
  end
152
159
 
160
+ def self.action_list_keypairs
161
+ Vagrant::Action::Builder.new.tap do |b|
162
+ b.use ConnectRackspace
163
+ b.use ListKeyPairs
164
+ end
165
+ end
166
+
153
167
  # The autoload farm
154
168
  action_root = Pathname.new(File.expand_path("../action", __FILE__))
155
169
  autoload :ConnectRackspace, action_root.join("connect_rackspace")
@@ -164,6 +178,9 @@ module VagrantPlugins
164
178
  autoload :CreateImage, action_root.join("create_image")
165
179
  autoload :ListImages, action_root.join("list_images")
166
180
  autoload :ListFlavors, action_root.join("list_flavors")
181
+ autoload :ListKeyPairs, action_root.join("list_keypairs")
182
+ autoload :ListNetworks, action_root.join("list_networks")
183
+ autoload :ListServers, action_root.join("list_servers")
167
184
  end
168
185
  end
169
186
  end
@@ -16,8 +16,14 @@ module VagrantPlugins
16
16
  end
17
17
 
18
18
  def call(env)
19
- # Get the configs
20
- config = env[:machine].provider_config
19
+ # Get the Rackspace configs
20
+ config = env[:machine].provider_config
21
+ machine_config = env[:machine].config
22
+ begin
23
+ communicator = machine_config.vm.communicator ||= :ssh
24
+ rescue NoMethodError
25
+ communicator = :ssh
26
+ end
21
27
 
22
28
  # Find the flavor
23
29
  env[:ui].info(I18n.t("vagrant_rackspace.finding_flavor"))
@@ -32,14 +38,19 @@ module VagrantPlugins
32
38
  # Figure out the name for the server
33
39
  server_name = config.server_name || env[:machine].name
34
40
 
35
- # If we are using a key name, can ignore the public key path
36
- if not config.key_name
37
- # If we're using the default keypair, then show a warning
38
- default_key_path = Vagrant.source_root.join("keys/vagrant.pub").to_s
39
- public_key_path = File.expand_path(config.public_key_path, env[:root_path])
40
-
41
- if default_key_path == public_key_path
42
- env[:ui].warn(I18n.t("vagrant_rackspace.warn_insecure_ssh"))
41
+ if communicator == :winrm
42
+ env[:ui].warn(I18n.t("vagrant_rackspace.warn_insecure_winrm")) if !winrm_secure?(machine_config)
43
+ env[:ui].warn(I18n.t("vagrant_rackspace.warn_winrm_password")) if config.admin_password != machine_config.winrm.password
44
+ else # communicator == :ssh
45
+ # If we are using a key name, can ignore the public key path
46
+ if not config.key_name
47
+ # If we're using the default keypair, then show a warning
48
+ default_key_path = Vagrant.source_root.join("keys/vagrant.pub").to_s
49
+ public_key_path = File.expand_path(config.public_key_path, env[:root_path])
50
+
51
+ if default_key_path == public_key_path
52
+ env[:ui].warn(I18n.t("vagrant_rackspace.warn_insecure_ssh"))
53
+ end
43
54
  end
44
55
  end
45
56
 
@@ -71,14 +82,26 @@ module VagrantPlugins
71
82
  options[:config_drive] = config.config_drive
72
83
  end
73
84
 
74
- if config.key_name
75
- options[:key_name] = config.key_name
76
- env[:ui].info(" -- Key Name: #{config.key_name}")
77
- else
85
+ if communicator == :ssh
86
+ if config.key_name
87
+ options[:key_name] = config.key_name
88
+ env[:ui].info(" -- Key Name: #{config.key_name}")
89
+ else
90
+ options[:personality] = [
91
+ {
92
+ :path => "/root/.ssh/authorized_keys",
93
+ :contents => encode64(File.read(public_key_path))
94
+ }
95
+ ]
96
+ end
97
+ end
98
+
99
+ if config.init_script && communicator == :winrm
100
+ # Might want to check init_script against known limits
78
101
  options[:personality] = [
79
102
  {
80
- :path => "/root/.ssh/authorized_keys",
81
- :contents => Base64.encode64(File.read(public_key_path))
103
+ :path => 'C:\\cloud-automation\\bootstrap.cmd',
104
+ :contents => encode64(config.init_script, :crlf_newline => true)
82
105
  }
83
106
  ]
84
107
  end
@@ -99,8 +122,7 @@ module VagrantPlugins
99
122
  next if env[:interrupted]
100
123
 
101
124
  # Set the progress
102
- env[:ui].clear_line
103
- env[:ui].report_progress(server.progress, 100, false)
125
+ report_server_progress(env[:machine], server.progress, 100, false)
104
126
 
105
127
  # Wait for the server to be ready
106
128
  begin
@@ -131,8 +153,10 @@ module VagrantPlugins
131
153
  end
132
154
  end
133
155
 
134
- # Wait for SSH to become available
135
- env[:ui].info(I18n.t("vagrant_rackspace.waiting_for_ssh"))
156
+ # Wait for a communicator
157
+ env[:ui].info(I18n.t("vagrant_rackspace.waiting_for_communicator",
158
+ :communicator => communicator, :address => server.public_ip_address))
159
+
136
160
  while true
137
161
  # If we're interrupted then just back out
138
162
  break if env[:interrupted]
@@ -143,6 +167,7 @@ module VagrantPlugins
143
167
  env[:ui].info(I18n.t("vagrant_rackspace.ready"))
144
168
  end
145
169
 
170
+ env[:machine].communicate.sudo config.init_script if config.init_script && communicator == :ssh
146
171
  @app.call(env)
147
172
  end
148
173
 
@@ -174,7 +199,32 @@ module VagrantPlugins
174
199
  item
175
200
  end
176
201
 
202
+ def encode64(content, options = nil)
203
+ content = content.encode options if options
204
+ encoded = Base64.encode64 content
205
+ encoded.strip
206
+ end
207
+
208
+ # This method checks to see if WinRM over SSL is supported and used
209
+ def winrm_secure?(machine_config)
210
+ machine_config.winrm.transport == :ssl
211
+ rescue NoMethodError
212
+ false
213
+ end
214
+
215
+ # Ported from Vagrant::UI, but scoped to the machine's UI
216
+ def report_server_progress(machine, progress, total, show_parts)
217
+ machine.ui.clear_line
218
+ if total && total > 0
219
+ percent = (progress.to_f / total.to_f) * 100
220
+ line = "Progress: #{percent.to_i}%"
221
+ line << " (#{progress} / #{total})" if show_parts
222
+ else
223
+ line = "Progress: #{progress}"
224
+ end
177
225
 
226
+ machine.ui.info(line, new_line: false)
227
+ end
178
228
  end
179
229
  end
180
230
  end
@@ -0,0 +1,20 @@
1
+ module VagrantPlugins
2
+ module Rackspace
3
+ module Action
4
+ class ListKeyPairs
5
+ def initialize(app, env)
6
+ @app = app
7
+ end
8
+
9
+ def call(env)
10
+ compute_service = env[:rackspace_compute]
11
+ env[:ui].info ('%s' % ['KeyPair Name'])
12
+ compute_service.key_pairs.sort_by(&:name).each do |keypair|
13
+ env[:ui].info ('%s' % [keypair.name])
14
+ end
15
+ @app.call(env)
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,20 @@
1
+ module VagrantPlugins
2
+ module Rackspace
3
+ module Action
4
+ class ListNetworks
5
+ def initialize(app, env)
6
+ @app = app
7
+ end
8
+
9
+ def call(env)
10
+ compute_service = env[:rackspace_compute]
11
+ env[:ui].info ('%-36s %-24s %s' % ['Network Name', 'Network CIDR', 'Network ID'])
12
+ compute_service.networks.sort_by(&:label).each do |network|
13
+ env[:ui].info ('%-36s %-24s %s' % [network.label, network.cidr, network.id])
14
+ end
15
+ @app.call(env)
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,20 @@
1
+ module VagrantPlugins
2
+ module Rackspace
3
+ module Action
4
+ class ListServers
5
+ def initialize(app, env)
6
+ @app = app
7
+ end
8
+
9
+ def call(env)
10
+ compute_service = env[:rackspace_compute]
11
+ env[:ui].info ('%-20s %-20s %s' % ['Server Name', 'State', 'IPv4 address'])
12
+ compute_service.servers.sort_by(&:name).each do |server|
13
+ env[:ui].info ('%-20s %-20s %s' % [server.name, server.state, server.access_ipv4_address])
14
+ end
15
+ @app.call(env)
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,21 @@
1
+ module VagrantPlugins
2
+ module Rackspace
3
+ module Command
4
+ class KeyPairs < Vagrant.plugin("2", :command)
5
+ def execute
6
+ options = {}
7
+ opts = OptionParser.new do |o|
8
+ o.banner = "Usage: vagrant rackspace keypairs [options]"
9
+ end
10
+
11
+ argv = parse_options(opts)
12
+ return if !argv
13
+
14
+ with_target_vms(argv, :provider => :rackspace) do |machine|
15
+ machine.action('list_keypairs')
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,21 @@
1
+ module VagrantPlugins
2
+ module Rackspace
3
+ module Command
4
+ class Networks < Vagrant.plugin("2", :command)
5
+ def execute
6
+ options = {}
7
+ opts = OptionParser.new do |o|
8
+ o.banner = "Usage: vagrant rackspace networks [options]"
9
+ end
10
+
11
+ argv = parse_options(opts)
12
+ return if !argv
13
+
14
+ with_target_vms(argv, :provider => :rackspace) do |machine|
15
+ machine.action('list_networks')
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -20,6 +20,18 @@ module VagrantPlugins
20
20
  require File.expand_path("../flavors", __FILE__)
21
21
  Flavors
22
22
  end
23
+ @subcommands.register(:keypairs) do
24
+ require File.expand_path("../keypairs", __FILE__)
25
+ KeyPairs
26
+ end
27
+ @subcommands.register(:networks) do
28
+ require File.expand_path("../networks", __FILE__)
29
+ Networks
30
+ end
31
+ @subcommands.register(:servers) do
32
+ require File.expand_path("../servers", __FILE__)
33
+ Servers
34
+ end
23
35
 
24
36
  super(argv, env)
25
37
  end
@@ -0,0 +1,21 @@
1
+ module VagrantPlugins
2
+ module Rackspace
3
+ module Command
4
+ class Servers < Vagrant.plugin("2", :command)
5
+ def execute
6
+ options = {}
7
+ opts = OptionParser.new do |o|
8
+ o.banner = "Usage: vagrant rackspace servers [options]"
9
+ end
10
+
11
+ argv = parse_options(opts)
12
+ return if !argv
13
+
14
+ with_target_vms(argv, :provider => :rackspace) do |machine|
15
+ machine.action('list_servers')
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -119,6 +119,17 @@ module VagrantPlugins
119
119
  # @return [String]
120
120
  attr_accessor :admin_password
121
121
 
122
+ # A initialization script to run on the target machine before
123
+ # Vagrant connects. It should generally be used only for enabling
124
+ # or securing shell connection transport protocols, like SSH or WinRM.
125
+ # Use normal Vagrant provisioners for other purposes.
126
+ #
127
+ # This script may be subject to the limits for Server Personality.
128
+ #
129
+ # @return [String]
130
+ # @see http://docs.rackspace.com/servers/api/v2/cs-devguide/content/Server_Personality-d1e2543.html Server Personality
131
+ attr_accessor :init_script
132
+
122
133
  # Default Rackspace Cloud Network IDs
123
134
  SERVICE_NET_ID = '11111111-1111-1111-1111-111111111111'
124
135
  PUBLIC_NET_ID = '00000000-0000-0000-0000-000000000000'
@@ -139,6 +150,7 @@ module VagrantPlugins
139
150
  @disk_config = UNSET_VALUE
140
151
  @networks = []
141
152
  @rsync_includes = []
153
+ @init_script = UNSET_VALUE
142
154
  end
143
155
 
144
156
  def finalize!
@@ -157,6 +169,7 @@ module VagrantPlugins
157
169
  @disk_config = nil if @disk_config == UNSET_VALUE
158
170
  @networks = nil if @networks.empty?
159
171
  @rsync_includes = nil if @rsync_includes.empty?
172
+ @init_script = nil if @init_script == UNSET_VALUE
160
173
 
161
174
  if @public_key_path == UNSET_VALUE
162
175
  @public_key_path = Vagrant.source_root.join("keys/vagrant.pub")
@@ -23,7 +23,7 @@ module VagrantPlugins
23
23
  Config
24
24
  end
25
25
 
26
- provider(:rackspace) do
26
+ provider(:rackspace, { :box_optional => true, parallel: true}) do
27
27
  # Setup some things
28
28
  Rackspace.init_i18n
29
29
  Rackspace.init_logging
@@ -1,5 +1,5 @@
1
1
  module VagrantPlugins
2
2
  module Rackspace
3
- VERSION = "0.1.9"
3
+ VERSION = "0.1.10"
4
4
  end
5
5
  end
@@ -24,21 +24,32 @@ en:
24
24
  Waiting for the server to be built...
25
25
  waiting_for_rackconnect: |-
26
26
  Waiting for RackConnect to complete...
27
- waiting_for_ssh: |-
28
- Waiting for SSH to become available...
27
+ waiting_for_communicator: |-
28
+ Waiting for %{communicator} to become available at %{address}...
29
29
  warn_insecure_ssh: |-
30
30
  Warning! By not specifying a custom public/private keypair,
31
31
  Vagrant is defaulting to use the insecure keypair that ships with
32
32
  Vagrant. While this isn't much of a big deal for local development,
33
33
  this is quite insecure for remote servers. Please specify a custom
34
34
  public/private keypair.
35
+ warn_insecure_winrm: |-
36
+ Warning! Vagrant is using plaintext communication for WinRM. While
37
+ this isn't much of a big deal for local development, this is quite
38
+ insecure for remote servers. Please configure WinRM to use SSL.
39
+ warn_winrm_password: |-
40
+ Warning! Vagrant has no way to store the Administrator password generated
41
+ by Rackspace for later use with WinRM. Please configure Vagrant to use
42
+ the same value for the winrm password and the Rackspace admin_password so
43
+ Vagrant will be able to connect via WinRM.
35
44
  warn_networks: |-
36
45
  Warning! The Rackspace provider doesn't support any of the Vagrant
37
46
  high-level network configurations (`config.vm.network`). They
38
47
  will be silently ignored.
48
+ will_not_destroy: |-
49
+ The server will not be deleted.
39
50
  sync_folders: |-
40
51
  Rackspace support for Vagrant 1.3 has been deprecated. Please
41
- upgrade to the latest version of vagrant for continued support.
52
+ upgrade to the latest version of vagrant for continued support.
42
53
 
43
54
  config:
44
55
  api_key_required: |-
@@ -25,6 +25,7 @@ describe VagrantPlugins::Rackspace::Config do
25
25
  its(:networks) { should be_nil }
26
26
  its(:rsync_includes) { should be_nil }
27
27
  its(:admin_password) { should be_nil }
28
+ its(:init_script) { should be_nil }
28
29
  end
29
30
 
30
31
  describe "overriding defaults" do
@@ -39,7 +40,8 @@ describe VagrantPlugins::Rackspace::Config do
39
40
  :server_name,
40
41
  :disk_config,
41
42
  :username,
42
- :admin_password].each do |attribute|
43
+ :admin_password,
44
+ :init_script].each do |attribute|
43
45
  it "should not default #{attribute} if overridden" do
44
46
  subject.send("#{attribute}=".to_sym, "foo")
45
47
  subject.finalize!
@@ -56,7 +58,7 @@ describe VagrantPlugins::Rackspace::Config do
56
58
  subject.send(:networks).should include(VagrantPlugins::Rackspace::Config::SERVICE_NET_ID)
57
59
  end
58
60
 
59
- it "should not default rsync_includes if overridden" do
61
+ it "should not default rsync_includes if overridden" do
60
62
  inc = "core"
61
63
  subject.send(:rsync_include, inc)
62
64
  subject.finalize!
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-rackspace
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.9
4
+ version: 0.1.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mitchell Hashimoto
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-24 00:00:00.000000000 Z
11
+ date: 2014-12-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fog
@@ -84,6 +84,7 @@ files:
84
84
  - Rakefile
85
85
  - Vagrantfile
86
86
  - Vagrantfile.multi
87
+ - bootstrap.cmd
87
88
  - dummy.box
88
89
  - example_box/README.md
89
90
  - example_box/metadata.json
@@ -96,6 +97,7 @@ files:
96
97
  - gemfiles/latest_stable.gemfile
97
98
  - gemfiles/oldest_current.gemfile
98
99
  - gemfiles/previous_release.gemfile
100
+ - gemfiles/windows_wip.gemfile
99
101
  - lib/vagrant-rackspace.rb
100
102
  - lib/vagrant-rackspace/action.rb
101
103
  - lib/vagrant-rackspace/action/connect_rackspace.rb
@@ -105,6 +107,9 @@ files:
105
107
  - lib/vagrant-rackspace/action/is_created.rb
106
108
  - lib/vagrant-rackspace/action/list_flavors.rb
107
109
  - lib/vagrant-rackspace/action/list_images.rb
110
+ - lib/vagrant-rackspace/action/list_keypairs.rb
111
+ - lib/vagrant-rackspace/action/list_networks.rb
112
+ - lib/vagrant-rackspace/action/list_servers.rb
108
113
  - lib/vagrant-rackspace/action/message_already_created.rb
109
114
  - lib/vagrant-rackspace/action/message_not_created.rb
110
115
  - lib/vagrant-rackspace/action/read_ssh_info.rb
@@ -113,8 +118,11 @@ files:
113
118
  - lib/vagrant-rackspace/command/create_image.rb
114
119
  - lib/vagrant-rackspace/command/flavors.rb
115
120
  - lib/vagrant-rackspace/command/images.rb
121
+ - lib/vagrant-rackspace/command/keypairs.rb
116
122
  - lib/vagrant-rackspace/command/list_images.rb
123
+ - lib/vagrant-rackspace/command/networks.rb
117
124
  - lib/vagrant-rackspace/command/root.rb
125
+ - lib/vagrant-rackspace/command/servers.rb
118
126
  - lib/vagrant-rackspace/config.rb
119
127
  - lib/vagrant-rackspace/errors.rb
120
128
  - lib/vagrant-rackspace/plugin.rb