Merge remote-tracking branch 'origin/shell-provisioning' into chef-shell

Conflicts:
	lib/vagrant-azure.rb
This commit is contained in:
Ramakrishnan 2014-04-11 12:57:42 +05:30
Родитель 5555285f9d a702b3ce6e
Коммит 6e2692a6ab
8 изменённых файлов: 125 добавлений и 5 удалений

2
.gitignore поставляемый
Просмотреть файл

@ -4,6 +4,7 @@ Gemfile.lock
azure.box
Vagrantfile
!example_box/Vagrantfile
!example_box/README.md
babu
example_box/
*.rdp
@ -11,3 +12,4 @@ pkg/
gem/
manifests/
modules/
.vagrant/

Просмотреть файл

@ -110,3 +110,15 @@ The vagrant-azure provide exposes a few Azure specific configration options:
* `winrm_https_port` To map the internal WinRM https port 5986 to a different public port.
* `winrm_http_port` To map the internal WinRM http port 5985 to a different public port.
* `tcp_endpoints` - To open any additional ports. E.g., `80` opens port `80` and `80,3389:53389` opens port `80` and `3389`. Also maps the interal port `3389` to public port `53389`
*
## New Commands for `azure` provider
The `azure` provider introduces the following new `vagrant` commands.
* `rdp` - To connect to a Windows VM using RDP. E.g.,
```
C:\> vagrant up --provider=azure
...
C:\> vagrant rdp
```

15
example_box/README.md Normal file
Просмотреть файл

@ -0,0 +1,15 @@
# Vagrant Azure Example Box
This directory contains the sample contents of a box for `azure` provider. Build this into a box using:
On Windows:
```
C:\> bsdtar -cvzf azure.box metadata.json Vagrantfile
```
On *Nix:
```
$ tar cvzf azure.box ./metadata.json ./Vagrantfile
```
You can add any defaults supported by the ```azure``` provider to the `Vagrantfile` in your box and Vagrant's built-in merging system will set them as defaults. Users can override these defaults in their own Vagrantfiles.

Просмотреть файл

@ -14,6 +14,7 @@ module VagrantPlugins
require lib_path.join('provisioner/puppet')
require lib_path.join('provisioner/chef-solo')
require lib_path.join('provisioner/shell')
# This returns the path to the source of this plugin.
#

Просмотреть файл

@ -215,13 +215,14 @@ module VagrantPlugins
next
end
b2.use RestartVM
b2.use Call, WaitForState, :ReadyRole do |env2, b3|
b2.use action_halt
b2.use Call, WaitForState, :StoppedDeallocated do |env2, b3|
if env2[:result]
env2[:machine].id =~ /@/
b3.use Message, I18n.t(
'vagrant_azure.vm_started', :name => $`
)
b3.use Message, I18n.t('vagrant_azure.vm_stopped', name: $`)
b3.use action_up
else
b3.use Message, 'Not able to stop the machine. Please retry.'
end
end
end

Просмотреть файл

@ -25,6 +25,10 @@ module VagrantPlugins
# TODO: Add Shell, Chef-solo and other provisioners
case env[:provisioner].class.to_s
when "VagrantPlugins::Shell::Provisioner"
VagrantPlugins::WinAzure::Provisioner::Shell.new(
env
).provision_for_windows
when "VagrantPlugins::Puppet::Provisioner::Puppet"
VagrantPlugins::WinAzure::Provisioner::Puppet.new(
env

Просмотреть файл

@ -0,0 +1,83 @@
#---------------------------------------------------------------------------
# Copyright (c) Microsoft Open Technologies, Inc.
# All Rights Reserved. Licensed under the Apache 2.0 License.
#---------------------------------------------------------------------------
module VagrantPlugins
module WinAzure
module Provisioner
class Shell
attr_reader :provisioner
def initialize(env)
@env = env
@provisioner = env[:provisioner]
end
def provision_for_windows
arguments = ''
arguments = "#{config.args}" if config.args
with_windows_script_file do |path|
guest_path = if File.extname(config.upload_path) == ''
"#{config.upload_path}#{File.extname(path.to_s)}"
else
config.upload_path
end
@env[:ui].detail "Uploading [#{path}] to [#{guest_path}]"
response = @env[:machine].provider.driver.upload(path, guest_path)
command = "powershell.exe #{guest_path} #{arguments}"
@env[:machine].provider.driver.run_remote_ps(
command
) do |type, data|
if type == :stdout || type == :stderr
@env[:ui].detail data
end
end
end
end
protected
def config
provisioner.config
end
def with_windows_script_file
if config.remote?
download_path = @env[:machine].env.tmp_path.join(
"#{env[:mahine].id}-remote-script#{File.extname(config.path)}"
)
download_path.delete if download_path.file?
begin
Vagrant::Util::Downloader.new(
config.path, download_path
).download!
yield download_path
ensure
download_path.delete
end
elsif config.path
yield config.path
else
# We have an inline script. Create a temp file and handle it.
file = Tempfile.new(['vagrant-powershell', '.ps1'])
begin
file.write(config.inline)
file.fsync
file.close
yield file.path
ensure
file.close
end
end
end
end
end
end
end

Просмотреть файл

@ -12,3 +12,5 @@ en:
RDP not ready
vm_started: |-
VM '%{name}' has been started
vm_stopped: |-
VM '%{name}' has been stopped