Community discussions

MikroTik App
 
KellyT
just joined
Topic Author
Posts: 1
Joined: Wed Aug 10, 2022 9:06 pm

Deploying RouterOS CHR via Terraform

Wed Aug 10, 2022 9:19 pm

Good day,

I've been trying to deploy RouterOS CHR version 7.5 beta 8 using Terraform, and although the VM deploys, the overall deployment fails due to linux_customization.

To accomplish this, I installed RouterOS on my server as normal, and then simply created a template from the VM.

I then reference the RouterOS template inside the Terraform script.

When the Terraform script is executed, the VM gets deployed and powers on, but the interfaces are in a 'disconnected' state, and Terraform throws the following error:
Virtual machine customization failed on "/xxx/xxx/xxx/R05A-RTR-Edge":
An error occurred while customizing VM R05A-RTR-Edge. For details reference the log file <No Log> in the guest OS.
The virtual machine has not been deleted to assist with troubleshooting. If
corrective steps are taken without modifying the "customize" block of the
resource configuration, the resource will need to be tainted before trying
again. For more information on how to do this, see the following page:
https://www.terraform.io/docs/commands/taint.html
And this is my Terraform script
resource "vsphere_virtual_machine" "BS-CORE-RTR" {
  name                          = "${var.RGE_PREFIX}-RTR-Edge"        
  folder                        = "${vsphere_folder.Networking.path}"
  resource_pool_id              = "${data.vsphere_resource_pool.pool.id}"
  datastore_id                  = "${data.vsphere_datastore.datastore.id}"
  num_cpus                      = 1
  memory                        = 1024
  guest_id                      = "${data.vsphere_virtual_machine.MikrotikRouter.guest_id}"
  scsi_type                     = "lsilogic"
  firmware                      = "bios"
  wait_for_guest_net_timeout    = -1
 
  network_interface {
    network_id                  = "${data.vsphere_network.VLAN-3.id}"
    adapter_type                = "vmxnet3"
  }

  network_interface {
    network_id                  = "${data.vsphere_network.VLAN-4.id}"
    adapter_type                = "vmxnet3"
  }
 
  disk {
    label                       = "disk0"
    size                        = "${data.vsphere_virtual_machine.MikrotikRouter.disks.0.size}"
    eagerly_scrub               = "${data.vsphere_virtual_machine.MikrotikRouter.disks.0.eagerly_scrub}"
    thin_provisioned            = "${data.vsphere_virtual_machine.MikrotikRouter.disks.0.thin_provisioned}"
  }
 
  clone {
    template_uuid               = "${data.vsphere_virtual_machine.MikrotikRouter.id}"

    customize {
      linux_options {
        host_name             = "r05a-rtr-edge"
        domain                = "local.net"
        #time_zone             = 85
      }

      network_interface {
        ipv4_address            = "172.16.1.1"
        ipv4_netmask            = 24
       }

      network_interface {
        ipv4_address            = "172.16.2.1"
        ipv4_netmask            = 24
       }

      ipv4_gateway = "172.16.1.1"
      dns_server_list = ["16.0.0.21"]
    }
  }
}
Any help getting past this hurdle would be appreciated - as I would like to use RouterOS in my labs.

Kelly

Who is online

Users browsing this forum: No registered users and 8 guests