How can I start a remote service using Terraform provisioning?

后端 未结 2 1915
醉梦人生
醉梦人生 2021-02-05 15:07

I want my Terraform config to provision a server and start the service at the end by invoking a command and keep running it. I tried using nohup and screen using remote-exec:

2条回答
  •  旧巷少年郎
    2021-02-05 16:00

    Try adding a sleep after your nohup. Worked for me. I suspect backgrounding your last remote-exec lets Terraform get away with shutting down the connection before the child process has a chance to start up, despite the nohup.

    provisioner "remote-exec" {
        inline = [
            "nohup sudo command &",
            "sleep 1"
        ]
    }
    

提交回复
热议问题