2

Is there a way to delay module resource creation with the Terraform Vsphere provider. I want to introduce a 10mn delay due to infrastructure impediments between each VM instance creation. Each one is created by a module occurrence.

At the moment, Terraform is doing its best to deploy at maximum speed!

I tried depends_on with module: no way.

Versions used:

vsphere 6.0
terraform 0.11.3
provider.vsphere v 1.3.2
Rekovni
  • 6,319
  • 3
  • 39
  • 62
MahediS
  • 21
  • 1
  • 3

2 Answers2

4

You could use a provisioner within the instance and have some kind of sleep command there, before the next VM instance is created.

resource "vsphere_virtual_machine" "vpshere_build_machine" {
  provisioner "local-exec" {
      command = "ping 127.0.0.1 -n 10 > nul" #or sleep 10
  }
Rekovni
  • 6,319
  • 3
  • 39
  • 62
  • 1
    Thanks for your reply. I found another solution bu terraform cli option with terraform -parallelism=1 apply and with TF_CLI_ARGS env variable. It s not 10mn delay but provisionning of instance respect the duration. Regards – MahediS Feb 27 '18 at 18:08
0

In my case I could solve it by doing this trick:

"sleep [s] && command"

For example:

provisioner "local-exec" {
    command = "sleep 30 && ansible-playbook -i ..."
  }
Kaguei Nakueka
  • 993
  • 2
  • 13
  • 34