terra-farm / terraform-provider-virtualbox

VirtualBox provider for Terraform
https://terra-farm.github.io/provider-virtualbox/
MIT License
322 stars 137 forks source link

user_data bash script dont work #144

Closed ngabsf closed 1 year ago

ngabsf commented 2 years ago

Hello, I am trying to launch a script through user_data if I remember correctly, I could do it in the same way, but maybe I have something wrong in the syntax.

user_data.sh

!/bin/bash

apk add htop

TF_LOG 2022-06-10T03:18:00.227-0400 [INFO] Terraform version: 1.2.2 2022-06-10T03:18:26.104-0400 [DEBUG] provider.terraform-provider-virtualbox_v0.2.2-alpha.1.exe: pid-5456-resource_vm.go:605: [DEBUG] Network adapter: {Network:bridged Hardware:82545EM HostInterface:Qualcomm Atheros AR956x Wireless Network Adapter MacAddr:} 2022-06-10T03:18:37.681-0400 [WARN] unexpected data: registry.terraform.io/terra-farm/virtualbox:stdout="Waiting for VM "vm_test" to power on... VM "vm_test" has been successfully started." 2022-06-10T03:18:37.703-0400 [DEBUG] provider.terraform-provider-virtualbox_v0.2.2-alpha.1.exe: pid-5456-resource_vm.go:335: [DEBUG] Resource ID: b5b03c4c-27dd-41c7-b13e-9d3870d66eb9 2022-06-10T03:18:37.703-0400 [DEBUG] provider.terraform-provider-virtualbox_v0.2.2-alpha.1.exe: pid-5456-resource_vm.go:813: [INFO] Waiting for VM (vm_test) to have network_adapter.0.ipv4_address_available of [yes] 2022-06-10T03:18:37.703-0400 [DEBUG] provider.terraform-provider-virtualbox_v0.2.2-alpha.1.exe: pid-5456-state.go:52: [DEBUG] Waiting for state to become: [yes]

2022-06-10T03:19:09.059-0400 [WARN] Provider "provider[\"registry.terraform.io/terra-farm/virtualbox\"]" produced an unexpected new value for virtualbox_vm.TEST_VM[0], but we are tolerating it because it is using the legacy plugin SDK. The following problems may be the cause of any confusing errors from downstream operations:

- .user_data: was cty.StringVal("#!/bin/bash\r\napk add htop"), but now cty.StringVal("#!/bin/bash\r\r\napk add htop")

2022-06-10T03:19:09.065-0400 [DEBUG] provider.stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = transport is closing" 2022-06-10T03:19:09.082-0400 [DEBUG] provider: plugin process exited: path=.terraform/providers/registry.terraform.io/terra-farm/virtualbox/0.2.2-alpha.1/windows_amd64/terraform-provider-virtualbox_v0.2.2-alpha.1.exe pid=5456 2022-06-10T03:19:09.082-0400 [DEBUG] provider: plugin exited

Kraktorist commented 1 year ago

There is no built-in cloud-init mechanism in VirtualBox. And as I see nothing similar hasn't been implemented in this provider. user_data parameter runs the following command: VBoxManage setextradata RESOURCE_VM user_data YOUR_USER_DATA (doc) This command attaches a tag user_data to the created box but this tag is not supposed to be accessible from inside the instance.

See this not resolved bug as well #89

VoyTechnology commented 1 year ago

Closing as we are aware of the issue - tracked in #150