Skip to content
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

Update docs with example of using IPs from resource #1

Open
ababra opened this issue May 13, 2017 · 1 comment
Open

Update docs with example of using IPs from resource #1

ababra opened this issue May 13, 2017 · 1 comment

Comments

@ababra
Copy link

ababra commented May 13, 2017

UPDATE: just realized that your README does not mention the post on your website; can it be updated to link to the original post?

The example is currently hardcoded with a string of fake IPs. Could a real-world example also be provided, i.e. using data from an actual resource (DigitalOcean/AWS, etc.)?

I have been trying to modify the outputs.tf file as follows, however it only outputs the first generated IP from the resource:

data "template_file" "ansible_hosts" {
  template = "${file("ansible_hosts.tpl")}"
  vars {
    # This works for first IP
    do_hosts = "Instances: ${element(digitalocean_droplet.host.*.ipv4_address, count.index)}"
  }
}

output "ansible_hosts" {
  value = "${data.template_file.ansible_hosts.rendered}"
}

For reference, here is my resource:

# Create DigitalOcean nodes
resource "digitalocean_droplet" "host" {
  count = "${var.do_count}"
  image  = "${var.do_image}"
  name   = "host-${format("%02d", count.index+1)}"
  region = "${var.do_region}"
  size   = "${var.do_size}"
  ssh_keys = ["${digitalocean_ssh_key.ssh-key.id}"]
}
@seanorama
Copy link

^ Same request as above for an example of how to get the IP from each created hosts rather than the static list example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants