0
0
mirror of https://github.com/bpg/terraform-provider-proxmox.git synced 2025-06-30 02:31:10 +00:00
terraform-provider-proxmox/example/resource_virtual_environment_file.tf
Pavel Boldyrev 3616b4b79e
refactor import custom disk, add tests
Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
2024-02-04 01:03:20 -05:00

66 lines
2.0 KiB
HCL

#===============================================================================
# Cloud Config (cloud-init)
#===============================================================================
resource "proxmox_virtual_environment_file" "user_config" {
content_type = "snippets"
datastore_id = element(data.proxmox_virtual_environment_datastores.example.datastore_ids, index(data.proxmox_virtual_environment_datastores.example.datastore_ids, "local"))
node_name = data.proxmox_virtual_environment_datastores.example.node_name
source_raw {
data = <<EOF
#cloud-config
chpasswd:
list: |
ubuntu:example
expire: false
hostname: terraform-provider-proxmox-example
users:
- default
- name: ubuntu
groups: sudo
shell: /bin/bash
ssh-authorized-keys:
- ${trimspace(tls_private_key.example.public_key_openssh)}
sudo: ALL=(ALL) NOPASSWD:ALL
EOF
file_name = "terraform-provider-proxmox-example-user-config.yaml"
}
}
resource "proxmox_virtual_environment_file" "vendor_config" {
content_type = "snippets"
datastore_id = element(data.proxmox_virtual_environment_datastores.example.datastore_ids, index(data.proxmox_virtual_environment_datastores.example.datastore_ids, "local"))
node_name = data.proxmox_virtual_environment_datastores.example.node_name
source_raw {
data = <<EOF
#cloud-config
runcmd:
- apt update
- apt install -y qemu-guest-agent
- systemctl enable qemu-guest-agent
- systemctl start qemu-guest-agent
- echo "done" > /tmp/vendor-cloud-init-done
EOF
file_name = "terraform-provider-proxmox-example-vendor-config.yaml"
}
}
resource "proxmox_virtual_environment_file" "meta_config" {
content_type = "snippets"
datastore_id = element(data.proxmox_virtual_environment_datastores.example.datastore_ids, index(data.proxmox_virtual_environment_datastores.example.datastore_ids, "local"))
node_name = data.proxmox_virtual_environment_datastores.example.node_name
source_raw {
data = <<EOF
local-hostname: myhost.internal
EOF
file_name = "meta-config.yaml"
}
}