terraform-routeros / terraform-provider-routeros

Terraform Provider for Mikrotik RouterOS
Mozilla Public License 2.0
200 stars 56 forks source link

reboot router and wait #526

Closed Schwitzd closed 2 months ago

Schwitzd commented 2 months ago

Is your feature request related to a problem? Please describe. To apply apply contain resources is needed to manually reboot the router, for example to load the container package.

I have the following code to upload the container package:

resource "null_resource" "upload_container_npk" {
  provisioner "local-exec" {
    command = "scp \"/tmp/routeros_packages/${local.container_npk_name}\" ${data.vault_generic_secret.mikrotik.data["user"]}@${var.router_ip}:/${local.container_npk_name}"
  }

  depends_on = [ null_resource.download_container_npk ]
}

But then I need to manually reboot. I'm looking for a way to reboot the router, wait the reboot time and continue to provision other resources.

Describe the solution you'd like M/A

Documentation Seems there is an endpoint /system/reboot

Additional context N/A

vaerh commented 2 months ago

Unfortunately what you describe is the task of the provisioner, not the resource. The resource has a clear state that TF is trying to bring the controlled object to, and the reboot process is not a control object, it is an effect on the object.

But, unless something has changed since I was wondering about this, TF does not support custom provisioners. Not all endpoints can be realized in the provider unfortunately.

Schwitzd commented 2 months ago

Ok, that was my assumption too, I think I'm going too far from what I'd like to do 😱

Schwitzd commented 2 months ago

here how I solved.