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

Syntax error when using strings #10

Merged
merged 3 commits into from
Dec 1, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Modulefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name 'ajjahn-puppet_dns'
version '0.1.3'
version '0.1.4'
summary "Module for provisioning DNS (bind9)"
description "Module for provisioning DNS (bind9)"
author 'Adam Jahn'
Expand Down
13 changes: 9 additions & 4 deletions manifests/record/a.pp
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
define dns::record::a ($zone, $data, $ttl = '', $ptr = false) {
define dns::record::a (
$zone,
$data,
$ttl = '',
$ptr = false,
$host = $name ) {

$alias = "${name},A,${zone}"
$alias = "${host},A,${zone}"

dns::record { $alias:
zone => $zone,
host => $name,
host => $host,
ttl => $ttl,
data => $data
}
Expand All @@ -16,7 +21,7 @@

dns::record::ptr { $octet:
zone => $reverse_zone,
data => "${name}.${zone}"
data => "${host}.${zone}"
}
}
}
10 changes: 7 additions & 3 deletions manifests/record/aaaa.pp
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
define dns::record::aaaa ($zone, $data, $ttl = '') {
define dns::record::aaaa (
$zone,
$data,
$ttl = '',
$host = $name ) {

$alias = "${name},AAAA,${zone}"
$alias = "${host},AAAA,${zone}"

dns::record { $alias:
zone => $zone,
host => $name,
host => $host,
ttl => $ttl,
record => 'AAAA',
data => $data
Expand Down
18 changes: 14 additions & 4 deletions manifests/record/cname.pp
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
define dns::record::cname ($zone, $data, $ttl = '') {
define dns::record::cname (
$zone,
$data,
$ttl = '',
$host = $name) {

$alias = "${name},CNAME,${zone}"
$alias = "${host},CNAME,${zone}"

$qualified_data = $data ? {
'@' => $data,
/\.$/ => $data,
default => "${data}."
}

dns::record { $alias:
zone => $zone,
host => $name,
host => $host,
ttl => $ttl,
record => 'CNAME',
data => "${data}."
data => $qualified_data
}
}
11 changes: 8 additions & 3 deletions manifests/record/mx.pp
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
define dns::record::mx ($zone, $data, $ttl = '', $preference = '0') {
define dns::record::mx (
$zone,
$data,
$ttl = '',
$preference = '0',
$host = $name ) {

$alias = "${name},MX,${zone}"
$alias = "${host},MX,${zone}"

dns::record { $alias:
zone => $zone,
host => $name,
host => $host,
ttl => $ttl,
record => 'MX',
preference => $preference,
Expand Down
10 changes: 7 additions & 3 deletions manifests/record/ptr.pp
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
define dns::record::ptr ($zone, $data, $ttl = '') {
define dns::record::ptr (
$zone,
$data,
$ttl = '',
$host = $name ) {

$alias = "${name},PTR,${zone}"
$alias = "${host},PTR,${zone}"

dns::record { $alias:
zone => $zone,
host => $name,
host => $host,
ttl => $ttl,
record => 'PTR',
data => "${data}."
Expand Down
10 changes: 7 additions & 3 deletions manifests/record/txt.pp
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
define dns::record::txt ($zone, $data, $ttl = '') {
define dns::record::txt (
$zone,
$data,
$ttl = '',
$host = $name) {

$alias = "${name},TXT,${zone}"
$alias = "${host},TXT,${zone}"

dns::record { $alias:
zone => $zone,
host => $name,
host => $host,
ttl => $ttl,
record => 'TXT',
data => $data
Expand Down
10 changes: 7 additions & 3 deletions templates/zone_record.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<% delimiter = %w[TXT SPF].include?(record.upcase) ? '"' : '' -%>
<% data.each do |data_item| -%>
<%
delimiter = %w[TXT SPF].include?(record.upcase) ? '"' : ''
data_a = data.is_a?(String) ? data.lines.to_a : data

data_a.each do |data_item|
-%>
<%= host unless record.upcase == 'MX' %> <%= ttl %> <%= dns_class %> <%= record.upcase %><%= record.upcase == 'MX' ? " #{preference}" : '' %> <%= delimiter %><%= data_item %><%= delimiter %>
<% end -%>
<% end -%>