'Terraform remote-exec: "error: too early for operation, device not yet seeded or device model not acknowledged"

I'm trying to run some inline remote-exec commands on a DigitalOcean droplet I provision with Terraform.

  provisioner "remote-exec" {
    inline=[
      "whoami",
      "sudo snap install microk8s --classic --channel=1.18/stable"
    ]
  }

The first command returns "root" correctly but after that I get:

digitalocean_droplet.example (remote-exec): Connecting to remote host via SSH...
digitalocean_droplet.example (remote-exec):   Host: 111.11.11.111
digitalocean_droplet.example (remote-exec):   User: root
digitalocean_droplet.example (remote-exec):   Password: false
digitalocean_droplet.example (remote-exec):   Private key: true
digitalocean_droplet.example (remote-exec):   Certificate: false
digitalocean_droplet.example (remote-exec):   SSH Agent: true
digitalocean_droplet.example (remote-exec):   Checking Host Key: false
digitalocean_droplet.example (remote-exec): Connected!
digitalocean_droplet.example: Still creating... [40s elapsed]
digitalocean_droplet.example (remote-exec): root
digitalocean_droplet.example (remote-exec): error: too early for operation, device not yet seeded or device model not acknowledged

Any advice? I'm new to Terraform, maybe missed something fundamental in docs.



Solution 1:[1]

For me, the error only occurs when I try to install a snap application immediately after installing the snap itself. After running the command below the "snap install" worked fine.

sudo snap wait system seed.loaded

Solution 2:[2]

you should disable SELinux on that server:

sudo setenforce 0

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 U53r
Solution 2 Dharman