vagrant-azure 1.0.3 → 1.0.4

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: 2aee9b5f481d71e24f031aeebf3b3c839fc9e1f6
4
- data.tar.gz: 1ed64f270bddda3ef6ac26d9db8c700224c4ccca
3
+ metadata.gz: 885a96873ff590a63735e07f52d4fbd602055b06
4
+ data.tar.gz: 65557e9414515c416956099c4145f073cab3afb4
5
5
  SHA512:
6
- metadata.gz: feb568430aa70d4c59ab756d68b1a2b9c6e8a770269867f3b4a4bc3beb163eff604a4bb454e52e7485e50b9cb452ea530d00f04390b59d0f3632d405ef4fa093
7
- data.tar.gz: 813c3493741560bb981ba4fd87454b299eb3c5496fd9b24e43d487affb297cb24cd9a04cd0a3345a340f7eb090f1dec244175297de80ebab34601fd6d127bb0f
6
+ metadata.gz: 2dc3dac70cd18050d7ab10382b0645fe6614b9e3d27b7965c55ff2b3c3fa7f81ed89d39c2801d83908df9fa9e18519cec7e6e7070d78fe972ceeceb5606b6674
7
+ data.tar.gz: a5163475ec6352837905e1504cb92afc8a81a98c4d1c8a23fdfd9e379fc2811b08d7230198fdef21c90fe0c0f9bbfee04ae95aaa77306a6f242974a9f7861bd9
data/.gitignore CHANGED
@@ -4,6 +4,7 @@ Gemfile.lock
4
4
  azure.box
5
5
  Vagrantfile
6
6
  !example_box/Vagrantfile
7
+ !example_box/README.md
7
8
  babu
8
9
  example_box/
9
10
  *.rdp
@@ -11,3 +12,4 @@ pkg/
11
12
  gem/
12
13
  manifests/
13
14
  modules/
15
+ .vagrant/
data/README.md CHANGED
@@ -1,9 +1,124 @@
1
1
  # Vagrant Azure Provider
2
2
 
3
- This is a [Vagrant](http://www.vagrantup.com) 1.2+ plugin that adds [Windows Azure](https://www.windowsazure.com)
3
+ ![Gem Version](https://badge.fury.io/rb/vagrant-azure.png)
4
+
5
+ This is a [Vagrant](http://www.vagrantup.com) 1.5.2+ plugin that adds [Windows Azure](https://www.windowsazure.com)
4
6
  provider to Vagrant, allowing Vagrant to control and provision machines in
5
7
  Windows Azure.
6
8
 
7
- **NOTE:** This plugin requires Vagrant 1.2+,
9
+ **NOTE:** This plugin requires Vagrant 1.5.2+,
10
+
11
+ ## Usage
12
+
13
+ Install Vagrant 1.5.2 or higher - [Download Vagrant](http://www.vagrantup.com/downloads.html)
14
+
15
+ Install the vagrant-azure plugin using the standarn Vagrant 1.1+ installation methods. After installing the plugin, you can you can ```vagrant up``` and use ```azure``` provider. For example:
16
+
17
+ ```
18
+ C:\> vagrant plugin install vagrant-azure
19
+ ...
20
+ C:\> vagrant up --provider=azure
21
+ ...
22
+ ```
23
+
24
+ You'll need an ```azure``` box before you can do ```vagrant up``` though.
25
+
26
+ ## Quick Start
27
+
28
+ You can use the dummy box and specify all the required details manually in the ```confiv.vm.provider``` block in your ```Vagrantfile```. Add the dummy box with the name you want:
29
+
30
+ ```
31
+ C:\> vagrant box add azure https://github.com/msopentech/vagrant-azure/raw/master/dummy.box
32
+ ...
33
+ ```
34
+
35
+ Now edit your ```Vagrantfile``` as shown below and provide all the values as explained.
36
+
37
+ ```ruby
38
+ Vagrant.configure('2') do |config|
39
+ config.vm.box = 'azure'
40
+
41
+ config.vm.provider :azure do |azure|
42
+ azure.mgmt_certificate = 'YOUR AZURE MANAGEMENT CERTIFICATE'
43
+ azure.mgmt_endpoint = 'https://management.core.windows.net'
44
+ azure.subscription_id = 'YOUR AZURE SUBSCRIPTION ID'
45
+ auzre.storage_acct_name = 'NAME OF YOUR STORAGE ACCOUNT' # optional. A new one will be generated if not provided.
46
+
47
+ azure.vm_user = 'PROVIDE A USERNAME' # defaults to 'vagrant' if not provided
48
+ azure.vm_password = 'PROVIDE A VALID PASSWORD' # min 8 characters. should contain a lower case letter, an uppercase letter, a number and a special character
49
+
50
+ azure.vm_name = 'PROVIDE A NAME FOR YOUR VIRTUAL MACHINE' # max 15 characters. contains letters, number and hyphens. can start with letters and can end with letters and numbers
51
+ azure.cloud_service_name = 'PROVIDE A NAME FOR YOUR CLOUD SERVICE' # same as vm_name. leave blank to auto-generate
52
+ azure.deployment_name = 'PROVIDE A NAME FOR YOUR DEPLOYMENT' # defaults to cloud_service_name
53
+ azure.vm_location = 'PROVIDE A LOCATION FOR VM' # e.g., West US
54
+ azure.ssh_private_key_file = 'PATH TO YOUR KEY FILE'
55
+ azure.ssh_certificate_file = 'PATH TO YOUR CERTIFICATE FILE'
56
+
57
+ # Provide the following values if creating a *Nix VM
58
+ azure.ssh_port = 'A VALID PUBLIC PORT'
59
+
60
+ # Provide the following values if creating a Windows VM
61
+ azure.winrm_transport = [ 'http', 'https' ] # this will open up winrm ports on both http (5985) and http (5986) ports
62
+ azure.winrm_https_port = 'A VALID PUBLIC PORT' # customize the winrm https port, instead of 5986
63
+ azure.winrm_http_port = 'A VALID PUBLIC PORT' # customize the winrm http port, insted of 5985
64
+
65
+ azure.tcp_endpoints = '3389:53389' # opens the Remote Desktop internal port that listens on public port 53389. Without this, you cannot RDP to a Windows VM.
66
+ end
67
+
68
+ config.ssh.username = 'YOUR USERNAME' # the one used to create the VM
69
+ config.ssh.password = 'YOUR PASSOWRD' # the one used to create the VM
70
+ end
71
+ ```
72
+
73
+ Now you can run
74
+
75
+ ```
76
+ C:\> vagrant up --provider=azure
77
+ ```
78
+
79
+ This will bring up an Azure VM as per the configuration options set above.
80
+
81
+ You can now either SSH (if its a *Nix VM) using ```vagrant ssh```, or RDP (if its a Windows VM) using ```vagrant rdp```.
82
+
83
+ Normally, a lot of this options, e.g., ```vm_image```, will be embedded in a box file and you just have to provide minimal options in the ```Vagrantfile```. Since, we're using a dummy box, there are no pre-configured defaults.
84
+
85
+ ## Azure Boxes
86
+
87
+ The vagrant-azure plugin provides the ability to use ```azure``` boxes with Vagrant. Please see the example box provided in [example_box/ directory](https://github.com/msopentech/vagrant-azure/tree/master/example_box) and follow the instructions there to build an ```azure``` box.
88
+
89
+ Please see [Vagrant Docs](http://docs.vagrantup.com/v2/) for more details.
8
90
 
9
91
  ## Configuration
92
+
93
+ The vagrant-azure provide exposes a few Azure specific configration options:
94
+
95
+ * `mgmt_certificate` - Your Azure Management certificate which has been uploaded to the Azure portal for your account.
96
+ * `mgmt_endpoint` - Azure Management endpoint. `https://management.core.windows.net`
97
+ * `subscription_id` - Your Azure Subscription ID.
98
+ * `storage_acct_name` - The Storage account to use when creating VMs.
99
+ * `vm_user` - The username to create the VM with. Defaults to `vagrant`.
100
+ * `vm_password`- The password to set for the user created with the VM.
101
+ * `vm_name` - The name of the created VM.
102
+ * `vm_size` - The size of the created VM.
103
+ * `cloud_service_name` - The name of the cloud service under which to create the VM.
104
+ * `deployment_name` - The name to give the deployment in the cloud service and add the VM to.
105
+ * `vm_location` - The location to create the cloud service, storage account.
106
+ * `ssh_private_key_file` - The private key file to use for SSH and if WinRM is enabled over HTTP/S.
107
+ * `ssh_certificate_file` - The certificate file to use for SSH and if WinRM is enabled over HTTP/S.
108
+ * `ssh_port` - To map the internal SSH port 22 to a different public port.
109
+ * `winrm_transport` - Enables or disables WinRm. Allowed values are `http` and `https`.
110
+ * `winrm_https_port` To map the internal WinRM https port 5986 to a different public port.
111
+ * `winrm_http_port` To map the internal WinRM http port 5985 to a different public port.
112
+ * `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`
113
+ *
114
+
115
+ ## New Commands for `azure` provider
116
+
117
+ The `azure` provider introduces the following new `vagrant` commands.
118
+
119
+ * `rdp` - To connect to a Windows VM using RDP. E.g.,
120
+ ```
121
+ C:\> vagrant up --provider=azure
122
+ ...
123
+ C:\> vagrant rdp
124
+ ```
Binary file
@@ -13,6 +13,8 @@ module VagrantPlugins
13
13
  autoload :Driver, lib_path.join('driver')
14
14
 
15
15
  require lib_path.join('provisioner/puppet')
16
+ require lib_path.join('provisioner/chef-solo')
17
+ require lib_path.join('provisioner/shell')
16
18
 
17
19
  # This returns the path to the source of this plugin.
18
20
  #
@@ -215,13 +215,14 @@ module VagrantPlugins
215
215
  next
216
216
  end
217
217
 
218
- b2.use RestartVM
219
- b2.use Call, WaitForState, :ReadyRole do |env2, b3|
218
+ b2.use action_halt
219
+ b2.use Call, WaitForState, :StoppedDeallocated do |env2, b3|
220
220
  if env2[:result]
221
221
  env2[:machine].id =~ /@/
222
- b3.use Message, I18n.t(
223
- 'vagrant_azure.vm_started', :name => $`
224
- )
222
+ b3.use Message, I18n.t('vagrant_azure.vm_stopped', name: $`)
223
+ b3.use action_up
224
+ else
225
+ b3.use Message, 'Not able to stop the machine. Please retry.'
225
226
  end
226
227
  end
227
228
  end
@@ -1,40 +1,49 @@
1
- #---------------------------------------------------------------------------
2
- # Copyright (c) Microsoft Open Technologies, Inc.
3
- # All Rights Reserved. Licensed under the Apache 2.0 License.
4
- #---------------------------------------------------------------------------
5
- module VagrantPlugins
6
- module WinAzure
7
- module Action
8
- class Provision < Vagrant::Action::Builtin::Provision
9
- # Override the core vagrant method and branch out for windows
10
- def run_provisioner(env)
11
- env[:ui].info "Provisioner: #{env[:provisioner].class.to_s}"
12
-
13
- env[:machine].id =~ /@/
14
- vm = env[:azure_vm_service].get_virtual_machine($`, $')
15
- env[:ui].info "VM OS: #{vm.os_type.to_sym}"
16
-
17
- if vm.os_type.to_sym == :Windows
18
- # Raise an error if we're not on a Windows Host.
19
- # Non-Windows OS will be supported once we move to WinRb/WinRm
20
- env[:ui].info "Is Host OS Windows?: #{Vagrant::Util::Platform.windows?}"
21
- raise 'Unsupported OS for Windows Provisioning' unless \
22
- Vagrant::Util::Platform.windows?
23
- env[:ui].info "Provisioning for Windows"
24
-
25
- # TODO: Add Shell, Chef-solo and other provisioners
26
- case env[:provisioner].class.to_s
27
- when "VagrantPlugins::Puppet::Provisioner::Puppet"
28
- VagrantPlugins::WinAzure::Provisioner::Puppet.new(
29
- env
30
- ).provision_for_windows
31
- end
32
- else
33
- env[:ui].info "Provisioning using SSH"
34
- env[:provisioner].provision
35
- end
36
- end
37
- end
38
- end
39
- end
40
- end
1
+ #---------------------------------------------------------------------------
2
+ # Copyright (c) Microsoft Open Technologies, Inc.
3
+ # All Rights Reserved. Licensed under the Apache 2.0 License.
4
+ #---------------------------------------------------------------------------
5
+
6
+ module VagrantPlugins
7
+ module WinAzure
8
+ module Action
9
+ class Provision < Vagrant::Action::Builtin::Provision
10
+ # Override the core vagrant method and branch out for windows
11
+ def run_provisioner(env)
12
+ env[:ui].info "Provisioner: #{env[:provisioner].class.to_s}"
13
+
14
+ env[:machine].id =~ /@/
15
+ vm = env[:azure_vm_service].get_virtual_machine($`, $')
16
+ env[:ui].info "VM OS: #{vm.os_type.to_sym}"
17
+
18
+ if vm.os_type.to_sym == :Windows
19
+ # Raise an error if we're not on a Windows Host.
20
+ # Non-Windows OS will be supported once we move to WinRb/WinRm
21
+ env[:ui].info "Is Host OS Windows?: #{Vagrant::Util::Platform.windows?}"
22
+ raise 'Unsupported OS for Windows Provisioning' unless \
23
+ Vagrant::Util::Platform.windows?
24
+ env[:ui].info "Provisioning for Windows"
25
+
26
+ # TODO: Add Shell, Chef-solo and other provisioners
27
+ case env[:provisioner].class.to_s
28
+ when "VagrantPlugins::Shell::Provisioner"
29
+ VagrantPlugins::WinAzure::Provisioner::Shell.new(
30
+ env
31
+ ).provision_for_windows
32
+ when "VagrantPlugins::Puppet::Provisioner::Puppet"
33
+ VagrantPlugins::WinAzure::Provisioner::Puppet.new(
34
+ env
35
+ ).provision_for_windows
36
+ when "VagrantPlugins::Chef::Provisioner::ChefSolo"
37
+ VagrantPlugins::WinAzure::Provisioner::ChefSolo.new(
38
+ env
39
+ ).provision_for_windows
40
+ end
41
+ else
42
+ env[:ui].info "Provisioning using SSH"
43
+ env[:provisioner].provision
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
@@ -1,111 +1,111 @@
1
- #---------------------------------------------------------------------------
2
- # Copyright (c) Microsoft Open Technologies, Inc.
3
- # All Rights Reserved. Licensed under the Apache 2.0 License.
4
- #--------------------------------------------------------------------------
5
- require 'log4r'
6
- require 'json'
7
- require 'azure'
8
-
9
- require 'vagrant/util/retryable'
10
-
11
- module VagrantPlugins
12
- module WinAzure
13
- module Action
14
- class RunInstance
15
- include Vagrant::Util::Retryable
16
-
17
- def initialize(app, env)
18
- @app = app
19
- @logger = Log4r::Logger.new('vagrant_azure::action::run_instance')
20
- end
21
-
22
- def call(env)
23
- config = env[:machine].provider_config
24
-
25
- # Add the mandatory parameters and options
26
- params = {
27
- vm_name: config.vm_name,
28
- vm_user: config.vm_user,
29
- image: config.vm_image
30
- }
31
-
32
- options = {
33
- cloud_service_name: config.cloud_service_name
34
- }
35
-
36
-
37
- # Add the optional parameters and options if not nil
38
- params[:password] = config.vm_password unless config.vm_password.nil?
39
- params[:location] = config.vm_location unless config.vm_location.nil?
40
- params[:affinity_group] = config.vm_affinity_group unless \
41
- config.vm_affinity_group.nil?
42
-
43
- options[:storage_account_name] = config.storage_acct_name unless \
44
- config.storage_acct_name.nil?
45
- options[:deployment_name] = config.deployment_name unless \
46
- config.deployment_name.nil?
47
- options[:tcp_endpoints] = config.tcp_endpoints unless \
48
- config.tcp_endpoints.nil?
49
- options[:private_key_file] = config.ssh_private_key_file unless \
50
- config.ssh_private_key_file.nil?
51
- options[:certificate_file] = config.ssh_certificate_file unless \
52
- config.ssh_certificate_file.nil?
53
- options[:ssh_port] = config.ssh_port unless \
54
- config.ssh_port.nil?
55
- options[:vm_size] = config.vm_size unless \
56
- config.vm_size.nil?
57
- options[:winrm_transport] = config.winrm_transport unless \
58
- config.winrm_transport.nil?
59
- options[:winrm_http_port] = config.winrm_http_port unless \
60
- config.winrm_http_port.nil?
61
- options[:winrm_https_port] = config.winrm_https_port unless \
62
- config.winrm_https_port.nil?
63
- options[:availability_set_name] = config.availability_set_name unless \
64
- config.availability_set_name.nil?
65
-
66
- add_role = false
67
-
68
- env[:ui].info(params.inspect)
69
- env[:ui].info(options.inspect)
70
-
71
- # Check if the cloud service exists and if yes, does it contain
72
- # a deployment.
73
- if config.cloud_service_name && !config.cloud_service_name.empty?
74
- begin
75
- cloud_service = ManagementHttpRequest.new(
76
- :get,
77
- "/services/hostedservices/#{config.cloud_service_name}?embed-detail=true"
78
- ).call
79
-
80
- deployments = cloud_service.css 'HostedService Deployments Deployment'
81
-
82
- # Lets see if any deployments exist. Set add_role = true if yes.
83
- # We're not worried about deployment slots, because the SDK has
84
- # hard coded 'Production' as deployment slot and you can have only
85
- # one deployment per deployment slot.
86
- add_role = deployments.length == 1
87
- rescue Exception => e
88
- add_role = false
89
- end
90
- end
91
- env[:ui].info("Add Role? - #{add_role}")
92
-
93
- server = env[:azure_vm_service].create_virtual_machine(
94
- params, options, add_role
95
- )
96
-
97
- # TODO: Exception/Error Handling
98
-
99
- if server.instance_of? String
100
- env[:ui].info "Server not created. Error is: #{server}"
101
- raise "#{server}"
102
- end
103
-
104
- env[:machine].id = "#{server.vm_name}@#{server.cloud_service_name}"
105
-
106
- @app.call(env)
107
- end
108
- end
109
- end
110
- end
111
- end
1
+ #---------------------------------------------------------------------------
2
+ # Copyright (c) Microsoft Open Technologies, Inc.
3
+ # All Rights Reserved. Licensed under the Apache 2.0 License.
4
+ #--------------------------------------------------------------------------
5
+ require 'log4r'
6
+ require 'json'
7
+ require 'azure'
8
+
9
+ require 'vagrant/util/retryable'
10
+
11
+ module VagrantPlugins
12
+ module WinAzure
13
+ module Action
14
+ class RunInstance
15
+ include Vagrant::Util::Retryable
16
+
17
+ def initialize(app, env)
18
+ @app = app
19
+ @logger = Log4r::Logger.new('vagrant_azure::action::run_instance')
20
+ end
21
+
22
+ def call(env)
23
+ config = env[:machine].provider_config
24
+
25
+ # Add the mandatory parameters and options
26
+ params = {
27
+ vm_name: config.vm_name,
28
+ vm_user: config.vm_user,
29
+ image: config.vm_image
30
+ }
31
+
32
+ options = {
33
+ cloud_service_name: config.cloud_service_name
34
+ }
35
+
36
+
37
+ # Add the optional parameters and options if not nil
38
+ params[:password] = config.vm_password unless config.vm_password.nil?
39
+ params[:location] = config.vm_location unless config.vm_location.nil?
40
+ params[:affinity_group] = config.vm_affinity_group unless \
41
+ config.vm_affinity_group.nil?
42
+
43
+ options[:storage_account_name] = config.storage_acct_name unless \
44
+ config.storage_acct_name.nil?
45
+ options[:deployment_name] = config.deployment_name unless \
46
+ config.deployment_name.nil?
47
+ options[:tcp_endpoints] = config.tcp_endpoints unless \
48
+ config.tcp_endpoints.nil?
49
+ options[:private_key_file] = config.ssh_private_key_file unless \
50
+ config.ssh_private_key_file.nil?
51
+ options[:certificate_file] = config.ssh_certificate_file unless \
52
+ config.ssh_certificate_file.nil?
53
+ options[:ssh_port] = config.ssh_port unless \
54
+ config.ssh_port.nil?
55
+ options[:vm_size] = config.vm_size unless \
56
+ config.vm_size.nil?
57
+ options[:winrm_transport] = config.winrm_transport unless \
58
+ config.winrm_transport.nil?
59
+ options[:winrm_http_port] = config.winrm_http_port unless \
60
+ config.winrm_http_port.nil?
61
+ options[:winrm_https_port] = config.winrm_https_port unless \
62
+ config.winrm_https_port.nil?
63
+ options[:availability_set_name] = config.availability_set_name unless \
64
+ config.availability_set_name.nil?
65
+
66
+ add_role = false
67
+
68
+ env[:ui].info(params.inspect)
69
+ env[:ui].info(options.inspect)
70
+
71
+ # Check if the cloud service exists and if yes, does it contain
72
+ # a deployment.
73
+ if config.cloud_service_name && !config.cloud_service_name.empty?
74
+ begin
75
+ cloud_service = ManagementHttpRequest.new(
76
+ :get,
77
+ "/services/hostedservices/#{config.cloud_service_name}?embed-detail=true"
78
+ ).call
79
+
80
+ deployments = cloud_service.css 'HostedService Deployments Deployment'
81
+
82
+ # Lets see if any deployments exist. Set add_role = true if yes.
83
+ # We're not worried about deployment slots, because the SDK has
84
+ # hard coded 'Production' as deployment slot and you can have only
85
+ # one deployment per deployment slot.
86
+ add_role = deployments.length == 1
87
+ rescue Exception => e
88
+ add_role = false
89
+ end
90
+ end
91
+ env[:ui].info("Add Role? - #{add_role}")
92
+
93
+ server = env[:azure_vm_service].create_virtual_machine(
94
+ params, options, add_role
95
+ )
96
+
97
+ # TODO: Exception/Error Handling
98
+
99
+ if server.instance_of? String
100
+ env[:ui].info "Server not created. Error is: #{server}"
101
+ raise "#{server}"
102
+ end
103
+
104
+ env[:machine].id = "#{server.vm_name}@#{server.cloud_service_name}"
105
+
106
+ @app.call(env)
107
+ end
108
+ end
109
+ end
110
+ end
111
+ end