-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
azurerm_virtual_machine
- making admin_password
optional for Linux VM's
#154
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,6 +34,25 @@ func TestAccAzureRMVirtualMachine_basicLinuxMachine(t *testing.T) { | |
}) | ||
} | ||
|
||
func TestAccAzureRMVirtualMachine_basicLinuxMachineSSHOnly(t *testing.T) { | ||
var vm compute.VirtualMachine | ||
ri := acctest.RandInt() | ||
config := testAccAzureRMVirtualMachine_basicLinuxMachineSSHOnly(ri) | ||
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
Providers: testAccProviders, | ||
CheckDestroy: testCheckAzureRMVirtualMachineDestroy, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: config, | ||
Check: resource.ComposeTestCheckFunc( | ||
testCheckAzureRMVirtualMachineExists("azurerm_virtual_machine.test", &vm), | ||
), | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func TestAccAzureRMVirtualMachine_basicLinuxMachine_managedDisk_explicit(t *testing.T) { | ||
var vm compute.VirtualMachine | ||
ri := acctest.RandInt() | ||
|
@@ -1005,6 +1024,101 @@ resource "azurerm_virtual_machine" "test" { | |
} | ||
` | ||
|
||
func testAccAzureRMVirtualMachine_basicLinuxMachineSSHOnly(rInt int) string { | ||
return fmt.Sprintf(` | ||
|
||
resource "azurerm_resource_group" "test" { | ||
name = "acctestRG-%d" | ||
location = "West US 2" | ||
} | ||
|
||
resource "azurerm_virtual_network" "test" { | ||
name = "acctvn-%d" | ||
address_space = ["10.0.0.0/16"] | ||
location = "West US 2" | ||
resource_group_name = "${azurerm_resource_group.test.name}" | ||
} | ||
|
||
resource "azurerm_subnet" "test" { | ||
name = "acctsub-%d" | ||
resource_group_name = "${azurerm_resource_group.test.name}" | ||
virtual_network_name = "${azurerm_virtual_network.test.name}" | ||
address_prefix = "10.0.2.0/24" | ||
} | ||
|
||
resource "azurerm_network_interface" "test" { | ||
name = "acctni-%d" | ||
location = "West US 2" | ||
resource_group_name = "${azurerm_resource_group.test.name}" | ||
|
||
ip_configuration { | ||
name = "testconfiguration1" | ||
subnet_id = "${azurerm_subnet.test.id}" | ||
private_ip_address_allocation = "dynamic" | ||
} | ||
} | ||
|
||
resource "azurerm_storage_account" "test" { | ||
name = "accsa%d" | ||
resource_group_name = "${azurerm_resource_group.test.name}" | ||
location = "West US 2" | ||
account_type = "Standard_LRS" | ||
|
||
tags { | ||
environment = "staging" | ||
} | ||
} | ||
|
||
resource "azurerm_storage_container" "test" { | ||
name = "vhds" | ||
resource_group_name = "${azurerm_resource_group.test.name}" | ||
storage_account_name = "${azurerm_storage_account.test.name}" | ||
container_access_type = "private" | ||
} | ||
|
||
resource "azurerm_virtual_machine" "test" { | ||
name = "acctvm-%d" | ||
location = "West US 2" | ||
resource_group_name = "${azurerm_resource_group.test.name}" | ||
network_interface_ids = ["${azurerm_network_interface.test.id}"] | ||
vm_size = "Standard_D1_v2" | ||
|
||
storage_image_reference { | ||
publisher = "Canonical" | ||
offer = "UbuntuServer" | ||
sku = "14.04.2-LTS" | ||
version = "latest" | ||
} | ||
|
||
storage_os_disk { | ||
name = "myosdisk1" | ||
vhd_uri = "${azurerm_storage_account.test.primary_blob_endpoint}${azurerm_storage_container.test.name}/myosdisk1.vhd" | ||
caching = "ReadWrite" | ||
create_option = "FromImage" | ||
disk_size_gb = "45" | ||
} | ||
|
||
os_profile { | ||
computer_name = "hn%d" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there any special meaning behind the two letters There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. copied it from the example above, but presumably There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, it's hn - we kept this short as Windows host names cannot be more than 16 characters |
||
admin_username = "testadmin" | ||
} | ||
|
||
os_profile_linux_config { | ||
disable_password_authentication = true | ||
ssh_keys { | ||
path = "/home/testadmin/.ssh/authorized_keys" | ||
key_data = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQCfGyt5W1eJVpDIxlyvAWO594j/azEGohmlxYe7mgSfmUCWjuzILI6nHuHbxhpBDIZJhQ+JAeduXpii61dmThbI89ghGMhzea0OlT3p12e093zqa4goB9g40jdNKmJArER3pMVqs6hmv8y3GlUNkMDSmuoyI8AYzX4n26cUKZbwXQ== mk@mk3" | ||
} | ||
} | ||
|
||
tags { | ||
environment = "Production" | ||
cost-center = "Ops" | ||
} | ||
} | ||
`, rInt, rInt, rInt, rInt, rInt, rInt, rInt) | ||
} | ||
|
||
var testAccAzureRMVirtualMachine_basicLinuxMachine_managedDisk_explicit = ` | ||
resource "azurerm_resource_group" "test" { | ||
name = "acctestRG-%d" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't we also mark this as
Sensitive
so it doesn't show up in the plan/apply output?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, probably - I'll update this :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(done)