vultr / terraform-provider-vultr-community

Terraform Vultr provider
Mozilla Public License 2.0
50 stars 7 forks source link

[BUG] - File provisioner doesn't copy my file #88

Closed yeongjukang closed 5 years ago

yeongjukang commented 5 years ago

Describe the bug I think file provisioner is not working correctly. When I was on #87 , my file didn't appear on my remote host.

To Reproduce

# please apply this file to test
# common.sh originally was filled with kubectl, kubeadm and kubelet install commands.
# I failed again with common.sh replaced with echo '123'.
provider "vultr" {}
data "vultr_os" "coreos" {
  filter {
    name   = "family"
    values = ["coreos"]
  }
}
data "vultr_plan" "plan_1c2g" {
  filter {
    name   = "VPSPLANID"
    values = ["202"]
  }
}

data "vultr_plan" "plan_2c4g" {
  filter {
    name   = "VPSPLANID"
    values = ["203"]
  }
}

data "vultr_region" "tokyo" {
  filter {
    name   = "name"
    values = ["Tokyo"]
  }
}

resource "vultr_server" "master_standalone" {
    plan_id = "${data.vultr_plan.plan_2c4g.id}"
    region_id = "${data.vultr_region.tokyo.id}"
    os_id = "${data.vultr_os.coreos.id}"
    hostname = "master-01"
    provisioner "file" {
    source      = "common.sh"
    destination = "/tmp/common.sh"
  }
  provisioner "remote-exec" {
    inline = [
      "chmod +x /tmp/common.sh"
    ]
  }
}

Expected behavior

  1. timeout from client side
  2. no such file '/tmp/common.sh'

Screenshots If applicable, add screenshots to help explain your problem. image

Desktop (please complete the following information where applicable:

Additional context

Add any other context about the problem here.

yeongjukang commented 5 years ago

additional screenshot from coreos server image

ddymko commented 5 years ago

Hey @979156

Thanks for creating the bug & enhancement. I'll take a look into this and see what the issue might be

ddymko commented 5 years ago

@979156 The error you are getting with your provisioner upload is because you did not supply SSH credentials. This is why you are getting the ssh: unable to authenticate... error.

https://www.terraform.io/docs/provisioners/connection.html

You will need to setup your provisioner block with a connection node like this:

provisioner "file" {
    source      = "common.sh"
    destination = "/tmp/common.sh"

      connection {
        type     = "ssh"
        host     = "${vultr_server.master_standalone.main_ip}"
        user     = "root"
        password = "${vultr_server.master_standalone.default_password}"

   }
  }

The output should then be similar to this

vultr_server.master_standalone: Creating...
vultr_server.master_standalone: Still creating... [10s elapsed]
vultr_server.master_standalone: Still creating... [20s elapsed]
vultr_server.master_standalone: Still creating... [30s elapsed]
vultr_server.master_standalone: Still creating... [40s elapsed]
vultr_server.master_standalone: Still creating... [50s elapsed]
vultr_server.master_standalone: Still creating... [1m0s elapsed]
vultr_server.master_standalone: Still creating... [1m10s elapsed]
vultr_server.master_standalone: Provisioning with 'file'...
vultr_server.master_standalone: Creation complete after 1m16s [id=27167644]
yeongjukang commented 5 years ago

@ddymko thanks for reply!