-
Notifications
You must be signed in to change notification settings - Fork 9.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Splats expanding improperly in provisioner #427
Comments
Notes: For this to work, we might actually have to split the graph into separate nodes for provisioners and resources, because the provisioners have to gate on all the resources being partially created. |
@mitchellh fwiw I think there's a lot of value in separating the resource creation and provisioning steps. I have thoughts and notes that I'm going to try to write up in a separate issue at some point. |
@knuckolls I agree, there is just some complication since we don't persist connection info and some other state. I'm not against it, just making notes of how we'd have to do it. |
It would be nice to have a readable state file for the provisioners as well. |
@pushingice The state file is readable now! As of 0.3.0 it is human-readable JSON (non-compacted). |
@mitchellh I don't think it is readable when the provisioner is kicked off though. I wrote a dynamic inventory script for ansible that reads the state file. I put this in my provisioner: provisioner "local-exec" { My python script dies when it tries to read from terraform.tfstate. |
@pushingice The state is updated only after Terraform is run. This I believe is working as expected (and not part of this issue). |
This is fixed by #1016 |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
I'm trying to run a provisioner script against each instance in a count block. I would like to be able to send the list of all the DNS names in the block to each instance. It looks like what is happening is that instead of expanding the splat fully for every iteration (e.g. producing the list [0, 1]), it accumulates the list as it goes (e.g. [0], [0,1]). Sample config:
resource "aws_instance" "zookeeper" {
ami = "${var.amis}"
instance_type = "m3.large"
key_name = "daalt-experimental"
subnet_id = "subnet-ef5def86"
security_groups = ["${aws_security_group.dev-zookeeper.id}"]
availability_zone = "us-west-2b"
count = 2
tags {
Name = "daalt-zookeeper-dev-${count.index}"
}
provisioner "local-exec" {
command = "echo ${join(",",aws_instance.zookeeper.*.private_dns)} "
}
}
Here's the output:
aws_instance.zookeeper.0: Provisioning with 'local-exec'...
aws_instance.zookeeper.0 (local-exec): Executing: /bin/sh -c "echo ip-10-252-3-52.us-west-2.compute.internal "
aws_instance.zookeeper.0 (local-exec): ip-10-252-3-52.us-west-2.compute.internal
aws_instance.zookeeper.0: Creation complete
aws_instance.zookeeper.1: Provisioning with 'local-exec'...
aws_instance.zookeeper.1 (local-exec): Executing: /bin/sh -c "echo ip-10-252-3-52.us-west-2.compute.internal,ip-10-252-3-154.us-west-2.compute.internal "
aws_instance.zookeeper.1 (local-exec): ip-10-252-3-52.us-west-2.compute.internal,ip-10-252-3-154.us-west-2.compute.internal
aws_instance.zookeeper.1: Creation complete
The text was updated successfully, but these errors were encountered: