terraform remote-exec provisioner hangs and fails running a simple command!

1,169 views
Skip to first unread message

Richard Mauri

unread,
Nov 21, 2015, 12:21:04 AM11/21/15
to Terraform
I have a terraform file provisioner that creates an ec2 atomic resource and then uploads a file to my atomic instance OK
I have a remote-exec provisioner to do a simple cat append command ; It is very slow (5 mins or so) and ultimately fails

partial terraform apply transcript

aws_instance.atomic-server: Provisioning with 'file'...

aws_instance.atomic-server: Provisioning with 'file'...

aws_instance.atomic-server: Provisioning with 'remote-exec'...

aws_instance.atomic-server (remote-exec): Connecting to remote host via SSH...

aws_instance.atomic-server (remote-exec):   Host: 52.33.230.184

aws_instance.atomic-server (remote-exec):   User: fedora

aws_instance.atomic-server (remote-exec):   Password: false

aws_instance.atomic-server (remote-exec):   Private key: true

aws_instance.atomic-server (remote-exec):   SSH Agent: false

aws_instance.atomic-server (remote-exec): Connected!


slow here.....then...


Error applying plan:


1 error(s) occurred:


* Failed to upload script: Error reading script: EOF


Terraform does not automatically rollback in the face of errors.

Instead, your Terraform state file has been partially updated with

any resources that successfully completed. Please address the error

above and apply again to incrementally change your infrastructure.


Below is a prtial snippet of my .tf file


provider "aws" {

    access_key = "${var.access_key}"

    secret_key = "${var.secret_key}"

    region = "${var.region}"

}


resource "aws_instance" "atomic-server" {

    ami = "${lookup(var.ami, concat(var.region, "-", var.platform))}"

    instance_type = "${var.instance_type}"

    key_name = "${var.aws_key_name}"

    count = "${var.servers}"

    security_groups = ["wideopen"]

#    security_groups = ["${aws_security_group.atomic.name}"]


    connection {

        user = "${lookup(var.user, var.platform)}"

        key_file = "${var.key_path}"

    }


    tags {

        Name = "${var.tagName}-${count.index}"

    }


    provisioner "file" {

        source = "fedora_bashrc"

        destination  = "/home/fedora/fedora_bashrc"

    }

    provisioner "file" {

        source = "nomad"

        destination  = "/home/fedora/nomad"

    }

    provisioner "remote-exec" {

        inline = [

            "cat /home/fedora/fedora_bashrc >> /home/fedora/.bashrc",

#            "chmod a+x /home/fedora/nomad",

#            "sudo chmod a+w /tmp",

#            "sudo groupadd docker",

#            "sudo gpasswd -a fedora docker",

#            "sudo service docker restart",

        ]

    }

}


I tried with and without the trailing ","in the remote-exec inline command

Richard Mauri

unread,
Nov 21, 2015, 12:21:54 AM11/21/15
to Terraform
Forgot to add this is on Terraform v0.6.6

Paul Hinze

unread,
Dec 3, 2015, 7:37:45 PM12/3/15
to terrafo...@googlegroups.com
Hi Richard,

Sorry for the trouble here! Can you file this as a GitHub Issue and we'll get it looked at?

Thanks,

Paul

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/hashicorp/terraform/issues
IRC: #terraform-tool on Freenode
---
You received this message because you are subscribed to the Google Groups "Terraform" group.
To unsubscribe from this group and stop receiving emails from it, send an email to terraform-too...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/terraform-tool/a37e1a9d-d321-4477-9cef-c0eae7de2f69%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages