-
Notifications
You must be signed in to change notification settings - Fork 112
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
Terraform Unable to use Provisioners in VM Resource when DHCP is used for IP Address #49
Comments
Try passing it the proper 'host' attribute from the generated VM reference. I know this works w/ SSH, and no reason to assume winrm would be any different. connection { |
Hello @jjamesmastercontrol did this work for you?
|
Hello @jjamesmastercontrol , I'd like to know if still an issue or its working now on branch master? |
Hello @jjamesmastercontrol , do you have an example of config file without sensitive data so I can test it and replicate behaviour like yours, please? |
Hello @jjamesmastercontrol , I just tested and it works for me it created a file test.txt and printed the Hello with powershell, could you confirm it if it's working for you and this issue can be closed?. data "nutanix_clusters" "clusters" {}
locals {
vmname_prefix = "test-issue49"
cluster1 = [
for cluster in data.nutanix_clusters.clusters.entities :
cluster.metadata.uuid if cluster.service_list[0] != "PRISM_CENTRAL"
][0]
vm_username = "Administrator"
image_name = "windows_2016"
image_name_virtio = "Virt IO"
}
data "template_file" "unattend" {
template = "${file("unattend.xml")}"
vars = {
vmname_prefix = local.vmname_prefix
index = 1
vm_username = local.vm_username
vm_password = var.vm_password
}
}
data "nutanix_subnet" "subnet" {
subnet_name = "Rx-Automation-Network"
}
data "nutanix_image" "windows" {
image_name = local.image_name
}
data "nutanix_image" "virtio" {
image_name = local.image_name_virtio
}
resource "nutanix_virtual_machine" "vm" {
name = "${local.vmname_prefix}-1"
cluster_uuid = local.cluster1
num_vcpus_per_socket = 1
num_sockets = 2
memory_size_mib = 2048
nic_list {
subnet_uuid = data.nutanix_subnet.subnet.id
}
guest_customization_sysprep = {
install_type = "PREPARED"
unattend_xml = base64encode(data.template_file.unattend.rendered)
}
disk_list {
data_source_reference = {
kind = "image"
uuid = data.nutanix_image.windows.id
}
}
connection {
type = "winrm"
user = local.vm_username
password = var.vm_password
use_ntlm = true
insecure = true
host = "${nutanix_virtual_machine.vm.nic_list_status.0.ip_endpoint_list.0.ip}"
}
provisioner "file" {
when = "create"
content = "test.txt"
destination = "C:\\test.txt"
}
provisioner "remote-exec" {
when = "create"
inline = [
"C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe Write-Host Hello"
]
}
} |
The response of if its working for me
|
Closed for lack of the response from the issue, it's been tested with similar config I shared and not erros has been presented. |
Describe the bug
The Nutanix Provider is not able to establish a connection to VM's it has created due to lacking the IP address of the Host it has just created if not provided, this prevents using DHCP for IP provisioning.
Expected behavior
The Nutanix Provider should allow the provisioners of remote-exe | file to establish connections on VM's it has just created using DHCP for IP provisioning
These provisioners would use a connection to connect to the VM's and then do what they should, copy a file | run a command | etc.
Logs
With the following inline code inside the: nutanix_virtual_machine object
connection {
type = "winrm"
user = "${var.admin_uid}"
password = "${var.admin_cid}"
}
provisioner "file" {
when = "create"
content = "test.txt"
destination = "C:\test.txt"
}
provisioner "remote-exec" {
when = "create"
inline = [
"C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe Write-Host Hello"
]
}
You get the following output until a timeout is reached:
For a remote-exec provisioner:
nutanix_virtual_machine.DB (remote-exec): Connecting to remote host via WinRM...
nutanix_virtual_machine.DB (remote-exec): Host:
nutanix_virtual_machine.DB (remote-exec): Port: 5985
nutanix_virtual_machine.DB (remote-exec): User: Administrator
nutanix_virtual_machine.DB (remote-exec): Password: true
nutanix_virtual_machine.DB (remote-exec): HTTPS: false
nutanix_virtual_machine.DB (remote-exec): Insecure: false
nutanix_virtual_machine.DB (remote-exec): NTLM: false
nutanix_virtual_machine.DB (remote-exec): CACert: false
For a File Provisioner:
nutanix_virtual_machine.DB: Provisioning with 'file'...
nutanix_virtual_machine.DB: Still creating... (20s elapsed)
nutanix_virtual_machine.DB: Still creating... (30s elapsed)
nutanix_virtual_machine.DB: Still creating... (40s elapsed)
nutanix_virtual_machine.DB: Still creating... (50s elapsed)
Versions (please complete the following information):
Additional context
This is most likely related to Issue #19 but is not specific to the provisioners
The text was updated successfully, but these errors were encountered: