Skip to content

Allow Setting for Host DNS Entries#382

Merged
MalloZup merged 1 commit intodmacvicar:masterfrom
eparis:crawford-host-dns
Sep 6, 2018
Merged

Allow Setting for Host DNS Entries#382
MalloZup merged 1 commit intodmacvicar:masterfrom
eparis:crawford-host-dns

Conversation

@eparis
Copy link
Copy Markdown
Contributor

@eparis eparis commented Aug 28, 2018

This will allow one to set host based DNS entries. So I can say
host=host1, ip=1.1.1.1
host=host1, ip=1.1.1.2
host=host2, ip=1.1.1.1
And It would work the way you expect...

@eparis
Copy link
Copy Markdown
Contributor Author

eparis commented Aug 28, 2018

this also includes the DNS rework from #376

// ...
// }
//
func datasourceLibvirtNetworkDNSHostTemplate() *schema.Resource {
Copy link
Copy Markdown
Collaborator

@MalloZup MalloZup Aug 29, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eparis eparis force-pushed the crawford-host-dns branch 10 times, most recently from 9a05cd6 to 652f585 Compare September 4, 2018 12:22
@eparis
Copy link
Copy Markdown
Contributor Author

eparis commented Sep 4, 2018

@MalloZup hopefully I learned enough from #376 that this review is easier.

@eparis
Copy link
Copy Markdown
Contributor Author

eparis commented Sep 5, 2018

rebased. thank you!

@eparis eparis force-pushed the crawford-host-dns branch 2 times, most recently from 27c5549 to 0bafd91 Compare September 5, 2018 13:26
The DNS hosts feature allows DNS records to be created that point to a
given IP address. This is useful for aliasing as well as setting up
round-robin DNS (by creating multiple hosts that point to the same IP
address).

This creates a new datasource called libvirt_network_dns_hosts_template,
which can be used to populate the dns_host attribute in libvirt_network
resources. The use of a datasource is required in order to dynamically
generate dns_host entries (since 'count' is the only looping construct
in Terraform and 'count' is limited to datasources and resources). The
list of hostnames has also been replaced by a single hostname with the
option of declaring multiple dns_host blocks with the same IP address.

I originally tried to externally generate a variable that would host the
list of maps needed for the dns_host attribute, but Terraform explicitly
disallows lists of maps greater than length one. Instead, I decided to
follow the pattern established by template_file and create a resource
that can be rendered.

The hostnames attribute had to be replaced with hostname because the
underlying schema for the 'rendered' attribute is a TypeMap. In
Terraform, this is not a generic map, but is instead limited to
map[string]string. To accommodate this, multiple dns_host blocks can be
defined with the same IP address, one for each hostname.
@MalloZup
Copy link
Copy Markdown
Collaborator

MalloZup commented Sep 5, 2018

@eparis i will review it more in deep tomorrow with a fresh mind. sofar looks nice to me but i want to try it out with time. thank you for your patience 👍

@eparis
Copy link
Copy Markdown
Contributor Author

eparis commented Sep 5, 2018

@MalloZup Patience? You've been one of the most responsive and helpful maintainers I've ever dealt with! Thank you for helping me get it right.

Copy link
Copy Markdown
Collaborator

@MalloZup MalloZup left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thx looks good ! 🎉

@MalloZup
Copy link
Copy Markdown
Collaborator

MalloZup commented Sep 6, 2018

merging. thx @eparis for the contribution! i hope it will be helpful for your projects and c u next contrib 👍 😄

@MalloZup MalloZup merged commit a8e8a87 into dmacvicar:master Sep 6, 2018
@eparis
Copy link
Copy Markdown
Contributor Author

eparis commented Sep 6, 2018

Thank you both, this was great!

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

Successfully merging this pull request may close these issues.

4 participants