I am trying to remote execute a command on an Azure VM just for testing Terraform.
The example for VM generation is from the original Terraform documentation and I have added the remote-exec provisioner.
I'll get a timeout after some minutes. The same problem is after I setup the specific connection settings (host, username, password). I have no error message except the timeout at the end.
I don't understand why it's not working
azurerm_virtual_machine.tftest: Still creating... (2m50s elapsed)
azurerm_virtual_machine.tftest: Provisioning with 'remote-exec'...
azurerm_virtual_machine.tftest (remote-exec): Connecting to remote host via SSH.
..
azurerm_virtual_machine.tftest (remote-exec): Host:
azurerm_virtual_machine.tftest (remote-exec): User: root
azurerm_virtual_machine.tftest (remote-exec): Password: false
azurerm_virtual_machine.tftest (remote-exec): Private key: false
azurerm_virtual_machine.tftest (remote-exec): SSH Agent: false
azurerm_virtual_machine.tftest (remote-exec): Connecting to remote host via SSH.
..
azurerm_virtual_machine.tftest (remote-exec): Host:
azurerm_virtual_machine.tftest (remote-exec): User: root
azurerm_virtual_machine.tftest (remote-exec): Password: false
azurerm_virtual_machine.tftest (remote-exec): Private key: false
azurerm_virtual_machine.tftest (remote-exec): SSH Agent: false
azurerm_virtual_machine.tftest (remote-exec): Connecting to remote host via SSH.
..
azurerm_virtual_machine.tftest (remote-exec): Host:
azurerm_virtual_machine.tftest (remote-exec): User: root
azurerm_virtual_machine.tftest (remote-exec): Password: false
azurerm_virtual_machine.tftest (remote-exec): Private key: false
azurerm_virtual_machine.tftest (remote-exec): SSH Agent: false
azurerm_virtual_machine.tftest: Still creating... (3m0s elapsed)
azurerm_virtual_machine.tftest (remote-exec): Connecting to remote host via SSH.
Error: Error applying plan:
1 error(s) occurred:
* azurerm_virtual_machine.tftest: 1 error(s) occurred:
* timeout
Terraform does not automatically rollback in the face of errors.
Instead, your Terraform state file has been partially updated with
any resources that successfully completed. Please address the error
above and apply again to incrementally change your infrastructure.
terraform {
backend "azurerm" {
storage_account_name = "asfd-something"
container_name = "terraform-state"
key = "prod.terraform.tfstate"
access_key = "==DELETED=="
}
}
resource "azurerm_resource_group" "tftest" {
name = "tftest"
location = "West Europe"
tags {
environment = "Production"
}
}
resource "azurerm_virtual_network" "tftest" {
name = "tftest"
address_space = ["10.254.0.0/28"]
location = "${azurerm_resource_group.tftest.location}"
resource_group_name = "${azurerm_resource_group.tftest.name}"
}
resource "azurerm_subnet" "tftest" {
name = "tftest"
resource_group_name = "${azurerm_resource_group.tftest.name}"
virtual_network_name = "${azurerm_virtual_network.tftest.name}"
address_prefix = "10.254.0.0/28"
}
resource "azurerm_network_interface" "tftest" {
name = "tftest"
location = "${azurerm_resource_group.tftest.location}"
resource_group_name = "${azurerm_resource_group.tftest.name}"
ip_configuration {
name = "testconfiguration1"
subnet_id = "${azurerm_subnet.tftest.id}"
private_ip_address_allocation = "dynamic"
}
}
resource "azurerm_managed_disk" "tftest" {
name = "datadisk_existing"
location = "${azurerm_resource_group.tftest.location}"
resource_group_name = "${azurerm_resource_group.tftest.name}"
storage_account_type = "Standard_LRS"
create_option = "Empty"
disk_size_gb = "5"
}
resource "azurerm_virtual_machine" "tftest" {
name = "vmplus"
location = "${azurerm_resource_group.tftest.location}"
resource_group_name = "${azurerm_resource_group.tftest.name}"
network_interface_ids = ["${azurerm_network_interface.tftest.id}"]
vm_size = "Standard_A0"
provisioner "remote-exec" {
inline = [
"whoami",
]
connection {
type = "ssh"
}
}
storage_image_reference {
publisher = "Canonical"
offer = "UbuntuServer"
sku = "16.04-LTS"
version = "latest"
}
storage_os_disk {
name = "osdisk"
caching = "ReadWrite"
create_option = "FromImage"
managed_disk_type = "Standard_LRS"
}
storage_data_disk {
name = "${azurerm_managed_disk.tftest.name}"
managed_disk_id = "${azurerm_managed_disk.tftest.id}"
create_option = "Attach"
lun = 1
disk_size_gb = "${azurerm_managed_disk.tftest.disk_size_gb}"
}
os_profile {
computer_name = "tfhostname"
admin_username = "testadmin"
admin_password = "Password1234!"
}
os_profile_linux_config {
disable_password_authentication = false
}
tags {
environment = "staging"
}
}
Hi,
A few things here:
Hope this helps.
Andrew.
--
This mailing list is governed under the HashiCorp Community Guidelines -
https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
GitHub Issues: https://github.com/hashicorp/terraform/issues
IRC: #terraform-tool on Freenode
---
You received this message because you are subscribed to the Google Groups "Terraform" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
terraform-too...@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/terraform-tool/8d11cd97-91f8-44bc-af9f-7545706f9d4f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
connection {
type = "ssh"
}
connection {
type = “ssh”
host = “${azurerm_network_interface.tftest.private_ip_address}” (or work out your public ip if not running terraform locally)
user = “root”
private_key = “${file(‘~/.ssh/id_rsa')"
}