Allow Setting for Host DNS Entries#382
Conversation
|
this also includes the DNS rework from #376 |
13bfccc to
f109aa0
Compare
libvirt/resource_libvirt_network.go
Outdated
| // ... | ||
| // } | ||
| // | ||
| func datasourceLibvirtNetworkDNSHostTemplate() *schema.Resource { |
There was a problem hiding this comment.
i am thinking that if we introduce a datasource resource, would make sense to me to create a new file
as example:
data_source_libvirt_network_dns..
https://github.com/terraform-providers/terraform-provider-aws/blob/master/aws/data_source_aws_acmpca_certificate_authority_test.go
9a05cd6 to
652f585
Compare
652f585 to
3c0a809
Compare
|
rebased. thank you! |
27c5549 to
0bafd91
Compare
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.
0bafd91 to
a4d0ba6
Compare
|
@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 👍 |
|
@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. |
|
merging. thx @eparis for the contribution! i hope it will be helpful for your projects and c u next contrib 👍 😄 |
|
Thank you both, this was great! |
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...