Unverified Commit 25e0fc42 authored by Nathan Ward's avatar Nathan Ward Committed by GitHub
Browse files

Merge pull request #164 from SearchLightNZ/fix_concat_newlines

Use ensure_newline for concats fragments
parents 7338d283 86ad33ff
...@@ -32,7 +32,7 @@ define freeradius::dictionary ( ...@@ -32,7 +32,7 @@ define freeradius::dictionary (
if ($ensure == 'present') { if ($ensure == 'present') {
concat::fragment { "dictionary.${name}": concat::fragment { "dictionary.${name}":
target => "${fr_basepath}/dictionary", target => "${fr_basepath}/dictionary",
content => "\$INCLUDE ${fr_basepath}/dictionary.d/dictionary.${name}\n", content => "\$INCLUDE ${fr_basepath}/dictionary.d/dictionary.${name}",
order => $order, order => $order,
require => File["${fr_basepath}/dictionary.d/dictionary.${name}"], require => File["${fr_basepath}/dictionary.d/dictionary.${name}"],
} }
......
...@@ -147,11 +147,12 @@ class freeradius ( ...@@ -147,11 +147,12 @@ class freeradius (
# Set up concat policy file, as there is only one global policy # Set up concat policy file, as there is only one global policy
# We also add standard header and footer # We also add standard header and footer
concat { "${freeradius::fr_basepath}/policy.conf": concat { "${freeradius::fr_basepath}/policy.conf":
owner => 'root', owner => 'root',
group => $freeradius::fr_group, group => $freeradius::fr_group,
mode => '0640', mode => '0640',
require => [Package[$freeradius::fr_package], Group[$freeradius::fr_group]], ensure_newline => true,
notify => Service[$freeradius::fr_service], require => [Package[$freeradius::fr_package], Group[$freeradius::fr_group]],
notify => Service[$freeradius::fr_service],
} }
concat::fragment { 'policy_header': concat::fragment { 'policy_header':
target => "${freeradius::fr_basepath}/policy.conf", target => "${freeradius::fr_basepath}/policy.conf",
...@@ -166,11 +167,12 @@ class freeradius ( ...@@ -166,11 +167,12 @@ class freeradius (
# Set up concat template file # Set up concat template file
concat { "${freeradius::fr_basepath}/templates.conf": concat { "${freeradius::fr_basepath}/templates.conf":
owner => 'root', owner => 'root',
group => $freeradius::fr_group, group => $freeradius::fr_group,
mode => '0640', mode => '0640',
require => [Package[$freeradius::fr_package], Group[$freeradius::fr_group]], ensure_newline => true,
notify => Service[$freeradius::fr_service], require => [Package[$freeradius::fr_package], Group[$freeradius::fr_group]],
notify => Service[$freeradius::fr_service],
} }
concat::fragment { 'template_header': concat::fragment { 'template_header':
target => "${freeradius::fr_basepath}/templates.conf", target => "${freeradius::fr_basepath}/templates.conf",
...@@ -186,25 +188,27 @@ class freeradius ( ...@@ -186,25 +188,27 @@ class freeradius (
# Set up concat proxy file # Set up concat proxy file
concat { "${freeradius::fr_basepath}/proxy.conf": concat { "${freeradius::fr_basepath}/proxy.conf":
owner => 'root', owner => 'root',
group => $freeradius::fr_group, group => $freeradius::fr_group,
mode => '0640', mode => '0640',
require => [Package[$freeradius::fr_package], Group[$freeradius::fr_group]], ensure_newline => true,
notify => Service[$freeradius::fr_service], require => [Package[$freeradius::fr_package], Group[$freeradius::fr_group]],
notify => Service[$freeradius::fr_service],
} }
concat::fragment { 'proxy_header': concat::fragment { 'proxy_header':
target => "${freeradius::fr_basepath}/proxy.conf", target => "${freeradius::fr_basepath}/proxy.conf",
content => "# Proxy config\n", content => '# Proxy config',
order => '05', order => '05',
} }
# Set up attribute filter file # Set up attribute filter file
concat { "${freeradius::fr_basepath}/mods-available/attr_filter": concat { "${freeradius::fr_basepath}/mods-available/attr_filter":
owner => 'root', owner => 'root',
group => $freeradius::fr_group, group => $freeradius::fr_group,
mode => '0640', mode => '0640',
require => [Package[$freeradius::fr_package], Group[$freeradius::fr_group]], ensure_newline => true,
notify => Service[$freeradius::fr_service], require => [Package[$freeradius::fr_package], Group[$freeradius::fr_group]],
notify => Service[$freeradius::fr_service],
} }
file { "${freeradius::fr_modulepath}/attr_filter": file { "${freeradius::fr_modulepath}/attr_filter":
ensure => link, ensure => link,
...@@ -238,10 +242,11 @@ class freeradius ( ...@@ -238,10 +242,11 @@ class freeradius (
# Install a slightly tweaked stock dictionary that includes # Install a slightly tweaked stock dictionary that includes
# our custom dictionaries # our custom dictionaries
concat { "${freeradius::fr_basepath}/dictionary": concat { "${freeradius::fr_basepath}/dictionary":
owner => 'root', owner => 'root',
group => $freeradius::fr_group, group => $freeradius::fr_group,
mode => '0644', mode => '0644',
require => [Package[$freeradius::fr_package], Group[$freeradius::fr_group]], ensure_newline => true,
require => [Package[$freeradius::fr_package], Group[$freeradius::fr_group]],
} }
concat::fragment { 'dictionary_header': concat::fragment { 'dictionary_header':
target => "${freeradius::fr_basepath}/dictionary", target => "${freeradius::fr_basepath}/dictionary",
...@@ -256,11 +261,12 @@ class freeradius ( ...@@ -256,11 +261,12 @@ class freeradius (
# Install a huntgroups file # Install a huntgroups file
concat { "${freeradius::fr_basepath}/mods-config/preprocess/huntgroups": concat { "${freeradius::fr_basepath}/mods-config/preprocess/huntgroups":
owner => 'root', owner => 'root',
group => $freeradius::fr_group, group => $freeradius::fr_group,
mode => '0640', mode => '0640',
require => [Package[$freeradius::fr_package], Group[$freeradius::fr_group]], ensure_newline => true,
notify => Service[$freeradius::fr_service], require => [Package[$freeradius::fr_package], Group[$freeradius::fr_group]],
notify => Service[$freeradius::fr_service],
} }
concat::fragment { 'huntgroups_header': concat::fragment { 'huntgroups_header':
target => "${freeradius::fr_basepath}/mods-config/preprocess/huntgroups", target => "${freeradius::fr_basepath}/mods-config/preprocess/huntgroups",
...@@ -454,7 +460,7 @@ class freeradius ( ...@@ -454,7 +460,7 @@ class freeradius (
"${freeradius::fr_basepath}/clients.conf", "${freeradius::fr_basepath}/clients.conf",
"${freeradius::fr_basepath}/sql.conf", "${freeradius::fr_basepath}/sql.conf",
]: ]:
content => "# FILE INTENTIONALLY BLANK\n", content => '# FILE INTENTIONALLY BLANK',
mode => '0644', mode => '0644',
owner => 'root', owner => 'root',
group => $freeradius::fr_group, group => $freeradius::fr_group,
......
...@@ -25,7 +25,7 @@ define freeradius::policy ( ...@@ -25,7 +25,7 @@ define freeradius::policy (
if ($ensure == 'present') { if ($ensure == 'present') {
concat::fragment { "policy-${name}": concat::fragment { "policy-${name}":
target => "${fr_basepath}/policy.conf", target => "${fr_basepath}/policy.conf",
content => "\t\$INCLUDE ${fr_basepath}/policy.d/${name}\n", content => "\t\$INCLUDE ${fr_basepath}/policy.d/${name}",
order => $order, order => $order,
require => File["${fr_basepath}/policy.d/${name}"], require => File["${fr_basepath}/policy.d/${name}"],
} }
......
...@@ -79,10 +79,11 @@ describe 'freeradius' do ...@@ -79,10 +79,11 @@ describe 'freeradius' do
it do it do
is_expected.to contain_concat('/etc/raddb/policy.conf') is_expected.to contain_concat('/etc/raddb/policy.conf')
.with( .with(
'group' => 'radiusd', 'group' => 'radiusd',
'mode' => '0640', 'mode' => '0640',
'notify' => 'Service[radiusd]', 'notify' => 'Service[radiusd]',
'owner' => 'root', 'owner' => 'root',
'ensure_newline' => true,
) )
.that_requires('Package[freeradius]') .that_requires('Package[freeradius]')
.that_requires('Group[radiusd]') .that_requires('Group[radiusd]')
...@@ -109,10 +110,11 @@ describe 'freeradius' do ...@@ -109,10 +110,11 @@ describe 'freeradius' do
it do it do
is_expected.to contain_concat('/etc/raddb/proxy.conf') is_expected.to contain_concat('/etc/raddb/proxy.conf')
.with( .with(
'group' => 'radiusd', 'group' => 'radiusd',
'mode' => '0640', 'mode' => '0640',
'notify' => 'Service[radiusd]', 'notify' => 'Service[radiusd]',
'owner' => 'root', 'owner' => 'root',
'ensure_newline' => true,
) )
.that_requires('Package[freeradius]') .that_requires('Package[freeradius]')
.that_requires('Group[radiusd]') .that_requires('Group[radiusd]')
...@@ -121,7 +123,7 @@ describe 'freeradius' do ...@@ -121,7 +123,7 @@ describe 'freeradius' do
it do it do
is_expected.to contain_concat__fragment('proxy_header') is_expected.to contain_concat__fragment('proxy_header')
.with( .with(
'content' => "# Proxy config\n", 'content' => '# Proxy config',
'order' => '05', 'order' => '05',
'target' => '/etc/raddb/proxy.conf', 'target' => '/etc/raddb/proxy.conf',
) )
...@@ -130,10 +132,11 @@ describe 'freeradius' do ...@@ -130,10 +132,11 @@ describe 'freeradius' do
it do it do
is_expected.to contain_concat('/etc/raddb/mods-available/attr_filter') is_expected.to contain_concat('/etc/raddb/mods-available/attr_filter')
.with( .with(
'group' => 'radiusd', 'group' => 'radiusd',
'mode' => '0640', 'mode' => '0640',
'notify' => 'Service[radiusd]', 'notify' => 'Service[radiusd]',
'owner' => 'root', 'owner' => 'root',
'ensure_newline' => true,
) )
.that_requires('Package[freeradius]') .that_requires('Package[freeradius]')
.that_requires('Group[radiusd]') .that_requires('Group[radiusd]')
...@@ -150,9 +153,10 @@ describe 'freeradius' do ...@@ -150,9 +153,10 @@ describe 'freeradius' do
it do it do
is_expected.to contain_concat('/etc/raddb/dictionary') is_expected.to contain_concat('/etc/raddb/dictionary')
.with( .with(
'group' => 'radiusd', 'group' => 'radiusd',
'mode' => '0644', 'mode' => '0644',
'owner' => 'root', 'owner' => 'root',
'ensure_newline' => true,
) )
.that_requires('Package[freeradius]') .that_requires('Package[freeradius]')
.that_requires('Group[radiusd]') .that_requires('Group[radiusd]')
...@@ -364,7 +368,7 @@ describe 'freeradius' do ...@@ -364,7 +368,7 @@ describe 'freeradius' do
].each do |file| ].each do |file|
is_expected.to contain_file(file) is_expected.to contain_file(file)
.with( .with(
'content' => "# FILE INTENTIONALLY BLANK\n", 'content' => '# FILE INTENTIONALLY BLANK',
'group' => 'radiusd', 'group' => 'radiusd',
'mode' => '0644', 'mode' => '0644',
'notify' => 'Service[radiusd]', 'notify' => 'Service[radiusd]',
......
...@@ -25,7 +25,7 @@ describe 'freeradius::policy' do ...@@ -25,7 +25,7 @@ describe 'freeradius::policy' do
it do it do
is_expected.to contain_concat__fragment('policy-test') is_expected.to contain_concat__fragment('policy-test')
.with_content(%r{\s+\$INCLUDE /etc/raddb/policy.d/test\n}) .with_content(%r{\s+\$INCLUDE /etc/raddb/policy.d/test$})
.with_order('50') .with_order('50')
.with_target('/etc/raddb/policy.conf') .with_target('/etc/raddb/policy.conf')
.that_requires('File[/etc/raddb/policy.d/test]') .that_requires('File[/etc/raddb/policy.d/test]')
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment