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

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

我正在尝试 运行 在我使用 Terraform 提供的 DigitalOcean Droplet 上执行一些内联​​远程执行命令。

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

第一个命令 returns “root” 正确,但之后我得到:

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

有什么建议吗?我是 Terraform 的新手,可能错过了文档中的一些基本知识。

您应该在该服务器上禁用 SELinux:

sudo setenforce 0

对我来说,只有当我在安装 snap 本身后立即尝试安装 snap 应用程序时才会出现错误。在 运行 之后,“snap install”下面的命令工作正常。

sudo snap wait system seed.loaded