Cloud-init : Error: error transferring file: try_sudo: no such file or directory: /usr/bin/tee /var/lib/vz/snippets/cloud-config.yml
Closed this issue · 4 comments
Describe the bug
When using proxmox_virtual_environment_file, terraform return │ Error: error transferring file: try_sudo: no such file or directory: /usr/bin/tee /var/lib/vz/snippets/cloud-config.yml , even when the file is present in local:snippets/
To Reproduce
resource "proxmox_virtual_environment_file" "cloud_config" {
content_type = "snippets"
datastore_id = "local"
node_name = "pve"
source_raw {
data = <<-EOF
runcmd:
- apt-get update
- apt-get install -y qemu-guest-agent net-tools
- systemctl enable --now qemu-guest-agent
EOF
file_name = "cloud-config.yml"
}
}
resource "proxmox_virtual_environment_vm" "debian_vm" {
name = "vdi"
description = "Managed by Terraform"
tags = ["terraform", "debian"]
node_name = "pve"
vm_id = 101
agent {
enabled = true
}
cpu {
cores = 4
type = "x86-64-v2-AES"
}
memory {
dedicated = 4096
floating = 4096
}
disk {
datastore_id = "local"
file_id = "local:iso/debian-12-generic-amd64.img"
interface = "scsi0"
}
initialization {
ip_config {
ipv4 {
address = "dhcp"
}
}
user_account {
password = var.password
username = var.username
}
user_data_file_id = proxmox_virtual_environment_file.cloud_config.id
}
network_device {
bridge = "vmbr0"
}
operating_system {
type = "l26"
}
}
and the output of terraform|tofu apply
.
Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
+ create
Terraform will perform the following actions:
# proxmox_virtual_environment_file.cloud_config will be created
+ resource "proxmox_virtual_environment_file" "cloud_config" {
+ content_type = "snippets"
+ datastore_id = "local"
+ file_modification_date = (known after apply)
+ file_name = (known after apply)
+ file_size = (known after apply)
+ file_tag = (known after apply)
+ id = (known after apply)
+ node_name = "pve"
+ overwrite = true
+ timeout_upload = 1800
+ source_raw {
+ data = <<-EOT
runcmd:
- apt-get update
- apt-get install -y qemu-guest-agent net-tools
- systemctl enable --now qemu-guest-agent
EOT
+ file_name = "cloud-config.yml"
+ resize = 0
}
}
# proxmox_virtual_environment_vm.debian_vm will be created
+ resource "proxmox_virtual_environment_vm" "debian_vm" {
+ acpi = true
+ bios = "seabios"
+ description = "Managed by Terraform"
+ id = (known after apply)
+ ipv4_addresses = (known after apply)
+ ipv6_addresses = (known after apply)
+ keyboard_layout = "en-us"
+ mac_addresses = (known after apply)
+ migrate = false
+ name = "vdi"
+ network_interface_names = (known after apply)
+ node_name = "pve"
+ on_boot = true
+ protection = false
+ reboot = false
+ scsi_hardware = "virtio-scsi-pci"
+ started = true
+ stop_on_destroy = false
+ tablet_device = true
+ tags = [
+ "terraform",
+ "debian",
]
+ template = false
+ timeout_clone = 1800
+ timeout_create = 1800
+ timeout_migrate = 1800
+ timeout_move_disk = 1800
+ timeout_reboot = 1800
+ timeout_shutdown_vm = 1800
+ timeout_start_vm = 1800
+ timeout_stop_vm = 300
+ vm_id = 101
+ agent {
+ enabled = true
+ timeout = "15m"
+ trim = false
+ type = "virtio"
}
+ cpu {
+ cores = 4
+ hotplugged = 0
+ limit = 0
+ numa = false
+ sockets = 1
+ type = "x86-64-v2-AES"
+ units = 1024
}
+ disk {
+ aio = "io_uring"
+ backup = true
+ cache = "none"
+ datastore_id = "local"
+ discard = "ignore"
+ file_format = (known after apply)
+ file_id = "local:iso/debian-12-generic-amd64.img"
+ interface = "scsi0"
+ iothread = false
+ path_in_datastore = (known after apply)
+ replicate = true
+ size = 8
+ ssd = false
}
+ initialization {
+ datastore_id = "local-lvm"
+ upgrade = (known after apply)
+ ip_config {
+ ipv4 {
+ address = "dhcp"
}
}
+ user_account {
+ password = (sensitive value)
+ username = "vdi"
}
}
+ memory {
+ dedicated = 4096
+ floating = 4096
+ keep_hugepages = false
+ shared = 0
}
+ network_device {
+ bridge = "vmbr0"
+ enabled = true
+ firewall = false
+ mac_address = (known after apply)
+ model = "virtio"
+ mtu = 0
+ queues = 0
+ rate_limit = 0
+ vlan_id = 0
}
+ operating_system {
+ type = "l26"
}
}
Plan: 2 to add, 0 to change, 0 to destroy.
Do you want to perform these actions?
Terraform will perform the actions described above.
Only 'yes' will be accepted to approve.
Enter a value: yes
proxmox_virtual_environment_file.cloud_config: Creating...
proxmox_virtual_environment_vm.debian_vm: Creating...
proxmox_virtual_environment_vm.debian_vm: Still creating... [10s elapsed]
proxmox_virtual_environment_vm.debian_vm: Still creating... [20s elapsed]
proxmox_virtual_environment_vm.debian_vm: Still creating... [30s elapsed]
proxmox_virtual_environment_vm.debian_vm: Creation complete after 32s [id=101]
╷
│ Warning: the existing file "local:snippets/cloud-config.yml" has been overwritten by the resource
│
│ with proxmox_virtual_environment_file.cloud_config,
│ on cloud-init.tf line 1, in resource "proxmox_virtual_environment_file" "cloud_config":
│ 1: resource "proxmox_virtual_environment_file" "cloud_config" {
│
╵
╷
│ Error: error transferring file: try_sudo: no such file or directory: /usr/bin/tee /var/lib/vz/snippets/cloud-config.yml
│
│
│ with proxmox_virtual_environment_file.cloud_config,
│ on cloud-init.tf line 1, in resource "proxmox_virtual_environment_file" "cloud_config":
│ 1: resource "proxmox_virtual_environment_file" "cloud_config" {
│
Expected behavior
Terraform should be able to configure the vm using the cloud-init template
Additional context
- Single or clustered Proxmox: Single
- Proxmox version: 8.2.2
- Provider version (ideally it should be the latest version): 0.66.2
- Terraform/OpenTofu version: v1.9.8
- OS (where you run Terraform/OpenTofu from): Debian 12
- Debug logs (
TF_LOG=DEBUG terraform apply
):
debug.txt
Have you enable snippets file on that datastore ? Had the issue back then.
Have you enable snippets file on that datastore ? Had the issue back then.
Yes I use the local datastore with snippets enabled
Hey @edricus 👋🏼
Have you configured your user account on the PVE host as documented here? Does this check work?
ssh terraform@<target-node> sudo pvesm apiinfo
Also, these requirements are important:
sudo may
not be installed by default on Proxmox VE nodes. You can install it via the command line on the Proxmox host:apt install sudo
The
root
user on the Proxmox node must be configured withbash
as the default shell.
Hey @edricus 👋🏼
Have you configured your user account on the PVE host as documented here? Does this check work?
ssh terraform@<target-node> sudo pvesm apiinfo
Also, these requirements are important:
sudo may
not be installed by default on Proxmox VE nodes. You can install it via the command line on the Proxmox host:apt install sudo
The
root
user on the Proxmox node must be configured withbash
as the default shell.
It was the shell, had sh and didn't know it'll cause this kind of behavior, thx !