diff --git a/manifests/generate.pp b/manifests/generate.pp index f432a78..78f80eb 100644 --- a/manifests/generate.pp +++ b/manifests/generate.pp @@ -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'], + } } } diff --git a/manifests/key.pp b/manifests/key.pp index 726f09e..19a7347 100644 --- a/manifests/key.pp +++ b/manifests/key.pp @@ -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'], + } } - } diff --git a/manifests/mx.pp b/manifests/mx.pp index 69796e3..e25ce0a 100644 --- a/manifests/mx.pp +++ b/manifests/mx.pp @@ -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'], + } } - } diff --git a/manifests/record.pp b/manifests/record.pp index 13fd75b..bc5e5a1 100644 --- a/manifests/record.pp +++ b/manifests/record.pp @@ -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'], + } } } diff --git a/manifests/view.pp b/manifests/view.pp index d614728..11ee7da 100644 --- a/manifests/view.pp +++ b/manifests/view.pp @@ -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'], - } - } diff --git a/manifests/zone.pp b/manifests/zone.pp index 7f356de..05b67de 100644 --- a/manifests/zone.pp +++ b/manifests/zone.pp @@ -80,16 +80,14 @@ 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, @@ -97,7 +95,6 @@ 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'], @@ -140,7 +137,6 @@ } concat::fragment {"00.bind.${name}": - ensure => $ensure, target => $conf_file, order => '01', content => template('bind/zone-header.erb'), diff --git a/spec/defines/bind_generate_spec.rb b/spec/defines/bind_generate_spec.rb index e0c6ebe..b32ee60 100644 --- a/spec/defines/bind_generate_spec.rb +++ b/spec/defines/bind_generate_spec.rb @@ -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" }) } @@ -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" }) } @@ -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" }) } diff --git a/spec/defines/bind_zone_spec.rb b/spec/defines/bind_zone_spec.rb index 87f1f25..3f0248e 100644 --- a/spec/defines/bind_zone_spec.rb +++ b/spec/defines/bind_zone_spec.rb @@ -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" }) } @@ -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" }) } @@ -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" }) } @@ -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" }) }