Skip to content

Commit

Permalink
fix ensure for concat 2.x
Browse files Browse the repository at this point in the history
  • Loading branch information
saimonn committed Nov 24, 2016
1 parent 292425d commit 0ea7c8b
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 57 deletions.
11 changes: 6 additions & 5 deletions manifests/generate.pp
Expand Up @@ -93,10 +93,11 @@
validate_string($record_class)
validate_string($ttl)

::concat::fragment {"${name}.generate":
ensure => $ensure,
target => "${bind::params::pri_directory}/${zone}.conf",
content => template('bind/generate.erb'),
notify => Service['bind9'],
if $ensure == 'present' {
::concat::fragment {"${name}.generate":
target => "${bind::params::pri_directory}/${zone}.conf",
content => template('bind/generate.erb'),
notify => Service['bind9'],
}
}
}
14 changes: 7 additions & 7 deletions manifests/key.pp
Expand Up @@ -35,12 +35,12 @@
content => template("${module_name}/dnskey.conf.erb"),
}

concat::fragment {"dnskey.${name}":
ensure => $ensure,
target => "${bind::params::config_base_dir}/${bind::params::named_local_name}",
content => "include \"${bind::params::keys_directory}/${name}.conf\";\n",
notify => Exec['reload bind9'],
require => Package['bind9'],
if $ensure == 'present' {
concat::fragment {"dnskey.${name}":
target => "${bind::params::config_base_dir}/${bind::params::named_local_name}",
content => "include \"${bind::params::keys_directory}/${name}.conf\";\n",
notify => Exec['reload bind9'],
require => Package['bind9'],
}
}

}
13 changes: 7 additions & 6 deletions manifests/mx.pp
Expand Up @@ -32,12 +32,13 @@
default => $owner
}

concat::fragment {"bind.${name}":
ensure => $ensure,
target => "${bind::params::pri_directory}/${zone}.conf",
content => template('bind/mx-record.erb'),
notify => Service['bind9'],
if $ensure == 'present' {
concat::fragment {"bind.${name}":
ensure => $ensure,
target => "${bind::params::pri_directory}/${zone}.conf",
content => template('bind/mx-record.erb'),
notify => Service['bind9'],
}
}

}

14 changes: 8 additions & 6 deletions manifests/record.pp
Expand Up @@ -57,12 +57,14 @@
$record_content = template('bind/default-record.erb')
}

concat::fragment {"${zone}.${record_type}.${name}":
ensure => $ensure,
target => "${bind::params::pri_directory}/${zone}.conf",
content => $record_content,
order => '10',
notify => Service['bind9'],
if $ensure == 'present' {
concat::fragment {"${zone}.${record_type}.${name}":
ensure => $ensure,
target => "${bind::params::pri_directory}/${zone}.conf",
content => $record_content,
order => '10',
notify => Service['bind9'],
}
}

}
30 changes: 14 additions & 16 deletions manifests/view.pp
Expand Up @@ -24,21 +24,19 @@
owner => 'root',
}

concat {"${bind::params::views_directory}/${_name}.zones":
ensure => $ensure,
force => true,
group => 'root',
mode => '0644',
owner => 'root',
if $ensure == 'present' {
concat {"${bind::params::views_directory}/${_name}.zones":
force => true,
group => 'root',
mode => '0644',
owner => 'root',
}
concat::fragment {"named.local.view.${_name}":
target => "${bind::params::config_base_dir}/${bind::params::named_local_name}",
content => "include \"${bind::params::views_directory}/${_name}.view\";\n",
order => $order,
notify => Exec['reload bind9'],
require => Class['bind::install'],
}
}

concat::fragment {"named.local.view.${_name}":
ensure => $ensure,
target => "${bind::params::config_base_dir}/${bind::params::named_local_name}",
content => "include \"${bind::params::views_directory}/${_name}.view\";\n",
order => $order,
notify => Exec['reload bind9'],
require => Class['bind::install'],
}

}
16 changes: 6 additions & 10 deletions manifests/zone.pp
Expand Up @@ -80,24 +80,21 @@
fail "Zone '${name}': transfer_source can be set only for slave zones!"
}

concat::fragment {"${_view}.zone.${name}":
ensure => $ensure,
target => "${bind::params::views_directory}/${_view}.zones",
content => "include \"${bind::params::zones_directory}/${name}.conf\";\n",
notify => Exec['reload bind9'],
require => Package['bind9'],
}

case $ensure {
'present': {
concat::fragment {"${_view}.zone.${name}":
target => "${bind::params::views_directory}/${_view}.zones",
content => "include \"${bind::params::zones_directory}/${name}.conf\";\n",
notify => Exec['reload bind9'],
require => Package['bind9'],
}
concat {"${bind::params::zones_directory}/${name}.conf":
owner => root,
group => root,
mode => '0644',
notify => Exec['reload bind9'],
}
concat::fragment {"bind.zones.${name}":
ensure => $ensure,
target => "${bind::params::zones_directory}/${name}.conf",
notify => Exec['reload bind9'],
require => Package['bind9'],
Expand Down Expand Up @@ -140,7 +137,6 @@
}

concat::fragment {"00.bind.${name}":
ensure => $ensure,
target => $conf_file,
order => '01',
content => template('bind/zone-header.erb'),
Expand Down
3 changes: 0 additions & 3 deletions spec/defines/bind_generate_spec.rb
Expand Up @@ -228,7 +228,6 @@
:rhs => '10.10.0.$',
} }
it { should contain_concat__fragment('a-record.generate').with({
:ensure => 'present',
:target => "#{confdir}/pri/test.tld.conf",
:content => "\$GENERATE 2-100 dhcp-\$ A 10.10.0.\$ ; a-record\n"
}) }
Expand All @@ -244,7 +243,6 @@
:rhs => '10.10.0.$',
} }
it { should contain_concat__fragment('a-record.generate').with({
:ensure => 'present',
:target => "#{confdir}/pri/test.tld.conf",
:content => "\$GENERATE 2-100 dhcp-\$ CNAME 10.10.0.\$ ; a-record\n"
}) }
Expand All @@ -260,7 +258,6 @@
:rhs => 'dhcp-$.test.tld.',
} }
it { should contain_concat__fragment('ptr-record.generate').with({
:ensure => 'present',
:target => "#{confdir}/pri/0.10.10.IN-ADDR.ARPA.conf",
:content => "$GENERATE 2-100 $.0.10.10.IN-ADDR.ARPA. PTR dhcp-$.test.tld. ; ptr-record\n"
}) }
Expand Down
4 changes: 0 additions & 4 deletions spec/defines/bind_zone_spec.rb
Expand Up @@ -175,7 +175,6 @@
:mode => '0644'
}) }
it { should contain_concat__fragment('bind.zones.domain.tld').with({
:ensure => 'present',
:target => "#{confdir}/zones/domain.tld.conf",
:content => "# File managed by puppet\nzone domain.tld IN {\n type slave;\n masters { 1.2.3.4; };\n allow-query { any; };\n transfer-source 2.3.4.5;\n forwarders { };\n};\n"
}) }
Expand All @@ -193,7 +192,6 @@
:mode => '0644'
}) }
it { should contain_concat__fragment('bind.zones.domain.tld').with({
:ensure => 'present',
:target => "#{confdir}/zones/domain.tld.conf",
:content => "# File managed by puppet\nzone domain.tld IN {\n type forward;\n forwarders { 1.2.3.4; };\n};\n"
}) }
Expand All @@ -215,7 +213,6 @@
:mode => '0644'
}) }
it { should contain_concat__fragment('bind.zones.domain.tld').with({
:ensure => 'present',
:target => "#{confdir}/zones/domain.tld.conf",
:content => "# File managed by puppet\nzone \"domain.tld\" IN {\n type master;\n file \"#{confdir}/pri/domain.tld.conf\";\n allow-transfer { none; };\n allow-query { any; };\n notify yes;\n also-notify { 1.1.1.1; 2.2.2.2; };\n forwarders { };\n};\n"
}) }
Expand All @@ -225,7 +222,6 @@
:mode => '0664'
}) }
it { should contain_concat__fragment('00.bind.domain.tld').with({
:ensure => 'present',
:target => "#{confdir}/pri/domain.tld.conf",
:content => "; File managed by puppet\n$TTL 60\n@ IN SOA ns.tld. admin@example.com. (\n 123456 ; serial\n 3h ; refresh\n 1h ; retry\n 1w; expiracy\n 60 ) ; TTL\n IN NS ns.tld.\n IN NS ns2.tld.\n"
}) }
Expand Down

0 comments on commit 0ea7c8b

Please sign in to comment.