New Question

Revision history [back]

click to hide/show revision 1
initial version

how to pass userdata via terraform

How do you pass the userdata to cloudbase-init via terraform?

I have cloudbase-init 1.1.4 x64 installed on a windows server 2022 template on vmware vsphere. I am attempting to use the terraform hashicorp/vsphere provider to build the vm and pass the userdata via the vapp directive. I have the ovfservice configured, but the template's ovf file doesn't include userdata properties. Would the vmwareguestinfoservice be required instead? According to the documentation, both metadata services support userdata.

how to pass userdata via terraform

How do you pass the userdata to cloudbase-init via terraform?

I have cloudbase-init 1.1.4 x64 installed on a windows server 2022 template on vmware vsphere. I am attempting to use the terraform hashicorp/vsphere provider to build the vm and pass the userdata via the vapp directive. hashicorp/cloudinit provider. I have the ovfservice configured, but the template's ovf file doesn't include userdata properties. Would the vmwareguestinfoservice Is an example configuration available that can be required instead? According to the documentation, both metadata services support userdata.used as a reference?

how to pass userdata via terraform

How do you pass the userdata to cloudbase-init via terraform?

I have cloudbase-init 1.1.4 x64 installed on a windows server 2022 template on vmware vsphere. I am attempting to use the terraform hashicorp/vsphere provider to build the vm and pass the userdata via the hashicorp/cloudinit provider. Is an example configuration available that can be used as a reference?

Please note, I have already seen this question...

https://ask.cloudbase.it/question/3228/failure-running-multipart-shellscript-with-terraform-and-openstack/

how to pass userdata via terraform

How do you pass the userdata to cloudbase-init via terraform?

I have cloudbase-init Answer...

• Software Platform: VMware 7.0 Cloudbase-init Version: 1.1.4 x64 installed on a windows server x64 Target: Windows Server 2022 template on vmware vsphere. I am attempting to use the terraform hashicorp/vsphere provider to build the vm and pass the userdata via the hashicorp/cloudinit provider. Is an example configuration available that can be used as a reference?

Please note, I have already seen this question...

https://ask.cloudbase.it/question/3228/failure-running-multipart-shellscript-with-terraform-and-openstack/OVF template Terraform Providers: hashicorp/vsphere, hashicorp/cloudinit

• cloudbase-init-unattend.conf [DEFAULT] username=Administrator groups=Administrators injectuserpassword=true configdriverawhhd=false configdrivecdrom=false configdrivevfat=false bsdtarpath=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\bin\bsdtar.exe mtoolspath=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\bin\ verbose=true debug=true logdir=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\log\ logfile=cloudbase-init-unattend.log defaultloglevels=comtypes=INFO,suds=INFO,iso8601=WARN,requests=WARN loggingserialportsettings= mtuusedhcpconfig=false ntpusedhcpconfig=false localscriptspath=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\LocalScripts\ checklatestversion=false metadataservices=cloudbaseinit.metadata.services.vmwareguestinfoservice.VMwareGuestInfoService plugins=cloudbaseinit.plugins.common.userdata.UserDataPlugin allowreboot=false stopserviceon_exit=false

• cloudbase-init.conf [DEFAULT] username=Administrator groups=Administrators firstlogonbehaviour=always injectuserpassword=true configdriverawhhd=false configdrivecdrom=false configdrivevfat=false bsdtarpath=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\bin\bsdtar.exe mtoolspath=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\bin\ verbose=true debug=true logdir=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\log\ logfile=cloudbase-init.log defaultloglevels=comtypes=INFO,suds=INFO,iso8601=WARN,requests=WARN loggingserialportsettings= mtuusedhcpconfig=false ntpusedhcpconfig=false localscriptspath=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\LocalScripts\ checklatestversion=false metadataservices=cloudbaseinit.metadata.services.vmwareguestinfoservice.VMwareGuestInfoService netbioshostnamecompatibility=false

• cloudinit.tf (hashicorp/cloudinit) data "cloudinitconfig" "userdata" { gzip = true base64encode = true

part { filename = "userdata.yml" content_type = "text/cloud-config" content = templatefile("${path.module}/cloudinit/userdata.yml", {}) } }

• vm.tf (hashicorp/vsphere, excerpt) clone { templateuuid = data.vspherecontentlibraryitem.contentlibraryitem.id customize { windowsoptions { computername = local.vm.hostname workgroup = local.vm.workgroup adminpassword = local.vm.adminpassword timezone = local.vm.timezone } networkinterface { ipv4address = local.vm.ipv4address ipv4netmask = local.vm.ipv4netmask } ipv4gateway = local.vm.ipv4gateway dnsserverlist = local.vm.dnsserver_list } }

cdrom { client_device = true }

extraconfig = { "guestinfo.metadata" = base64gzip(jsonencode({ "instance-id": local.vm.hostname, })), "guestinfo.metadata.encoding" = "gzip+base64", "guestinfo.userdata" = data.cloudinitconfig.userdata.rendered, "guestinfo.userdata.encoding" = "gzip+base64" }

how to pass userdata via terraform

How do you pass the userdata to cloudbase-init via terraform?

Answer...

• Software Platform: VMware 7.0 Cloudbase-init Version: 1.1.4 x64 Target: Windows Server 2022 OVF template Terraform Providers: hashicorp/vsphere, hashicorp/cloudinit

• cloudbase-init-unattend.conf [DEFAULT] username=Administrator groups=Administrators injectuserpassword=true configdriverawhhd=false configdrivecdrom=false configdrivevfat=false bsdtarpath=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\bin\bsdtar.exe mtoolspath=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\bin\ verbose=true debug=true logdir=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\log\ logfile=cloudbase-init-unattend.log defaultloglevels=comtypes=INFO,suds=INFO,iso8601=WARN,requests=WARN loggingserialportsettings= mtuusedhcpconfig=false ntpusedhcpconfig=false localscriptspath=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\LocalScripts\ checklatestversion=false metadataservices=cloudbaseinit.metadata.services.vmwareguestinfoservice.VMwareGuestInfoService plugins=cloudbaseinit.plugins.common.userdata.UserDataPlugin allowreboot=false stopserviceon_exit=false

• cloudbase-init.conf [DEFAULT] username=Administrator groups=Administrators firstlogonbehaviour=always injectuserpassword=true configdriverawhhd=false configdrivecdrom=false configdrivevfat=false bsdtarpath=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\bin\bsdtar.exe mtoolspath=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\bin\ verbose=true debug=true logdir=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\log\ logfile=cloudbase-init.log defaultloglevels=comtypes=INFO,suds=INFO,iso8601=WARN,requests=WARN loggingserialportsettings= mtuusedhcpconfig=false ntpusedhcpconfig=false localscriptspath=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\LocalScripts\ checklatestversion=false metadataservices=cloudbaseinit.metadata.services.vmwareguestinfoservice.VMwareGuestInfoService netbioshostnamecompatibility=false

• cloudinit.tf (hashicorp/cloudinit) data "cloudinitconfig" "userdata" { gzip = true base64encode = true

part { filename = "userdata.yml" content_type = "text/cloud-config" content = templatefile("${path.module}/cloudinit/userdata.yml", {}) } }

• vm.tf (hashicorp/vsphere, excerpt) clone { templateuuid = data.vspherecontentlibraryitem.contentlibraryitem.id customize { windowsoptions { computername = local.vm.hostname workgroup = local.vm.workgroup adminpassword = local.vm.adminpassword timezone = local.vm.timezone } networkinterface { ipv4address = local.vm.ipv4address ipv4netmask = local.vm.ipv4netmask } ipv4gateway = local.vm.ipv4gateway dnsserverlist = local.vm.dnsserver_list } }

cdrom { client_device = true }

extraconfig = { "guestinfo.metadata" = base64gzip(jsonencode({ "instance-id": local.vm.hostname, })), "guestinfo.metadata.encoding" = "gzip+base64", "guestinfo.userdata" = data.cloudinitconfig.userdata.rendered, "guestinfo.userdata.encoding" = "gzip+base64" }

how to pass userdata via terraform

How do you pass the userdata to cloudbase-init via terraform?

Answer...

• Software Platform: VMware 7.0 Cloudbase-init Version: 1.1.4 x64 Target: Windows Server 2022 OVF template Terraform Providers: hashicorp/vsphere, hashicorp/cloudinit

• cloudbase-init-unattend.conf [DEFAULT] username=Administrator groups=Administrators injectuserpassword=true configdriverawhhd=false configdrivecdrom=false configdrivevfat=false bsdtarpath=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\bin\bsdtar.exe mtoolspath=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\bin\ verbose=true debug=true logdir=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\log\ logfile=cloudbase-init-unattend.log defaultloglevels=comtypes=INFO,suds=INFO,iso8601=WARN,requests=WARN loggingserialportsettings= mtuusedhcpconfig=false ntpusedhcpconfig=false localscriptspath=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\LocalScripts\ checklatestversion=false metadataservices=cloudbaseinit.metadata.services.vmwareguestinfoservice.VMwareGuestInfoService plugins=cloudbaseinit.plugins.common.userdata.UserDataPlugin allowreboot=false stopserviceon_exit=false

• cloudbase-init.conf [DEFAULT] username=Administrator groups=Administrators firstlogonbehaviour=always first_logon_behaviour=always injectuserpassword=true configdriverawhhd=false configdrivecdrom=false configdrivevfat=false bsdtarpath=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\bin\bsdtar.exe mtoolspath=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\bin\ verbose=true debug=true logdir=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\log\ logfile=cloudbase-init.log defaultloglevels=comtypes=INFO,suds=INFO,iso8601=WARN,requests=WARN loggingserialportsettings= mtuusedhcpconfig=false ntpusedhcpconfig=false localscriptspath=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\LocalScripts\ checklatestversion=false metadataservices=cloudbaseinit.metadata.services.vmwareguestinfoservice.VMwareGuestInfoService netbioshostnamecompatibility=false

• cloudinit.tf (hashicorp/cloudinit) data "cloudinitconfig" "userdata" { gzip = true base64encode = true

part { filename = "userdata.yml" content_type = "text/cloud-config" content = templatefile("${path.module}/cloudinit/userdata.yml", {}) } }

• vm.tf (hashicorp/vsphere, excerpt) clone { templateuuid = data.vspherecontentlibraryitem.contentlibraryitem.id customize { windowsoptions { computername = local.vm.hostname workgroup = local.vm.workgroup adminpassword = local.vm.adminpassword timezone = local.vm.timezone } networkinterface { ipv4address = local.vm.ipv4address ipv4netmask = local.vm.ipv4netmask } ipv4gateway = local.vm.ipv4gateway dnsserverlist = local.vm.dnsserver_list } }

cdrom { client_device = true }

extraconfig = { "guestinfo.metadata" = base64gzip(jsonencode({ "instance-id": local.vm.hostname, })), "guestinfo.metadata.encoding" = "gzip+base64", "guestinfo.userdata" = data.cloudinitconfig.userdata.rendered, "guestinfo.userdata.encoding" = "gzip+base64" }

how to pass userdata via terraform

How do you pass the userdata to cloudbase-init via terraform?

Answer...

• Software Platform: VMware 7.0 Cloudbase-init Version: 1.1.4 x64 Target: Windows Server 2022 OVF template Terraform Providers: hashicorp/vsphere, hashicorp/cloudinit

• cloudbase-init-unattend.conf [DEFAULT] username=Administrator groups=Administrators injectuserpassword=true inject_user_password=true configdriverawhhd=false configdrivecdrom=false configdrivevfat=false bsdtarpath=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\bin\bsdtar.exe mtoolspath=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\bin\ verbose=true debug=true logdir=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\log\ logfile=cloudbase-init-unattend.log defaultloglevels=comtypes=INFO,suds=INFO,iso8601=WARN,requests=WARN loggingserialportsettings= mtuusedhcpconfig=false ntpusedhcpconfig=false localscriptspath=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\LocalScripts\ checklatestversion=false metadataservices=cloudbaseinit.metadata.services.vmwareguestinfoservice.VMwareGuestInfoService plugins=cloudbaseinit.plugins.common.userdata.UserDataPlugin allowreboot=false stopserviceon_exit=false

• cloudbase-init.conf [DEFAULT] username=Administrator groups=Administrators first_logon_behaviour=always firstlogonbehaviour=always injectuserpassword=true configdriverawhhd=false configdrivecdrom=false configdrivevfat=false bsdtarpath=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\bin\bsdtar.exe mtoolspath=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\bin\ verbose=true debug=true logdir=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\log\ logfile=cloudbase-init.log defaultloglevels=comtypes=INFO,suds=INFO,iso8601=WARN,requests=WARN loggingserialportsettings= mtuusedhcpconfig=false ntpusedhcpconfig=false localscriptspath=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\LocalScripts\ checklatestversion=false metadataservices=cloudbaseinit.metadata.services.vmwareguestinfoservice.VMwareGuestInfoService netbioshostnamecompatibility=false

• cloudinit.tf (hashicorp/cloudinit) data "cloudinitconfig" "userdata" { gzip = true base64encode = true

part { filename = "userdata.yml" content_type = "text/cloud-config" content = templatefile("${path.module}/cloudinit/userdata.yml", {}) } }

• vm.tf (hashicorp/vsphere, excerpt) clone { templateuuid = data.vspherecontentlibraryitem.contentlibraryitem.id customize { windowsoptions { computername = local.vm.hostname workgroup = local.vm.workgroup adminpassword = local.vm.adminpassword timezone = local.vm.timezone } networkinterface { ipv4address = local.vm.ipv4address ipv4netmask = local.vm.ipv4netmask } ipv4gateway = local.vm.ipv4gateway dnsserverlist = local.vm.dnsserver_list } }

cdrom { client_device = true }

extraconfig = { "guestinfo.metadata" = base64gzip(jsonencode({ "instance-id": local.vm.hostname, })), "guestinfo.metadata.encoding" = "gzip+base64", "guestinfo.userdata" = data.cloudinitconfig.userdata.rendered, "guestinfo.userdata.encoding" = "gzip+base64" }

how to pass userdata via terraform

How do you pass the userdata to cloudbase-init via terraform?

Answer...

• Software Platform: VMware 7.0 Cloudbase-init Version: 1.1.4 x64 Target: Windows Server 2022 OVF template Terraform Providers: hashicorp/vsphere, hashicorp/cloudinit

• cloudbase-init-unattend.conf [DEFAULT] username=Administrator groups=Administrators inject_user_password=true configdriverawhhd=false configdrivecdrom=false configdrivevfat=false bsdtarpath=C:\Program config_drive_raw_hhd=false config_drive_cdrom=false config_drive_vfat=false bsdtar_path=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\bin\bsdtar.exe mtoolspath=C:\Program mtools_path=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\bin\ verbose=true debug=true logdir=C:\Program log_dir=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\log\ logfile=cloudbase-init-unattend.log defaultloglevels=comtypes=INFO,suds=INFO,iso8601=WARN,requests=WARN loggingserialportsettings= mtuusedhcpconfig=false ntpusedhcpconfig=false localscriptspath=C:\Program log_file=cloudbase-init-unattend.log default_log_levels=comtypes=INFO,suds=INFO,iso8601=WARN,requests=WARN logging_serial_port_settings= mtu_use_dhcp_config=false ntp_use_dhcp_config=false local_scripts_path=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\LocalScripts\ checklatestversion=false metadataservices=cloudbaseinit.metadata.services.vmwareguestinfoservice.VMwareGuestInfoService check_latest_version=false metadata_services=cloudbaseinit.metadata.services.vmwareguestinfoservice.VMwareGuestInfoService plugins=cloudbaseinit.plugins.common.userdata.UserDataPlugin allowreboot=false stopserviceon_exit=falseallow_reboot=false stop_service_on_exit=false

• cloudbase-init.conf [DEFAULT] username=Administrator groups=Administrators firstlogonbehaviour=always injectuserpassword=true configdriverawhhd=false configdrivecdrom=false configdrivevfat=false bsdtarpath=C:\Program first_logon_behaviour=always inject_user_password=true config_drive_raw_hhd=false config_drive_cdrom=false config_drive_vfat=false bsdtar_path=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\bin\bsdtar.exe mtoolspath=C:\Program mtools_path=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\bin\ verbose=true debug=true logdir=C:\Program log_dir=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\log\ logfile=cloudbase-init.log defaultloglevels=comtypes=INFO,suds=INFO,iso8601=WARN,requests=WARN loggingserialportsettings= mtuusedhcpconfig=false ntpusedhcpconfig=false localscriptspath=C:\Program log_file=cloudbase-init.log default_log_levels=comtypes=INFO,suds=INFO,iso8601=WARN,requests=WARN logging_serial_port_settings= mtu_use_dhcp_config=false ntp_use_dhcp_config=false local_scripts_path=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\LocalScripts\ checklatestversion=false metadataservices=cloudbaseinit.metadata.services.vmwareguestinfoservice.VMwareGuestInfoService netbioshostnamecompatibility=falsecheck_latest_version=false metadata_services=cloudbaseinit.metadata.services.vmwareguestinfoservice.VMwareGuestInfoService netbios_host_name_compatibility=false

• cloudinit.tf (hashicorp/cloudinit) data "cloudinitconfig" "cloudinit_config" "userdata" { gzip = true base64encode base64_encode = true

part { filename = "userdata.yml" content_type = "text/cloud-config" content = templatefile("${path.module}/cloudinit/userdata.yml", {}) } }

• vm.tf (hashicorp/vsphere, excerpt) clone { templateuuid = data.vspherecontentlibraryitem.contentlibraryitem.id template_uuid = data.vsphere_content_library_item.content_library_item.id customize { windowsoptions { computername windows_options { computer_name = local.vm.hostname workgroup = local.vm.workgroup adminpassword = local.vm.adminpassword timezone = local.vm.timezone admin_password = local.vm.admin_password time_zone = local.vm.time_zone } networkinterface { ipv4address = local.vm.ipv4address ipv4netmask = local.vm.ipv4netmask network_interface { ipv4_address = local.vm.ipv4_address ipv4_netmask = local.vm.ipv4_netmask } ipv4gateway = local.vm.ipv4gateway dnsserverlist = local.vm.dnsserver_list ipv4_gateway = local.vm.ipv4_gateway dns_server_list = local.vm.dns_server_list } }

cdrom { client_device = true }

extraconfig extra_config = { "guestinfo.metadata" = base64gzip(jsonencode({ "instance-id": local.vm.hostname, })), "guestinfo.metadata.encoding" = "gzip+base64", "guestinfo.userdata" = data.cloudinitconfig.userdata.rendered, data.cloudinit_config.userdata.rendered, "guestinfo.userdata.encoding" = "gzip+base64" }

how to pass userdata via terraform

How do you pass the userdata to cloudbase-init via terraform?

Answer...

• Software Platform: VMware 7.0 Cloudbase-init Version: 1.1.4 x64 Target: Windows Server 2022 OVF template Terraform Providers: hashicorp/vsphere, hashicorp/cloudinit

• cloudbase-init-unattend.conf [DEFAULT] username=Administrator groups=Administrators inject_user_password=true config_drive_raw_hhd=false config_drive_cdrom=false config_drive_vfat=false bsdtar_path=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\bin\bsdtar.exe mtools_path=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\bin\ verbose=true debug=true log_dir=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\log\ log_file=cloudbase-init-unattend.log default_log_levels=comtypes=INFO,suds=INFO,iso8601=WARN,requests=WARN logging_serial_port_settings= mtu_use_dhcp_config=false ntp_use_dhcp_config=false local_scripts_path=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\LocalScripts\ check_latest_version=false metadata_services=cloudbaseinit.metadata.services.vmwareguestinfoservice.VMwareGuestInfoService plugins=cloudbaseinit.plugins.common.userdata.UserDataPlugin allow_reboot=false stop_service_on_exit=false

• cloudbase-init.conf [DEFAULT] username=Administrator groups=Administrators first_logon_behaviour=always inject_user_password=true config_drive_raw_hhd=false config_drive_cdrom=false config_drive_vfat=false bsdtar_path=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\bin\bsdtar.exe mtools_path=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\bin\ verbose=true debug=true log_dir=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\log\ log_file=cloudbase-init.log default_log_levels=comtypes=INFO,suds=INFO,iso8601=WARN,requests=WARN logging_serial_port_settings= mtu_use_dhcp_config=false ntp_use_dhcp_config=false local_scripts_path=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\LocalScripts\ check_latest_version=false metadata_services=cloudbaseinit.metadata.services.vmwareguestinfoservice.VMwareGuestInfoService netbios_host_name_compatibility=false

• cloudinit.tf (hashicorp/cloudinit) data "cloudinit_config" "userdata" { gzip = true base64_encode = true

part { filename = "userdata.yml" content_type = "text/cloud-config" content = templatefile("${path.module}/cloudinit/userdata.yml", {}) } }

• vm.tf (hashicorp/vsphere, excerpt) clone { template_uuid = data.vsphere_content_library_item.content_library_item.id customize { windows_options { computer_name = local.vm.hostname workgroup = local.vm.workgroup admin_password = local.vm.admin_password time_zone = local.vm.time_zone } network_interface { ipv4_address = local.vm.ipv4_address ipv4_netmask = local.vm.ipv4_netmask } ipv4_gateway = local.vm.ipv4_gateway dns_server_list = local.vm.dns_server_list } }

cdrom { client_device = true }

extra_config = { "guestinfo.metadata" = base64gzip(jsonencode({ "instance-id": local.vm.hostname, })), "guestinfo.metadata.encoding" = "gzip+base64", "guestinfo.userdata" = data.cloudinit_config.userdata.rendered, "guestinfo.userdata.encoding" = "gzip+base64" }

how to pass userdata via terraform

How do you pass the userdata to cloudbase-init via terraform?

Answer...

Software Software \ Platform: VMware 7.0 Cloudbase-init Version: 1.1.4 x64 Target: Windows Server 2022 OVF template Terraform Providers: hashicorp/vsphere, hashicorp/cloudinit

• cloudbase-init-unattend.conf [DEFAULT] username=Administrator groups=Administrators inject_user_password=true config_drive_raw_hhd=false config_drive_cdrom=false config_drive_vfat=false bsdtar_path=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\bin\bsdtar.exe mtools_path=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\bin\ verbose=true debug=true log_dir=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\log\ log_file=cloudbase-init-unattend.log default_log_levels=comtypes=INFO,suds=INFO,iso8601=WARN,requests=WARN logging_serial_port_settings= mtu_use_dhcp_config=false ntp_use_dhcp_config=false local_scripts_path=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\LocalScripts\ check_latest_version=false metadata_services=cloudbaseinit.metadata.services.vmwareguestinfoservice.VMwareGuestInfoService plugins=cloudbaseinit.plugins.common.userdata.UserDataPlugin allow_reboot=false stop_service_on_exit=false

• cloudbase-init.conf [DEFAULT] username=Administrator groups=Administrators first_logon_behaviour=always inject_user_password=true config_drive_raw_hhd=false config_drive_cdrom=false config_drive_vfat=false bsdtar_path=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\bin\bsdtar.exe mtools_path=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\bin\ verbose=true debug=true log_dir=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\log\ log_file=cloudbase-init.log default_log_levels=comtypes=INFO,suds=INFO,iso8601=WARN,requests=WARN logging_serial_port_settings= mtu_use_dhcp_config=false ntp_use_dhcp_config=false local_scripts_path=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\LocalScripts\ check_latest_version=false metadata_services=cloudbaseinit.metadata.services.vmwareguestinfoservice.VMwareGuestInfoService netbios_host_name_compatibility=false

• cloudinit.tf (hashicorp/cloudinit) data "cloudinit_config" "userdata" { gzip = true base64_encode = true

part { filename = "userdata.yml" content_type = "text/cloud-config" content = templatefile("${path.module}/cloudinit/userdata.yml", {}) } }

• vm.tf (hashicorp/vsphere, excerpt) clone { template_uuid = data.vsphere_content_library_item.content_library_item.id customize { windows_options { computer_name = local.vm.hostname workgroup = local.vm.workgroup admin_password = local.vm.admin_password time_zone = local.vm.time_zone } network_interface { ipv4_address = local.vm.ipv4_address ipv4_netmask = local.vm.ipv4_netmask } ipv4_gateway = local.vm.ipv4_gateway dns_server_list = local.vm.dns_server_list } }

cdrom { client_device = true }

extra_config = { "guestinfo.metadata" = base64gzip(jsonencode({ "instance-id": local.vm.hostname, })), "guestinfo.metadata.encoding" = "gzip+base64", "guestinfo.userdata" = data.cloudinit_config.userdata.rendered, "guestinfo.userdata.encoding" = "gzip+base64" }

how to pass userdata via terraform

How do you pass the userdata to cloudbase-init via terraform?

Answer...

Software \ Software

Platform: VMware 7.0 7.0

Cloudbase-init Version: 1.1.4 x64 x64

Target: Windows Server 2022 OVF template template

Terraform Providers: hashicorp/vsphere, hashicorp/cloudinit

• cloudbase-init-unattend.conf [DEFAULT] username=Administrator groups=Administrators inject_user_password=true config_drive_raw_hhd=false config_drive_cdrom=false config_drive_vfat=false bsdtar_path=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\bin\bsdtar.exe mtools_path=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\bin\ verbose=true debug=true log_dir=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\log\ log_file=cloudbase-init-unattend.log default_log_levels=comtypes=INFO,suds=INFO,iso8601=WARN,requests=WARN logging_serial_port_settings= mtu_use_dhcp_config=false ntp_use_dhcp_config=false local_scripts_path=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\LocalScripts\ check_latest_version=false metadata_services=cloudbaseinit.metadata.services.vmwareguestinfoservice.VMwareGuestInfoService plugins=cloudbaseinit.plugins.common.userdata.UserDataPlugin allow_reboot=false stop_service_on_exit=false

• cloudbase-init.conf [DEFAULT] username=Administrator groups=Administrators first_logon_behaviour=always inject_user_password=true config_drive_raw_hhd=false config_drive_cdrom=false config_drive_vfat=false bsdtar_path=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\bin\bsdtar.exe mtools_path=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\bin\ verbose=true debug=true log_dir=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\log\ log_file=cloudbase-init.log default_log_levels=comtypes=INFO,suds=INFO,iso8601=WARN,requests=WARN logging_serial_port_settings= mtu_use_dhcp_config=false ntp_use_dhcp_config=false local_scripts_path=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\LocalScripts\ check_latest_version=false metadata_services=cloudbaseinit.metadata.services.vmwareguestinfoservice.VMwareGuestInfoService netbios_host_name_compatibility=false

• cloudinit.tf (hashicorp/cloudinit) data "cloudinit_config" "userdata" { gzip = true base64_encode = true

part { filename = "userdata.yml" content_type = "text/cloud-config" content = templatefile("${path.module}/cloudinit/userdata.yml", {}) } }

• vm.tf (hashicorp/vsphere, excerpt) clone { template_uuid = data.vsphere_content_library_item.content_library_item.id customize { windows_options { computer_name = local.vm.hostname workgroup = local.vm.workgroup admin_password = local.vm.admin_password time_zone = local.vm.time_zone } network_interface { ipv4_address = local.vm.ipv4_address ipv4_netmask = local.vm.ipv4_netmask } ipv4_gateway = local.vm.ipv4_gateway dns_server_list = local.vm.dns_server_list } }

cdrom { client_device = true }

extra_config = { "guestinfo.metadata" = base64gzip(jsonencode({ "instance-id": local.vm.hostname, })), "guestinfo.metadata.encoding" = "gzip+base64", "guestinfo.userdata" = data.cloudinit_config.userdata.rendered, "guestinfo.userdata.encoding" = "gzip+base64" }

how to pass userdata via terraform

How do you pass the userdata to cloudbase-init via terraform?

Answer...

Software

Software\ Platform: VMware 7.0

Cloudbase-init Version: 1.1.4 x64

Target: Windows Server 2022 OVF template

Terraform Providers: hashicorp/vsphere, hashicorp/cloudinit

• cloudbase-init-unattend.conf [DEFAULT] username=Administrator groups=Administrators inject_user_password=true config_drive_raw_hhd=false config_drive_cdrom=false config_drive_vfat=false bsdtar_path=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\bin\bsdtar.exe mtools_path=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\bin\ verbose=true debug=true log_dir=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\log\ log_file=cloudbase-init-unattend.log default_log_levels=comtypes=INFO,suds=INFO,iso8601=WARN,requests=WARN logging_serial_port_settings= mtu_use_dhcp_config=false ntp_use_dhcp_config=false local_scripts_path=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\LocalScripts\ check_latest_version=false metadata_services=cloudbaseinit.metadata.services.vmwareguestinfoservice.VMwareGuestInfoService plugins=cloudbaseinit.plugins.common.userdata.UserDataPlugin allow_reboot=false stop_service_on_exit=false

• cloudbase-init.conf [DEFAULT] username=Administrator groups=Administrators first_logon_behaviour=always inject_user_password=true config_drive_raw_hhd=false config_drive_cdrom=false config_drive_vfat=false bsdtar_path=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\bin\bsdtar.exe mtools_path=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\bin\ verbose=true debug=true log_dir=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\log\ log_file=cloudbase-init.log default_log_levels=comtypes=INFO,suds=INFO,iso8601=WARN,requests=WARN logging_serial_port_settings= mtu_use_dhcp_config=false ntp_use_dhcp_config=false local_scripts_path=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\LocalScripts\ check_latest_version=false metadata_services=cloudbaseinit.metadata.services.vmwareguestinfoservice.VMwareGuestInfoService netbios_host_name_compatibility=false

• cloudinit.tf (hashicorp/cloudinit) data "cloudinit_config" "userdata" { gzip = true base64_encode = true

part { filename = "userdata.yml" content_type = "text/cloud-config" content = templatefile("${path.module}/cloudinit/userdata.yml", {}) } }

• vm.tf (hashicorp/vsphere, excerpt) clone { template_uuid = data.vsphere_content_library_item.content_library_item.id customize { windows_options { computer_name = local.vm.hostname workgroup = local.vm.workgroup admin_password = local.vm.admin_password time_zone = local.vm.time_zone } network_interface { ipv4_address = local.vm.ipv4_address ipv4_netmask = local.vm.ipv4_netmask } ipv4_gateway = local.vm.ipv4_gateway dns_server_list = local.vm.dns_server_list } }

cdrom { client_device = true }

extra_config = { "guestinfo.metadata" = base64gzip(jsonencode({ "instance-id": local.vm.hostname, })), "guestinfo.metadata.encoding" = "gzip+base64", "guestinfo.userdata" = data.cloudinit_config.userdata.rendered, "guestinfo.userdata.encoding" = "gzip+base64" }

how to pass userdata via terraform

How do you pass the userdata to cloudbase-init via terraform?

Answer...

Software\ Platform: Software \Platform: VMware 7.0

Cloudbase-init Version: 1.1.4 x64

Target: Windows Server 2022 OVF template

Terraform Providers: hashicorp/vsphere, hashicorp/cloudinit

• cloudbase-init-unattend.conf [DEFAULT] username=Administrator groups=Administrators inject_user_password=true config_drive_raw_hhd=false config_drive_cdrom=false config_drive_vfat=false bsdtar_path=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\bin\bsdtar.exe mtools_path=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\bin\ verbose=true debug=true log_dir=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\log\ log_file=cloudbase-init-unattend.log default_log_levels=comtypes=INFO,suds=INFO,iso8601=WARN,requests=WARN logging_serial_port_settings= mtu_use_dhcp_config=false ntp_use_dhcp_config=false local_scripts_path=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\LocalScripts\ check_latest_version=false metadata_services=cloudbaseinit.metadata.services.vmwareguestinfoservice.VMwareGuestInfoService plugins=cloudbaseinit.plugins.common.userdata.UserDataPlugin allow_reboot=false stop_service_on_exit=false

• cloudbase-init.conf [DEFAULT] username=Administrator groups=Administrators first_logon_behaviour=always inject_user_password=true config_drive_raw_hhd=false config_drive_cdrom=false config_drive_vfat=false bsdtar_path=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\bin\bsdtar.exe mtools_path=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\bin\ verbose=true debug=true log_dir=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\log\ log_file=cloudbase-init.log default_log_levels=comtypes=INFO,suds=INFO,iso8601=WARN,requests=WARN logging_serial_port_settings= mtu_use_dhcp_config=false ntp_use_dhcp_config=false local_scripts_path=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\LocalScripts\ check_latest_version=false metadata_services=cloudbaseinit.metadata.services.vmwareguestinfoservice.VMwareGuestInfoService netbios_host_name_compatibility=false

• cloudinit.tf (hashicorp/cloudinit) data "cloudinit_config" "userdata" { gzip = true base64_encode = true

part { filename = "userdata.yml" content_type = "text/cloud-config" content = templatefile("${path.module}/cloudinit/userdata.yml", {}) } }

• vm.tf (hashicorp/vsphere, excerpt) clone { template_uuid = data.vsphere_content_library_item.content_library_item.id customize { windows_options { computer_name = local.vm.hostname workgroup = local.vm.workgroup admin_password = local.vm.admin_password time_zone = local.vm.time_zone } network_interface { ipv4_address = local.vm.ipv4_address ipv4_netmask = local.vm.ipv4_netmask } ipv4_gateway = local.vm.ipv4_gateway dns_server_list = local.vm.dns_server_list } }

cdrom { client_device = true }

extra_config = { "guestinfo.metadata" = base64gzip(jsonencode({ "instance-id": local.vm.hostname, })), "guestinfo.metadata.encoding" = "gzip+base64", "guestinfo.userdata" = data.cloudinit_config.userdata.rendered, "guestinfo.userdata.encoding" = "gzip+base64" }

how to pass userdata via terraform

How do you pass the userdata to cloudbase-init via terraform?

Answer...

Software \Platform: Software\r\n Platform: VMware 7.0

Cloudbase-init Version: 1.1.4 x64

Target: Windows Server 2022 OVF template

Terraform Providers: hashicorp/vsphere, hashicorp/cloudinit

cloudbase-init-unattend.conf [DEFAULT] username=Administrator groups=Administrators inject_user_password=true config_drive_raw_hhd=false config_drive_cdrom=false config_drive_vfat=false cloudbase-init-unattend.conf

[DEFAULT]

username=Administrator

groups=Administrators

inject_user_password=true

config_drive_raw_hhd=false

config_drive_cdrom=false

config_drive_vfat=false

bsdtar_path=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\bin\bsdtar.exe Solutions\Cloudbase-Init\bin\bsdtar.exe

mtools_path=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\bin\ verbose=true debug=true Solutions\Cloudbase-Init\bin\

verbose=true

debug=true

log_dir=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\log\ log_file=cloudbase-init-unattend.log default_log_levels=comtypes=INFO,suds=INFO,iso8601=WARN,requests=WARN logging_serial_port_settings= mtu_use_dhcp_config=false ntp_use_dhcp_config=false Solutions\Cloudbase-Init\log\

log_file=cloudbase-init-unattend.log

default_log_levels=comtypes=INFO,suds=INFO,iso8601=WARN,requests=WARN

logging_serial_port_settings=

mtu_use_dhcp_config=false

ntp_use_dhcp_config=false

local_scripts_path=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\LocalScripts\ check_latest_version=false metadata_services=cloudbaseinit.metadata.services.vmwareguestinfoservice.VMwareGuestInfoService plugins=cloudbaseinit.plugins.common.userdata.UserDataPlugin allow_reboot=false Solutions\Cloudbase-Init\LocalScripts\

check_latest_version=false

metadata_services=cloudbaseinit.metadata.services.vmwareguestinfoservice.VMwareGuestInfoService

plugins=cloudbaseinit.plugins.common.userdata.UserDataPlugin

allow_reboot=false

stop_service_on_exit=false

cloudbase-init.conf [DEFAULT] username=Administrator groups=Administrators first_logon_behaviour=always inject_user_password=true config_drive_raw_hhd=false config_drive_cdrom=false config_drive_vfat=false cloudbase-init.conf

[DEFAULT]

username=Administrator

groups=Administrators

first_logon_behaviour=always

inject_user_password=true

config_drive_raw_hhd=false

config_drive_cdrom=false

config_drive_vfat=false

bsdtar_path=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\bin\bsdtar.exe Solutions\Cloudbase-Init\bin\bsdtar.exe

mtools_path=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\bin\ verbose=true debug=true Solutions\Cloudbase-Init\bin\

verbose=true

debug=true

log_dir=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\log\ log_file=cloudbase-init.log default_log_levels=comtypes=INFO,suds=INFO,iso8601=WARN,requests=WARN logging_serial_port_settings= mtu_use_dhcp_config=false ntp_use_dhcp_config=false Solutions\Cloudbase-Init\log\

log_file=cloudbase-init.log

default_log_levels=comtypes=INFO,suds=INFO,iso8601=WARN,requests=WARN

logging_serial_port_settings=

mtu_use_dhcp_config=false

ntp_use_dhcp_config=false

local_scripts_path=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\LocalScripts\ check_latest_version=false metadata_services=cloudbaseinit.metadata.services.vmwareguestinfoservice.VMwareGuestInfoService Solutions\Cloudbase-Init\LocalScripts\

check_latest_version=false

metadata_services=cloudbaseinit.metadata.services.vmwareguestinfoservice.VMwareGuestInfoService

netbios_host_name_compatibility=false

• cloudinit.tf (hashicorp/cloudinit) data "cloudinit_config" "userdata" { gzip = true base64_encode = true

part { filename = "userdata.yml" content_type = "text/cloud-config" content = templatefile("${path.module}/cloudinit/userdata.yml", {}) } }

• vm.tf (hashicorp/vsphere, excerpt) clone { template_uuid = data.vsphere_content_library_item.content_library_item.id customize { windows_options { computer_name = local.vm.hostname workgroup = local.vm.workgroup admin_password = local.vm.admin_password time_zone = local.vm.time_zone } network_interface { ipv4_address = local.vm.ipv4_address ipv4_netmask = local.vm.ipv4_netmask } ipv4_gateway = local.vm.ipv4_gateway dns_server_list = local.vm.dns_server_list } }

cdrom { client_device = true }

extra_config = { "guestinfo.metadata" = base64gzip(jsonencode({ "instance-id": local.vm.hostname, })), "guestinfo.metadata.encoding" = "gzip+base64", "guestinfo.userdata" = data.cloudinit_config.userdata.rendered, "guestinfo.userdata.encoding" = "gzip+base64" }

how to pass userdata via terraform

How do you pass the userdata to cloudbase-init via terraform?

Answer...

Software\r\n
Software
Platform: VMware 7.0

7.0 Cloudbase-init Version: 1.1.4 x64

x64 Target: Windows Server 2022 OVF template

template Terraform Providers: hashicorp/vsphere, hashicorp/cloudinit

hashicorp/cloudinit cloudbase-init-unattend.conf

[DEFAULT]

username=Administrator

groups=Administrators

inject_user_password=true

config_drive_raw_hhd=false

config_drive_cdrom=false

config_drive_vfat=false

bsdtar_path=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\bin\bsdtar.exe

mtools_path=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\bin\

verbose=true

debug=true

log_dir=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\log\

log_file=cloudbase-init-unattend.log

default_log_levels=comtypes=INFO,suds=INFO,iso8601=WARN,requests=WARN

logging_serial_port_settings=

mtu_use_dhcp_config=false

ntp_use_dhcp_config=false

local_scripts_path=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\LocalScripts\

check_latest_version=false

metadata_services=cloudbaseinit.metadata.services.vmwareguestinfoservice.VMwareGuestInfoService

plugins=cloudbaseinit.plugins.common.userdata.UserDataPlugin

allow_reboot=false

stop_service_on_exit=false

cloudbase-init-unattend.conf [DEFAULT] username=Administrator groups=Administrators inject\_user\_password=true config\_drive\_raw\_hhd=false config\_drive\_cdrom=false config\_drive\_vfat=false bsdtar\_path=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\bin\bsdtar.exe mtools\_path=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\bin\ verbose=true debug=true log\_dir=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\log\ log\_file=cloudbase-init-unattend.log default\_log\_levels=comtypes=INFO,suds=INFO,iso8601=WARN,requests=WARN logging\_serial\_port\_settings= mtu\_use\_dhcp\_config=false ntp\_use\_dhcp\_config=false local\_scripts\_path=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\LocalScripts\ check\_latest\_version=false metadata\_services=cloudbaseinit.metadata.services.vmwareguestinfoservice.VMwareGuestInfoService plugins=cloudbaseinit.plugins.common.userdata.UserDataPlugin allow\_reboot=false stop\_service\_on\_exit=false cloudbase-init.conf

[DEFAULT]

username=Administrator

groups=Administrators

first_logon_behaviour=always

inject_user_password=true

config_drive_raw_hhd=false

config_drive_cdrom=false

config_drive_vfat=false

bsdtar_path=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\bin\bsdtar.exe

mtools_path=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\bin\

verbose=true

debug=true

log_dir=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\log\

log_file=cloudbase-init.log

default_log_levels=comtypes=INFO,suds=INFO,iso8601=WARN,requests=WARN

logging_serial_port_settings=

mtu_use_dhcp_config=false

ntp_use_dhcp_config=false

local_scripts_path=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\LocalScripts\

check_latest_version=false

metadata_services=cloudbaseinit.metadata.services.vmwareguestinfoservice.VMwareGuestInfoService

netbios_host_name_compatibility=false

cloudbase-init.conf [DEFAULT] username=Administrator groups=Administrators first\_logon\_behaviour=always inject\_user\_password=true config\_drive\_raw\_hhd=false config\_drive\_cdrom=false config\_drive\_vfat=false bsdtar\_path=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\bin\bsdtar.exe mtools\_path=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\bin\ verbose=true debug=true log\_dir=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\log\ log\_file=cloudbase-init.log default\_log\_levels=comtypes=INFO,suds=INFO,iso8601=WARN,requests=WARN logging\_serial\_port\_settings= mtu\_use\_dhcp\_config=false ntp\_use\_dhcp\_config=false local\_scripts\_path=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\LocalScripts\ check\_latest\_version=false metadata\_services=cloudbaseinit.metadata.services.vmwareguestinfoservice.VMwareGuestInfoService netbios\_host\_name\_compatibility=false • cloudinit.tf (hashicorp/cloudinit) data "cloudinit_config" "cloudinit\_config" "userdata" { gzip = true base64_encode = true

base64\_encode = true part { filename = "userdata.yml" content_type content\_type = "text/cloud-config" content = templatefile("${path.module}/cloudinit/userdata.yml", {}) } }

} • vm.tf (hashicorp/vsphere, excerpt) clone { template_uuid = data.vsphere_content_library_item.content_library_item.id template\_uuid = data.vsphere\_content\_library\_item.content\_library\_item.id customize { windows_options { computer_name windows\_options { computer\_name = local.vm.hostname workgroup = local.vm.workgroup admin_password = local.vm.admin_password time_zone = local.vm.time_zone } network_interface { ipv4_address = local.vm.ipv4_address ipv4_netmask = local.vm.ipv4_netmask } ipv4_gateway = local.vm.ipv4_gateway dns_server_list = local.vm.dns_server_list } }

admin\_password = local.vm.admin\_password time\_zone = local.vm.time\_zone } network\_interface { ipv4\_address = local.vm.ipv4\_address ipv4\_netmask = local.vm.ipv4\_netmask } ipv4\_gateway = local.vm.ipv4\_gateway dns\_server\_list = local.vm.dns\_server\_list } } cdrom { client_device client\_device = true }

extra_config } extra\_config = { "guestinfo.metadata" = base64gzip(jsonencode({ "instance-id": local.vm.hostname, })), "guestinfo.metadata.encoding" = "gzip+base64", "guestinfo.userdata" = data.cloudinit_config.userdata.rendered, data.cloudinit\_config.userdata.rendered, "guestinfo.userdata.encoding" = "gzip+base64" }

}

how to pass userdata via terraform

How do you pass the userdata to cloudbase-init via terraform?

Answer...

terraform?

Answer...

• Software
Platform: VMware 7.0
 Cloudbase-init Version: 1.1.4 x64
 Target: Windows Server 2022 OVF template
 Terraform Providers: hashicorp/vsphere, hashicorp/cloudinit

• cloudbase-init-unattend.conf

[DEFAULT]

username=Administrator

groups=Administrators

inject\_user\_password=true

config\_drive\_raw\_hhd=false

config\_drive\_cdrom=false

config\_drive\_vfat=false

bsdtar\_path=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\bin\bsdtar.exe

mtools\_path=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\bin\

verbose=true

debug=true

log\_dir=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\log\

log\_file=cloudbase-init-unattend.log

default\_log\_levels=comtypes=INFO,suds=INFO,iso8601=WARN,requests=WARN

logging\_serial\_port\_settings=

mtu\_use\_dhcp\_config=false

ntp\_use\_dhcp\_config=false

local\_scripts\_path=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\LocalScripts\

check\_latest\_version=false

metadata\_services=cloudbaseinit.metadata.services.vmwareguestinfoservice.VMwareGuestInfoService

plugins=cloudbaseinit.plugins.common.userdata.UserDataPlugin

allow\_reboot=false

stop\_service\_on\_exit=false

• cloudbase-init.conf

[DEFAULT]

username=Administrator

groups=Administrators

first\_logon\_behaviour=always

inject\_user\_password=true

config\_drive\_raw\_hhd=false

config\_drive\_cdrom=false

config\_drive\_vfat=false

bsdtar\_path=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\bin\bsdtar.exe

mtools\_path=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\bin\

verbose=true

debug=true

log\_dir=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\log\

log\_file=cloudbase-init.log

default\_log\_levels=comtypes=INFO,suds=INFO,iso8601=WARN,requests=WARN

logging\_serial\_port\_settings=


mtu\_use\_dhcp\_config=false

ntp\_use\_dhcp\_config=false

local\_scripts\_path=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\LocalScripts\

check\_latest\_version=false

metadata\_services=cloudbaseinit.metadata.services.vmwareguestinfoservice.VMwareGuestInfoService

netbios\_host\_name\_compatibility=false

• cloudinit.tf (hashicorp/cloudinit)
data "cloudinit\_config" "userdata" {
  gzip          = true
  base64\_encode = true

  part {
    filename     = "userdata.yml"
    content\_type = "text/cloud-config"
    content      = templatefile("${path.module}/cloudinit/userdata.yml", {})
  }
}

• vm.tf (hashicorp/vsphere, excerpt)
  clone {
    template\_uuid = data.vsphere\_content\_library\_item.content\_library\_item.id
    customize {
      windows\_options {
        computer\_name = local.vm.hostname
        workgroup = local.vm.workgroup
        admin\_password = local.vm.admin\_password
        time\_zone = local.vm.time\_zone
      }
      network\_interface {
        ipv4\_address = local.vm.ipv4\_address
        ipv4\_netmask = local.vm.ipv4\_netmask
      }
      ipv4\_gateway    = local.vm.ipv4\_gateway
      dns\_server\_list = local.vm.dns\_server\_list
    }
  }

  cdrom {
    client\_device = true
  }

  extra\_config = {
    "guestinfo.metadata" = base64gzip(jsonencode({
    "instance-id": local.vm.hostname,
    })),
    "guestinfo.metadata.encoding" = "gzip+base64",
    "guestinfo.userdata" = data.cloudinit\_config.userdata.rendered,
    "guestinfo.userdata.encoding" = "gzip+base64"
  }

how to pass userdata via terraform

How do you pass the userdata to cloudbase-init via terraform?

Answer...

• Software
Platform: VMware 7.0
Cloudbase-init Version: 1.1.4 x64
Target: Windows Server 2022 OVF template
Terraform Providers: hashicorp/vsphere, hashicorp/cloudinit

• cloudbase-init-unattend.conf
 [DEFAULT]
 username=Administrator
 groups=Administrators

inject\_user\_password=true

config\_drive\_raw\_hhd=false

config\_drive\_cdrom=false

config\_drive\_vfat=false

bsdtar\_path=C:\Program inject_user_password=true
config_drive_raw_hhd=false
config_drive_cdrom=false
config_drive_vfat=false
bsdtar_path=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\bin\bsdtar.exe

mtools\_path=C:\Program mtools_path=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\bin\
 verbose=true
 debug=true

log\_dir=C:\Program log_dir=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\log\

log\_file=cloudbase-init-unattend.log

default\_log\_levels=comtypes=INFO,suds=INFO,iso8601=WARN,requests=WARN

logging\_serial\_port\_settings=

mtu\_use\_dhcp\_config=false

ntp\_use\_dhcp\_config=false

local\_scripts\_path=C:\Program log_file=cloudbase-init-unattend.log
default_log_levels=comtypes=INFO,suds=INFO,iso8601=WARN,requests=WARN
logging_serial_port_settings=
mtu_use_dhcp_config=false
ntp_use_dhcp_config=false
local_scripts_path=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\LocalScripts\

check\_latest\_version=false

metadata\_services=cloudbaseinit.metadata.services.vmwareguestinfoservice.VMwareGuestInfoService

check_latest_version=false
metadata_services=cloudbaseinit.metadata.services.vmwareguestinfoservice.VMwareGuestInfoService
plugins=cloudbaseinit.plugins.common.userdata.UserDataPlugin

allow\_reboot=false

stop\_service\_on\_exit=false
allow_reboot=false
stop_service_on_exit=false

• cloudbase-init.conf
 [DEFAULT]
 username=Administrator
 groups=Administrators

first\_logon\_behaviour=always

inject\_user\_password=true

config\_drive\_raw\_hhd=false

config\_drive\_cdrom=false

config\_drive\_vfat=false

bsdtar\_path=C:\Program first_logon_behaviour=always
inject_user_password=true
config_drive_raw_hhd=false
config_drive_cdrom=false
config_drive_vfat=false
bsdtar_path=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\bin\bsdtar.exe

mtools\_path=C:\Program mtools_path=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\bin\
 verbose=true
 debug=true

log\_dir=C:\Program log_dir=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\log\

log\_file=cloudbase-init.log

default\_log\_levels=comtypes=INFO,suds=INFO,iso8601=WARN,requests=WARN

logging\_serial\_port\_settings=


mtu\_use\_dhcp\_config=false

ntp\_use\_dhcp\_config=false

local\_scripts\_path=C:\Program log_file=cloudbase-init.log
default_log_levels=comtypes=INFO,suds=INFO,iso8601=WARN,requests=WARN
logging_serial_port_settings=
mtu_use_dhcp_config=false
ntp_use_dhcp_config=false
local_scripts_path=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\LocalScripts\

check\_latest\_version=false

metadata\_services=cloudbaseinit.metadata.services.vmwareguestinfoservice.VMwareGuestInfoService

netbios\_host\_name\_compatibility=false
check_latest_version=false
metadata_services=cloudbaseinit.metadata.services.vmwareguestinfoservice.VMwareGuestInfoService
netbios_host_name_compatibility=false

• cloudinit.tf (hashicorp/cloudinit)
data "cloudinit\_config" "cloudinit_config" "userdata" {
  gzip          = true
  base64\_encode base64_encode = true

  part {
    filename     = "userdata.yml"
    content\_type content_type = "text/cloud-config"
    content      = templatefile("${path.module}/cloudinit/userdata.yml", {})
  }
}

• vm.tf (hashicorp/vsphere, excerpt)
  clone {
    template\_uuid = data.vsphere\_content\_library\_item.content\_library\_item.id
template_uuid = data.vsphere_content_library_item.content_library_item.id
    customize {
      windows\_options {
        computer\_name windows_options {
        computer_name = local.vm.hostname
        workgroup = local.vm.workgroup
        admin\_password = local.vm.admin\_password
        time\_zone = local.vm.time\_zone
      }
      network\_interface {
        ipv4\_address = local.vm.ipv4\_address
        ipv4\_netmask = local.vm.ipv4\_netmask
      }
      ipv4\_gateway    = local.vm.ipv4\_gateway
      dns\_server\_list = local.vm.dns\_server\_list
admin_password = local.vm.admin_password
        time_zone = local.vm.time_zone
      }
      network_interface {
        ipv4_address = local.vm.ipv4_address
        ipv4_netmask = local.vm.ipv4_netmask
      }
      ipv4_gateway    = local.vm.ipv4_gateway
      dns_server_list = local.vm.dns_server_list
    }
  }

  cdrom {
    client\_device client_device = true
  }

  extra\_config extra_config = {
    "guestinfo.metadata" = base64gzip(jsonencode({
    "instance-id": local.vm.hostname,
    })),
    "guestinfo.metadata.encoding" = "gzip+base64",
    "guestinfo.userdata" = data.cloudinit\_config.userdata.rendered,
data.cloudinit_config.userdata.rendered,
    "guestinfo.userdata.encoding" = "gzip+base64"
  }

how to pass userdata via terraform

How do you pass the userdata to cloudbase-init via terraform?

Answer...

• Software
Platform: VMware 7.0
Cloudbase-init Version: 1.1.4 x64
Target: VM Template: Windows Server 2022 OVF template
OVF
Terraform Providers: hashicorp/vsphere, hashicorp/cloudinit

• cloudbase-init-unattend.conf
[DEFAULT]
username=Administrator
groups=Administrators
inject_user_password=true
config_drive_raw_hhd=false
config_drive_cdrom=false
config_drive_vfat=false
bsdtar_path=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\bin\bsdtar.exe
mtools_path=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\bin\
verbose=true
debug=true
log_dir=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\log\
log_file=cloudbase-init-unattend.log
default_log_levels=comtypes=INFO,suds=INFO,iso8601=WARN,requests=WARN
logging_serial_port_settings=
mtu_use_dhcp_config=false
ntp_use_dhcp_config=false
local_scripts_path=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\LocalScripts\
check_latest_version=false
metadata_services=cloudbaseinit.metadata.services.vmwareguestinfoservice.VMwareGuestInfoService
plugins=cloudbaseinit.plugins.common.userdata.UserDataPlugin
allow_reboot=false
stop_service_on_exit=false

• cloudbase-init.conf
[DEFAULT]
username=Administrator
groups=Administrators
first_logon_behaviour=always
inject_user_password=true
config_drive_raw_hhd=false
config_drive_cdrom=false
config_drive_vfat=false
bsdtar_path=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\bin\bsdtar.exe
mtools_path=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\bin\
verbose=true
debug=true
log_dir=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\log\
log_file=cloudbase-init.log
default_log_levels=comtypes=INFO,suds=INFO,iso8601=WARN,requests=WARN
logging_serial_port_settings=
mtu_use_dhcp_config=false
ntp_use_dhcp_config=false
local_scripts_path=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\LocalScripts\
check_latest_version=false
metadata_services=cloudbaseinit.metadata.services.vmwareguestinfoservice.VMwareGuestInfoService
netbios_host_name_compatibility=false

• cloudinit.tf (hashicorp/cloudinit)
data "cloudinit_config" "userdata" {
  gzip          = true
  base64_encode = true

  part {
    filename     = "userdata.yml"
    content_type = "text/cloud-config"
    content      = templatefile("${path.module}/cloudinit/userdata.yml", {})
  }
}

• vm.tf (hashicorp/vsphere, excerpt)
  clone {
    template_uuid = data.vsphere_content_library_item.content_library_item.id
    customize {
      windows_options {
        computer_name = local.vm.hostname
        workgroup = local.vm.workgroup
        admin_password = local.vm.admin_password
        time_zone = local.vm.time_zone
      }
      network_interface {
        ipv4_address = local.vm.ipv4_address
        ipv4_netmask = local.vm.ipv4_netmask
      }
      ipv4_gateway    = local.vm.ipv4_gateway
      dns_server_list = local.vm.dns_server_list
    }
  }

  cdrom {
    client_device = true
  }

  extra_config = {
    "guestinfo.metadata" = base64gzip(jsonencode({
    "instance-id": local.vm.hostname,
    })),
    "guestinfo.metadata.encoding" = "gzip+base64",
    "guestinfo.userdata" = data.cloudinit_config.userdata.rendered,
    "guestinfo.userdata.encoding" = "gzip+base64"
  }

how to pass userdata via terraform

How do you pass the userdata to cloudbase-init via terraform?

Answer...

• Software
Platform: VMware vSphere 7.0
Cloudbase-init Version: 1.1.4 x64
VM Template: Windows Server 2022 OVF
Terraform Providers: hashicorp/vsphere, hashicorp/cloudinit

• cloudbase-init-unattend.conf
[DEFAULT]
username=Administrator
groups=Administrators
inject_user_password=true
config_drive_raw_hhd=false
config_drive_cdrom=false
config_drive_vfat=false
bsdtar_path=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\bin\bsdtar.exe
mtools_path=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\bin\
verbose=true
debug=true
log_dir=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\log\
log_file=cloudbase-init-unattend.log
default_log_levels=comtypes=INFO,suds=INFO,iso8601=WARN,requests=WARN
logging_serial_port_settings=
mtu_use_dhcp_config=false
ntp_use_dhcp_config=false
local_scripts_path=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\LocalScripts\
check_latest_version=false
metadata_services=cloudbaseinit.metadata.services.vmwareguestinfoservice.VMwareGuestInfoService
plugins=cloudbaseinit.plugins.common.userdata.UserDataPlugin
allow_reboot=false
stop_service_on_exit=false

• cloudbase-init.conf
[DEFAULT]
username=Administrator
groups=Administrators
first_logon_behaviour=always
inject_user_password=true
config_drive_raw_hhd=false
config_drive_cdrom=false
config_drive_vfat=false
bsdtar_path=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\bin\bsdtar.exe
mtools_path=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\bin\
verbose=true
debug=true
log_dir=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\log\
log_file=cloudbase-init.log
default_log_levels=comtypes=INFO,suds=INFO,iso8601=WARN,requests=WARN
logging_serial_port_settings=
mtu_use_dhcp_config=false
ntp_use_dhcp_config=false
local_scripts_path=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\LocalScripts\
check_latest_version=false
metadata_services=cloudbaseinit.metadata.services.vmwareguestinfoservice.VMwareGuestInfoService
netbios_host_name_compatibility=false

• cloudinit.tf (hashicorp/cloudinit)
data "cloudinit_config" "userdata" {
  gzip          = true
  base64_encode = true

  part {
    filename     = "userdata.yml"
    content_type = "text/cloud-config"
    content      = templatefile("${path.module}/cloudinit/userdata.yml", {})
  }
}

• vm.tf (hashicorp/vsphere, excerpt)
  clone {
    template_uuid = data.vsphere_content_library_item.content_library_item.id
    customize {
      windows_options {
        computer_name = local.vm.hostname
        workgroup = local.vm.workgroup
        admin_password = local.vm.admin_password
        time_zone = local.vm.time_zone
      }
      network_interface {
        ipv4_address = local.vm.ipv4_address
        ipv4_netmask = local.vm.ipv4_netmask
      }
      ipv4_gateway    = local.vm.ipv4_gateway
      dns_server_list = local.vm.dns_server_list
    }
  }

  cdrom {
    client_device = true
  }

  extra_config = {
    "guestinfo.metadata" = base64gzip(jsonencode({
    "instance-id": local.vm.hostname,
    })),
    "guestinfo.metadata.encoding" = "gzip+base64",
    "guestinfo.userdata" = data.cloudinit_config.userdata.rendered,
    "guestinfo.userdata.encoding" = "gzip+base64"
  }

how to pass userdata via terraform

How do you pass the userdata to cloudbase-init via terraform?

Answer...

• Software
Platform: VMware vSphere 7.0
Cloudbase-init Version: 1.1.4 x64
VM Template: Windows Server 2022 OVF
Terraform Providers: hashicorp/vsphere, hashicorp/cloudinit

• cloudbase-init-unattend.conf
[DEFAULT]
username=Administrator
groups=Administrators
inject_user_password=true
config_drive_raw_hhd=false
config_drive_cdrom=false
config_drive_vfat=false
bsdtar_path=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\bin\bsdtar.exe
mtools_path=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\bin\
verbose=true
debug=true
log_dir=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\log\
log_file=cloudbase-init-unattend.log
default_log_levels=comtypes=INFO,suds=INFO,iso8601=WARN,requests=WARN
logging_serial_port_settings=
mtu_use_dhcp_config=false
ntp_use_dhcp_config=false
local_scripts_path=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\LocalScripts\
check_latest_version=false
metadata_services=cloudbaseinit.metadata.services.vmwareguestinfoservice.VMwareGuestInfoService
plugins=cloudbaseinit.plugins.common.userdata.UserDataPlugin
allow_reboot=false
stop_service_on_exit=false

• cloudbase-init.conf
[DEFAULT]
username=Administrator
groups=Administrators
first_logon_behaviour=always
inject_user_password=true
config_drive_raw_hhd=false
config_drive_cdrom=false
config_drive_vfat=false
bsdtar_path=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\bin\bsdtar.exe
mtools_path=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\bin\
verbose=true
debug=true
log_dir=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\log\
log_file=cloudbase-init.log
default_log_levels=comtypes=INFO,suds=INFO,iso8601=WARN,requests=WARN
logging_serial_port_settings=
mtu_use_dhcp_config=false
ntp_use_dhcp_config=false
local_scripts_path=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\LocalScripts\
check_latest_version=false
metadata_services=cloudbaseinit.metadata.services.vmwareguestinfoservice.VMwareGuestInfoService
netbios_host_name_compatibility=false

• cloudinit.tf (hashicorp/cloudinit)
data "cloudinit_config" "userdata" {
  gzip          = true
  base64_encode = true

  part {
    filename     = "userdata.yml"
    content_type = "text/cloud-config"
    content      = templatefile("${path.module}/cloudinit/userdata.yml", {})
  }
}

• vm.tf (hashicorp/vsphere, excerpt)
  clone {
    template_uuid = data.vsphere_content_library_item.content_library_item.id
    customize {
      windows_options {
        computer_name = local.vm.hostname
        workgroup = local.vm.workgroup
        admin_password = local.vm.admin_password
        time_zone = local.vm.time_zone
      }
      network_interface {
        ipv4_address = local.vm.ipv4_address
        ipv4_netmask = local.vm.ipv4_netmask
      }
      ipv4_gateway    = local.vm.ipv4_gateway
      dns_server_list = local.vm.dns_server_list
    }
  }

  cdrom {
    client_device = true
  }

  extra_config = {
    "guestinfo.metadata" = base64gzip(jsonencode({
    "instance-id": local.vm.hostname,
    })),
    "guestinfo.metadata.encoding" = "gzip+base64",
    "guestinfo.userdata" = data.cloudinit_config.userdata.rendered,
    "guestinfo.userdata.encoding" = "gzip+base64"
  }