This commit is contained in:
David Justice 2017-04-19 14:33:38 -07:00
Родитель df70a367b6
Коммит 7caa2b2aa1
4 изменённых файлов: 108 добавлений и 39 удалений

10
.travis.yml Normal file
Просмотреть файл

@ -0,0 +1,10 @@
sudo: false
language: ruby
rvm:
- 2.2.5p319
deploy:
provider: rubygems
api_key:
secure: secure: "ThMTLeJ1E2dLLAK1AIokfE+0GyfCKwaAstxETI/qFkOwL21REi6dgTfPIrBpgmrYATb/YgkgIf6Zl46R7vx9/dtgIGBmX7AXT3zsR38P3zfOGy5PzHGGK72ZmkC5UFSBsnQl5J0qQsUEMQfEy2g7dwn1d9aFLKhvnFblNHt4x5c="
on:
tags: true

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

@ -0,0 +1,43 @@
# Linux Machine with Empty Data Disks
This scenario will build an Ubuntu 16.04 machine with data disks attached to the virtual machine.
To see more information about this scenario, see [Prepare an Ubuntu virtual machine for Azure](https://docs.microsoft.com/en-us/azure/virtual-machines/linux/create-upload-ubuntu)
Before you attempt this scenario, ensure you have followed the [getting started docs](../../readme.md#getting-started).
If you wanted to build a more customized image, you could do the same with your own VHD manually by following these
[instructions](https://docs.microsoft.com/en-us/azure/virtual-machines/linux/create-upload-ubuntu?toc=%2fazure%2fvirtual-machines%2flinux%2ftoc.json#manual-steps).
## Vagrant up
We will set this up with Azure CLI and then run Vagrant after we've provisioned the needed Azure resources.
- Login to Azure CLI (if not already logged in)
```sh
az login
```
- Create a resource group for your VHDs (assuming westus)
```sh
az group create -n vagrantimages -l westus
```
- Create a storage account in the region you'd like to deploy
```sh
# insert your own name for the storage account DNS name (-n)
az storage account create -g vagrantimages -n vagrantimagesXXXX --sku Standard_LRS -l westus
```
- Download and unzip the VHD from Ubuntu
```sh
wget -qO- -O tmp.zip http://cloud-images.ubuntu.com/releases/xenial/release/ubuntu-16.04-server-cloudimg-amd64-disk1.vhd.zip && unzip tmp.zip && rm tmp.zip
```
- Upload the VHD to your storage account in the vhds container
```sh
conn_string=$(az storage account show-connection-string -g vagrantimages -n vagrantimagesXXXX -o tsv)
az storage container create -n vhds --connection-string $conn_string
az storage container create -n vhds vagrantimagesXXXX
az storage blob upload -c vhds -n xenial-server-cloudimg-amd64-disk1.vhd -f xenial-server-cloudimg-amd64-disk1.vhd --connection-string $conn_string
```
- Update Vagrantfile with the URI of your uploaded blob (`azure.vm_vhd_uri`).
- Vagrant up
```bash
vagrant up --provider=azure
```
To clean up, run `vagrant destroy`

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

@ -35,8 +35,8 @@ module VagrantPlugins
expect(subject["parameters"].count).to eq(10)
end
it "should have 17 variables" do
expect(subject["variables"].count).to eq(17)
it "should have 14 variables" do
expect(subject["variables"].count).to eq(14)
end
it "should have 5 resources" do
@ -45,9 +45,9 @@ module VagrantPlugins
end
describe "resources" do
describe "the virtual machine" do
describe "virtual machine" do
let(:subject) {
render(options)["resources"].detect { |vm| vm["type"] == "Microsoft.Compute/virtualMachines" }
render(options)["resources"].detect {|vm| vm["type"] == "Microsoft.Compute/virtualMachines"}
}
it "should depend on 1 resources without an AV Set" do
@ -57,13 +57,57 @@ module VagrantPlugins
describe "with AV Set" do
let(:subject) {
template = render(options.merge(availability_set_name: "avSet"))
template["resources"].detect { |vm| vm["type"] == "Microsoft.Compute/virtualMachines" }
template["resources"].detect {|vm| vm["type"] == "Microsoft.Compute/virtualMachines"}
}
it "should depend on 2 resources with an AV Set" do
expect(subject["dependsOn"].count).to eq(2)
end
end
describe "with managed disk reference" do
let(:subject) {
template = render(options.merge(vm_managed_image_id: "image_id"))
template["resources"].detect {|vm| vm["type"] == "Microsoft.Compute/virtualMachines"}
}
it "should have an image reference id set to image_id" do
expect(subject["properties"]["storageProfile"]["imageReference"]["id"]).to eq("image_id")
end
end
end
describe "managed image" do
let(:subject) {
render(options)["resources"].detect {|vm| vm["type"] == "Microsoft.Compute/images"}
}
describe "with custom vhd" do
let(:vhd_uri_options) {
options.merge(
vhd_uri: "https://my_image.vhd",
operating_system: "Foo"
)
}
let(:subject) {
render(vhd_uri_options)["resources"].detect {|vm| vm["type"] == "Microsoft.Compute/images"}
}
it "should exist" do
expect(subject).not_to be_nil
end
it "should set the blob_uri" do
expect(subject["properties"]["storageProfile"]["osDisk"]["blobUri"]).to eq(vhd_uri_options[:vhd_uri])
end
it "should set the osType" do
expect(subject["properties"]["storageProfile"]["osDisk"]["osType"]).to eq(vhd_uri_options[:operating_system])
end
end
it "should not exist" do
expect(subject).to be_nil
end
end
end
@ -102,9 +146,9 @@ module VagrantPlugins
describe "variables" do
let(:keys) {
%w(storageAccountName location osDiskName addressPrefix subnetPrefix vmStorageAccountContainerName nicName
publicIPAddressName publicIPAddressType networkSecurityGroupName sshKeyPath vnetID subnetRef apiVersion
singleQuote doubleQuote managedOSDiskName)
%w(location addressPrefix subnetPrefix nicName publicIPAddressName publicIPAddressType
networkSecurityGroupName sshKeyPath vnetID subnetRef apiVersion
singleQuote doubleQuote managedImageName)
}
let(:subject) {

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

@ -38,7 +38,7 @@
{
"name": "ssh_rule",
"properties": {
"description": "Locks inbound down to ssh default port 22.",
"description": "Enable inbound down to ssh default port 22.",
"protocol": "Tcp",
"sourcePortRange": "*",
"destinationPortRange": "22",
@ -54,7 +54,7 @@
,{
"name": "custom_rule_inbound_<%= index %>",
"properties": {
"description": "Custom opened ports.",
"description": "Enable inbound custom ports.",
"protocol": "*",
"sourcePortRange": "<%= ports %>",
"destinationPortRange": "<%= ports %>",
@ -68,7 +68,7 @@
{
"name": "custom_rule_outbound_<%= index %>",
"properties": {
"description": "Custom opened ports.",
"description": "Enabled outbound custom ports.",
"protocol": "*",
"sourcePortRange": "<%= ports %>",
"destinationPortRange": "<%= ports %>",
@ -80,34 +80,6 @@
}
}
<% end %>
,{
"name": "all_in",
"properties": {
"description": "Enable Inbound RDP",
"protocol": "*",
"sourcePortRange": "*",
"destinationPortRange": "*",
"sourceAddressPrefix": "*",
"destinationAddressPrefix": "*",
"access": "Allow",
"priority": 100,
"direction": "Inbound"
}
},
{
"name": "all_out",
"properties": {
"description": "Enable Inbound RDP",
"protocol": "*",
"sourcePortRange": "*",
"destinationPortRange": "*",
"sourceAddressPrefix": "*",
"destinationAddressPrefix": "*",
"access": "Allow",
"priority": 101,
"direction": "Outbound"
}
}
]
}
}