Brandon Wilson
Brandon Wilson

Reputation: 4590

Terraform mkdir no such file or directory

Learning Terraform and running into a weird issue when trying to create a directory. When this resource is executed it returns:

Error running command 'mkdir /home/user-a/docker': no such file or directory.

This command works locally on the target just fine. This is building a directory to put docker data.

resource "null_resource" "dockerarm1"{
    connection {
        type     = "ssh"
        user     = "user-a"
        password = "sojfadsfsdfsa"
        host     = "dockerarm1.local"
      }
      provisioner "local-exec" {
        command = "mkdir /home/user-a/docker"
    }
}

Upvotes: 0

Views: 1940

Answers (1)

Marcin
Marcin

Reputation: 238189

Based on the comments.

local-exec executes on a local machine. To run your commands on a remote host (Ubuntu) you need to use remote-exec:

The remote-exec provisioner invokes a script on a remote resource after it is created.

Upvotes: 1

Related Questions