Use resource names instead of hosts for the aliases of dns record types. With spec test file. #100
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I noticed that the current resource definitions in the
dns::record::
* classes all base their resource names on the zonefile host entry. This means that you cannot create multiple entries of the same type for the same name.Admittedly,most of the entries allow for an array for the data parameter, but there's one case where this doesn't work: automatic ptr entry creation.
Suppose I want to create these DNS zones fragments:
...and...
Under the current code, I would not be able to use the automatic PTR record generation for this, because I would have to use a two-item array for the data of the A record, but the automatic PTR generation only looks at the first IP address.
This PR changes the alias definitions for the record type to use
${name}
instead of${host}
. This would allow me to give the two A records different names but use the same host entry in both, and I would get my automatic PTR generation:This also allows, in general, for the (to me) more obvious style of having two resource definitions if I want to create two records of the same name, whether it's for A records, NS records, TXT records, etc.
MX records already allow this, but I made the change to them also to be consistent. The only record type I did not change was the SRV record type, since I don't understand the semantics of the SRV records.
I also created a spec file to test all the record types that use the new alias construction, to ensure they create the proper fragment name and proper record entry both when using the alias for the host and when specifying a different host, and I adjusted the
dns__record__mx_spec.rb
tests to match the new expected fragment names.