Class: VagrantPlugins::Azure::Config
- Inherits:
-
Object
- Object
- VagrantPlugins::Azure::Config
- Includes:
- Util::ManagedImagedHelper
- Defined in:
- lib/vagrant-azure/config.rb
Constant Summary
Constants included from Util::ManagedImagedHelper
Util::ManagedImagedHelper::ID_REGEX
Instance Attribute Summary collapse
-
#admin_password ⇒ String
(Optional - Required for Windows) The admin username for Windows templates – ENV.
-
#admin_username ⇒ String
(Optional - requrired for Windows) The admin username for Windows templates – ENV.
-
#availability_set_name ⇒ String
(Optional) Name of the virtual machine image.
-
#client_id ⇒ String
The Azure Active Directory Application Client ID – ENV.
-
#client_secret ⇒ String
The Azure Active Directory Application Client Secret – ENV.
-
#data_disks ⇒ Array
(Optional) Array of data disks to attach to the VM.
-
#deployment_template ⇒ String
(Optional - Required for Windows) The admin username for Windows templates – ENV.
-
#dns_name ⇒ String
(Optional) DNS Name prefix of the virtual machine Uses value of vm_name if not specified.
-
#endpoint ⇒ String
(Optional) The Azure Management API endpoint – default ‘management.azure.com’ seconds – ENV.
-
#instance_check_interval ⇒ Fixnum
(Optional) The interval to wait for checking an instance’s state – default 2 seconds.
-
#instance_ready_timeout ⇒ Fixnum
(Optional) The timeout to wait for an instance to become ready – default 120 seconds.
-
#location ⇒ String
(Optional) Azure location to build the VM – defaults to ‘westus’.
-
#nsg_name ⇒ String
(Optional) Network Security Group Name prefix of the virtual machine.
-
#resource_group_name ⇒ String
(Optional) Name of the resource group to use.
-
#subnet_name ⇒ String
(Optional) Name of the virtual network subnet resource.
-
#subscription_id ⇒ String
The Azure Subscription ID to use – ENV.
-
#tcp_endpoints ⇒ String
(Optional) TCP endpoints to open up for the VM.
-
#tenant_id ⇒ String
The Azure Active Directory Tenant ID – ENV.
-
#virtual_network_name ⇒ String
(Optional) Name of the virtual network resource.
-
#vm_image_urn ⇒ String
(Optional) Name of the virtual machine image URN to use – defaults to ‘canonical:ubuntuserver:16.04.0-DAILY-LTS:latest’.
-
#vm_managed_image_id ⇒ String
(Optional) The Managed Image Id which will be used to build the VM (like: /subscriptions/sub_id/resourceGroups/group_name/providers/Microsoft.Compute/images/image_name) – default nil.
-
#vm_name ⇒ String
(Optional) Name of the virtual machine.
-
#vm_operating_system ⇒ String
(Optional unless using custom image) OS of the custom image.
-
#vm_password ⇒ String
Password for the VM – This is not recommended for *nix deployments.
-
#vm_size ⇒ String
(Optional) VM size to be used – defaults to ‘Standard_D1’.
-
#vm_storage_account_type ⇒ String
(Optional) Storage account type to be used – defaults to ‘Premium_LRS’.
-
#vm_vhd_uri ⇒ String
(Optional) Custom OS Image URI (like: mystorage1.blob.core.windows.net/vhds/myosdisk1.vhd) – default nil.
-
#wait_for_destroy ⇒ String
(Optional) Wait for all resources to be deleted prior to completing Vagrant destroy – default false.
-
#winrm_install_self_signed_cert ⇒ Bool
(Optional) Whether to automatically install a self-signed cert and open the firewall port for winrm over https – default true.
Instance Method Summary collapse
- #finalize! ⇒ Object
-
#initialize ⇒ Config
constructor
A new instance of Config.
- #validate(machine) ⇒ Object
Methods included from Util::ManagedImagedHelper
#image_id_captures, #image_id_matches, #valid_image_id?
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 |
# File 'lib/vagrant-azure/config.rb', line 185 def initialize @tenant_id = UNSET_VALUE @client_id = UNSET_VALUE @client_secret = UNSET_VALUE @endpoint = UNSET_VALUE @subscription_id = UNSET_VALUE @resource_group_name = UNSET_VALUE @location = UNSET_VALUE @vm_name = UNSET_VALUE @vm_password = UNSET_VALUE @vm_image_urn = UNSET_VALUE @vm_vhd_uri = UNSET_VALUE @vm_image_reference_id = UNSET_VALUE = UNSET_VALUE @vm_managed_image_id = UNSET_VALUE @data_disks = UNSET_VALUE @virtual_network_name = UNSET_VALUE @subnet_name = UNSET_VALUE @dsn_name = UNSET_VALUE @nsg_name = UNSET_VALUE @tcp_endpoints = UNSET_VALUE @vm_size = UNSET_VALUE @vm_storage_account_type = UNSET_VALUE @availability_set_name = UNSET_VALUE @instance_ready_timeout = UNSET_VALUE @instance_check_interval = UNSET_VALUE @admin_username = UNSET_VALUE @admin_password = UNSET_VALUE @winrm_install_self_signed_cert = UNSET_VALUE @deployment_template = UNSET_VALUE @wait_for_destroy = UNSET_VALUE end |
Instance Attribute Details
#admin_password ⇒ String
(Optional - Required for Windows) The admin username for Windows templates – ENV
167 168 169 |
# File 'lib/vagrant-azure/config.rb', line 167 def admin_password @admin_password end |
#admin_username ⇒ String
(Optional - requrired for Windows) The admin username for Windows templates – ENV
162 163 164 |
# File 'lib/vagrant-azure/config.rb', line 162 def admin_username @admin_username end |
#availability_set_name ⇒ String
(Optional) Name of the virtual machine image
142 143 144 |
# File 'lib/vagrant-azure/config.rb', line 142 def availability_set_name @availability_set_name end |
#client_id ⇒ String
The Azure Active Directory Application Client ID – ENV
21 22 23 |
# File 'lib/vagrant-azure/config.rb', line 21 def client_id @client_id end |
#client_secret ⇒ String
The Azure Active Directory Application Client Secret – ENV
26 27 28 |
# File 'lib/vagrant-azure/config.rb', line 26 def client_secret @client_secret end |
#data_disks ⇒ Array
(Optional) Array of data disks to attach to the VM
sample of creating empty data disk
{
name: "mydatadisk1",
size_gb: 30
}
sample of attaching an existing VHD as a data disk
{
name: "mydatadisk2",
vhd_uri: "http://mystorage.blob.core.windows.net/vhds/mydatadisk2.vhd"
},
sample of attaching a data disk from image
{
name: "mydatadisk3",
vhd_uri: "http://mystorage.blob.core.windows.net/vhds/mydatadisk3.vhd",
image: "http: //storagename.blob.core.windows.net/vhds/VMImageName-datadisk.vhd"
}
122 123 124 |
# File 'lib/vagrant-azure/config.rb', line 122 def data_disks @data_disks end |
#deployment_template ⇒ String
(Optional - Required for Windows) The admin username for Windows templates – ENV
177 178 179 |
# File 'lib/vagrant-azure/config.rb', line 177 def deployment_template @deployment_template end |
#dns_name ⇒ String
(Optional) DNS Name prefix of the virtual machine Uses value of vm_name if not specified. Note: this must conform to the following regular expression:
^[a-z][a-z0-9-]{1,61}[a-z0-9]
Therefore this field mustbe set if vm_name has capital letters (for ex.)
57 58 59 |
# File 'lib/vagrant-azure/config.rb', line 57 def dns_name @dns_name end |
#endpoint ⇒ String
(Optional) The Azure Management API endpoint – default ‘management.azure.com’ seconds – ENV.
157 158 159 |
# File 'lib/vagrant-azure/config.rb', line 157 def endpoint @endpoint end |
#instance_check_interval ⇒ Fixnum
(Optional) The interval to wait for checking an instance’s state – default 2 seconds.
152 153 154 |
# File 'lib/vagrant-azure/config.rb', line 152 def instance_check_interval @instance_check_interval end |
#instance_ready_timeout ⇒ Fixnum
(Optional) The timeout to wait for an instance to become ready – default 120 seconds.
147 148 149 |
# File 'lib/vagrant-azure/config.rb', line 147 def instance_ready_timeout @instance_ready_timeout end |
#location ⇒ String
(Optional) Azure location to build the VM – defaults to ‘westus’
41 42 43 |
# File 'lib/vagrant-azure/config.rb', line 41 def location @location end |
#nsg_name ⇒ String
(Optional) Network Security Group Name prefix of the virtual machine
62 63 64 |
# File 'lib/vagrant-azure/config.rb', line 62 def nsg_name @nsg_name end |
#resource_group_name ⇒ String
(Optional) Name of the resource group to use.
36 37 38 |
# File 'lib/vagrant-azure/config.rb', line 36 def resource_group_name @resource_group_name end |
#subnet_name ⇒ String
(Optional) Name of the virtual network subnet resource
132 133 134 |
# File 'lib/vagrant-azure/config.rb', line 132 def subnet_name @subnet_name end |
#subscription_id ⇒ String
The Azure Subscription ID to use – ENV
31 32 33 |
# File 'lib/vagrant-azure/config.rb', line 31 def subscription_id @subscription_id end |
#tcp_endpoints ⇒ String
(Optional) TCP endpoints to open up for the VM
137 138 139 |
# File 'lib/vagrant-azure/config.rb', line 137 def tcp_endpoints @tcp_endpoints end |
#tenant_id ⇒ String
The Azure Active Directory Tenant ID – ENV
16 17 18 |
# File 'lib/vagrant-azure/config.rb', line 16 def tenant_id @tenant_id end |
#virtual_network_name ⇒ String
(Optional) Name of the virtual network resource
127 128 129 |
# File 'lib/vagrant-azure/config.rb', line 127 def virtual_network_name @virtual_network_name end |
#vm_image_urn ⇒ String
(Optional) Name of the virtual machine image URN to use – defaults to ‘canonical:ubuntuserver:16.04.0-DAILY-LTS:latest’. See: azure.microsoft.com/en-us/documentation/articles/virtual-machines-linux-cli-ps-findimage/
82 83 84 |
# File 'lib/vagrant-azure/config.rb', line 82 def vm_image_urn @vm_image_urn end |
#vm_managed_image_id ⇒ String
(Optional) The Managed Image Id which will be used to build the VM (like: /subscriptions/sub_id/resourceGroups/group_name/providers/Microsoft.Compute/images/image_name) – default nil.
93 94 95 |
# File 'lib/vagrant-azure/config.rb', line 93 def vm_managed_image_id @vm_managed_image_id end |
#vm_name ⇒ String
(Optional) Name of the virtual machine
46 47 48 |
# File 'lib/vagrant-azure/config.rb', line 46 def vm_name @vm_name end |
#vm_operating_system ⇒ String
(Optional unless using custom image) OS of the custom image
98 99 100 |
# File 'lib/vagrant-azure/config.rb', line 98 def end |
#vm_password ⇒ String
Password for the VM – This is not recommended for *nix deployments
67 68 69 |
# File 'lib/vagrant-azure/config.rb', line 67 def vm_password @vm_password end |
#vm_size ⇒ String
(Optional) VM size to be used – defaults to ‘Standard_D1’. See: azure.microsoft.com/en-us/documentation/articles/virtual-machines-linux-sizes/
72 73 74 |
# File 'lib/vagrant-azure/config.rb', line 72 def vm_size @vm_size end |
#vm_storage_account_type ⇒ String
(Optional) Storage account type to be used – defaults to ‘Premium_LRS’. Alt value is ‘Standard_LRS’ See: docs.microsoft.com/en-us/azure/storage/storage-about-disks-and-vhds-linux
77 78 79 |
# File 'lib/vagrant-azure/config.rb', line 77 def vm_storage_account_type @vm_storage_account_type end |
#vm_vhd_uri ⇒ String
(Optional) Custom OS Image URI (like: mystorage1.blob.core.windows.net/vhds/myosdisk1.vhd) – default nil.
87 88 89 |
# File 'lib/vagrant-azure/config.rb', line 87 def vm_vhd_uri @vm_vhd_uri end |
#wait_for_destroy ⇒ String
(Optional) Wait for all resources to be deleted prior to completing Vagrant destroy – default false.
182 183 184 |
# File 'lib/vagrant-azure/config.rb', line 182 def wait_for_destroy @wait_for_destroy end |
#winrm_install_self_signed_cert ⇒ Bool
(Optional) Whether to automatically install a self-signed cert and open the firewall port for winrm over https – default true
172 173 174 |
# File 'lib/vagrant-azure/config.rb', line 172 def winrm_install_self_signed_cert @winrm_install_self_signed_cert end |
Instance Method Details
#finalize! ⇒ Object
218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 |
# File 'lib/vagrant-azure/config.rb', line 218 def finalize! @endpoint = (ENV['AZURE_MANAGEMENT_ENDPOINT'] || 'https://management.azure.com') if @endpoint == UNSET_VALUE @subscription_id = ENV['AZURE_SUBSCRIPTION_ID'] if @subscription_id == UNSET_VALUE @tenant_id = ENV['AZURE_TENANT_ID'] if @tenant_id == UNSET_VALUE @client_id = ENV['AZURE_CLIENT_ID'] if @client_id == UNSET_VALUE @client_secret = ENV['AZURE_CLIENT_SECRET'] if @client_secret == UNSET_VALUE @resource_group_name = Haikunator.haikunate(100) if @resource_group_name == UNSET_VALUE @vm_name = Haikunator.haikunate(100) if @vm_name == UNSET_VALUE @vm_size = 'Standard_DS2_v2' if @vm_size == UNSET_VALUE @vm_password = nil if @vm_password == UNSET_VALUE @vm_image_urn = 'canonical:ubuntuserver:16.04.0-LTS:latest' if @vm_image_urn == UNSET_VALUE @vm_vhd_uri = nil if @vm_vhd_uri == UNSET_VALUE @vm_vhd_storage_account_id = nil if @vm_vhd_storage_account_id == UNSET_VALUE = nil if == UNSET_VALUE @vm_managed_image_id = nil if @vm_managed_image_id == UNSET_VALUE @data_disks = [] if @data_disks == UNSET_VALUE @location = 'westus' if @location == UNSET_VALUE @virtual_network_name = nil if @virtual_network_name == UNSET_VALUE @subnet_name = nil if @subnet_name == UNSET_VALUE @dns_name = nil if @dns_name == UNSET_VALUE @nsg_name = nil if @nsg_name == UNSET_VALUE @tcp_endpoints = nil if @tcp_endpoints == UNSET_VALUE @vm_storage_account_type = 'Premium_LRS' if @vm_storage_account_type == UNSET_VALUE @availability_set_name = nil if @availability_set_name == UNSET_VALUE @instance_ready_timeout = 120 if @instance_ready_timeout == UNSET_VALUE @instance_check_interval = 2 if @instance_check_interval == UNSET_VALUE @admin_username = (ENV['AZURE_VM_ADMIN_USERNAME'] || 'vagrant') if @admin_username == UNSET_VALUE @admin_password = (ENV['AZURE_VM_ADMIN_PASSWORD'] || '$Vagrant(0)') if @admin_password == UNSET_VALUE @winrm_install_self_signed_cert = true if @winrm_install_self_signed_cert == UNSET_VALUE @wait_for_destroy = false if @wait_for_destroy == UNSET_VALUE end |
#validate(machine) ⇒ Object
255 256 257 258 259 260 261 262 263 264 265 266 267 |
# File 'lib/vagrant-azure/config.rb', line 255 def validate(machine) errors = _detected_errors errors << I18n.t("vagrant_azure.custom_image_os_error") if !@vm_vhd_uri.nil? && .nil? errors << I18n.t("vagrant_azure.vhd_and_managed_image_error") if !@vm_vhd_uri.nil? && !@vm_managed_image_id.nil? errors << I18n.t("vagrant_azure.manage_image_id_format_error") if !@vm_managed_image_id.nil? && !valid_image_id?(@vm_managed_image_id) # Azure connection properties related validation. errors << I18n.t('vagrant_azure.subscription_id.required') if @subscription_id.nil? errors << I18n.t('vagrant_azure.mgmt_endpoint.required') if @endpoint.nil? errors << I18n.t('vagrant_azure.auth.required') if @tenant_id.nil? || @client_secret.nil? || @client_id.nil? { 'Microsoft Azure Provider' => errors } end |