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

Use resource names instead of hosts for the aliases of dns record types. With spec test file. #100

Merged
merged 1 commit into from Apr 14, 2015

Conversation

ghost
Copy link

@ghost ghost commented Apr 11, 2015

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:

foo     IN A    192.168.100.101
foo     IN A    192.168.100.102

...and...

101    IN PTR    foo.example.com.
102    IN PTR    foo.example.com.

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:

dns::record::a { "foo,101":    # generates alias foo,101,A,example.com
    host => "foo" ,
    zone => "example.com" ,
    data => [ "192.168.100.101" ] ,
    ptr => true
}

dns::record::a { "foo,102":    # generates alias foo,102,A,example.com
    host => "foo" ,
    zone => "example.com" ,
    data => [ "192.168.100.102" ] ,
    ptr => true
}

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.

@ghost ghost changed the title Use aliases instead of hosts in dns record types. With spec test file. Use resource names instead of hosts for the aliases of dns record types. With spec test file. Apr 11, 2015
solarkennedy added a commit that referenced this pull request Apr 14, 2015
…host

Use resource names instead of hosts for the aliases of dns record types.  With spec test file.
@solarkennedy solarkennedy merged commit 968851d into ajjahn:master Apr 14, 2015
@solarkennedy
Copy link
Collaborator

Thanks!

@ghost ghost deleted the allow-multiple-records-with-same-host branch April 14, 2015 18:28
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.

1 participant