-
Notifications
You must be signed in to change notification settings - Fork 454
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 deploy of Ubuntu 22.04.3 LTS customised with cloud-init resets to DHCP after reboot. #2041
Comments
Hello, mrdanielmartins! 🖐 Thank you for submitting an issue for this provider. The issue will now enter into the issue lifecycle. If you want to contribute to this project, please review the contributing guidelines and information on submitting pull requests. |
Your configuration look correct. It's the same that I apply to Ubuntu with Ansible during the Packer build in Packer Examples for VMware vSphere project. rm -rf /etc/cloud/cloud.cfg.d/subiquity-disable-cloudinit-networking.cfg
rm -rf /etc/cloud/cloud.cfg.d/99-installer.cfg
rm -rf /etc/netplan/00-installer-config.yaml
echo "disable_vmware_customization: false" >> /etc/cloud/cloud.cfg
echo "datasource_list: [ VMware, OVF, None ]" > /etc/cloud/cloud.cfg.d/90_dpkg.cfg Once you do that, you will customize with resource "vsphere_virtual_machine" "vm" {
name = var.vm_name
folder = var.vsphere_folder
num_cpus = var.vm_cpus
memory = var.vm_memory
firmware = var.vm_firmware
efi_secure_boot_enabled = var.vm_efi_secure_boot_enabled
guest_id = data.vsphere_virtual_machine.template.guest_id
datastore_id = data.vsphere_datastore.datastore.id
resource_pool_id = data.vsphere_resource_pool.pool.id
network_interface {
network_id = data.vsphere_network.network.id
}
disk {
label = "disk0"
size = data.vsphere_virtual_machine.template.disks.0.size
eagerly_scrub = data.vsphere_virtual_machine.template.disks.0.eagerly_scrub
thin_provisioned = data.vsphere_virtual_machine.template.disks.0.thin_provisioned
}
clone {
template_uuid = data.vsphere_virtual_machine.template.id
}
lifecycle {
ignore_changes = [
clone[0].template_uuid,
]
}
extra_config = {
"guestinfo.metadata" = base64encode(file("${path.module}/metadata.yml"))
"guestinfo.metadata.encoding" = "base64"
"guestinfo.userdata" = base64encode(file("${path.module}/userdata.yml"))
"guestinfo.userdata.encoding" = "base64"
}
} Example: tenthirtyam/terrafom-examples-vmware |
Good morning @tenthirtyam, That repo is amazing! I'll give the Sure the VMware bit makes sense. I was using this VMware KB 90331 which lists a solution using Perl and cloud-init together. However, I've just read through it again, and it specifies only that user-data (which I wasn't doing in the first place) is to be provided to cloud-init. I'll also give this a go now that I've got your illustration with the exta_config block. Thank you Daniel |
Hello. I have the same issue, but your fix doesn't work in full. I run the next commands:
Don't run the command
Now only the problem with DNS. Could you please help me fix it? My full the clone part:
|
You should be customizing with cloud-init using extra_config, See https://github.com/tenthirtyam/terrafom-examples-vmware/tree/main/vsphere/vsphere-virtual-machine/clone-template-linux-cloud-init for an example using cloud-init. If you don't want to use cloud-init you can simply remove it with apt and not make any of the changes above. |
Hmm...I'm using the terraform for Rocky Linux and Ubuntu. For Rocky works fine. |
@tenthirtyam And should I change my extra_config all time for each VM if I have static IP for each? |
For now, yes. There is an open issue for extra_config not working with dynamic blocks. |
@tenthirtyam let me know when the problem is solved please |
As a commenter, you will |
@tenthirtyam main.tf
matadata.yml
It works fine and I can set up different network settings for each virtual machine.
But I have to add additional routes to VMs. For that I add to metadata.yml file the next lines:
To main.tf I add:
And to file with VM:
And in this case, when I'm adding routes they are not transferable to VM and not working. |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
Community Guidelines
Terraform
1.6.1
Terraform Provider
2.5.1
VMware vSphere
7.0.3o
Description
Excuse me, I've tried various bets across the internet, from blogs to VMware docs, but I'm still far from solving this issue I'm facing.
Overview
Ubuntu VM has cloud-init enabled, and Terraform assigns static IP. Upon reboot, the VM loses its static IP configuration.
What is strange is the static IP customisation seems to be configured on the
50-cloud-init.yaml
, which, of course, does not persist after a reboot.Please do pardon me if this is not the correct place to raise the issue I'm facing!
What I've tried as part of the VM template
subiquity-disable-cloudinit-networking.cfg
etc/cloud/cloud.cfg.d/99-installer.cfg
disable_vmware_customization: false
to/etc/cloud/cloud.cfg
datasource_list
the values ofOVF
andVMware
Cloud-init version for the VM is
cloud-init 23.3.1-0ubuntu1~22.04.1
.Am I going entirely about this incorrectly, and this is expected behaviour?
Affected Resources or Data Sources
resource vsphere_virtual_machine
Terraform Configuration
Debug Output
I can provide a debug later.
Panic Output
No response
Expected Behavior
Static IP to persist after reboot.
Actual Behavior
Static IP resets to DHCP.
Steps to Reproduce
Terraform apply on a custom Packer VM Ubuntu image.
Environment Details
No response
Screenshots
No response
References
No response
The text was updated successfully, but these errors were encountered: