Skip to content

Commit f1255d9

Browse files
Simon Peetersekohl
authored andcommitted
Add newline at the end of each config block
1 parent a51e38e commit f1255d9

File tree

3 files changed

+27
-4
lines changed

3 files changed

+27
-4
lines changed

manifests/config.pp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,12 @@
7373
puppet::config::main { $key: value => $value }
7474
}
7575

76+
concat::fragment { 'puppet.conf_comment':
77+
target => "${puppet_dir}/puppet.conf",
78+
content => '# file managed by puppet',
79+
order => '0_comment',
80+
}
81+
7682
file { $puppet_dir:
7783
ensure => directory,
7884
owner => $puppet::dir_owner,

manifests/config/entry.pp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,14 @@
3030
# they make sure that '1_main ' is ordered before '1_main_*'
3131
ensure_resource('concat::fragment', "puppet.conf_${section}", {
3232
target => "${puppet::dir}/puppet.conf",
33-
content => "\n\n[${section}]",
33+
content => "\n[${section}]",
3434
order => "${sectionorder}_${section} ",
3535
})
36+
ensure_resource('concat::fragment', "puppet.conf_${section}_end", {
37+
target => "${puppet::dir}/puppet.conf",
38+
content => "\n",
39+
order => "${sectionorder}_${section}~end",
40+
})
3641

3742
# this adds the '$key =' for the first value,
3843
# otherwise it just appends it with the joiner to separate it from the previous value.

spec/defines/puppet_config_entry_spec.rb

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,13 @@
2020
}
2121
end
2222
it 'should contain the section header' do
23-
should contain_concat__fragment('puppet.conf_main').with_content("\n\n[main]")
23+
should contain_concat__fragment('puppet.conf_main').with_content("\n[main]")
2424
should contain_concat__fragment('puppet.conf_main').with_order("1_main ")
2525
end
26+
it 'should contain the section end' do
27+
should contain_concat__fragment('puppet.conf_main_end').with_content("\n")
28+
should contain_concat__fragment('puppet.conf_main_end').with_order("1_main~end")
29+
end
2630
it 'should contain the keyvalue pair' do
2731
should contain_concat__fragment('puppet.conf_main_foo').with_content(/^\s+foo = bar$/)
2832
should contain_concat__fragment('puppet.conf_main_foo').with_order("1_main_foo ")
@@ -41,9 +45,13 @@
4145
}
4246
end
4347
it 'should contain the section header' do
44-
should contain_concat__fragment('puppet.conf_main').with_content("\n\n[main]")
48+
should contain_concat__fragment('puppet.conf_main').with_content("\n[main]")
4549
should contain_concat__fragment('puppet.conf_main').with_order("1_main ")
4650
end
51+
it 'should contain the section end' do
52+
should contain_concat__fragment('puppet.conf_main_end').with_content("\n")
53+
should contain_concat__fragment('puppet.conf_main_end').with_order("1_main~end")
54+
end
4755
it 'should contain the keyvalue pair' do
4856
should contain_concat__fragment('puppet.conf_main_foo').with_content(/^\s+foo = bar,baz$/)
4957
should contain_concat__fragment('puppet.conf_main_foo').with_order("1_main_foo ")
@@ -63,9 +71,13 @@
6371
}
6472
end
6573
it 'should contain the section header' do
66-
should contain_concat__fragment('puppet.conf_main').with_content("\n\n[main]")
74+
should contain_concat__fragment('puppet.conf_main').with_content("\n[main]")
6775
should contain_concat__fragment('puppet.conf_main').with_order("1_main ")
6876
end
77+
it 'should contain the section end' do
78+
should contain_concat__fragment('puppet.conf_main_end').with_content("\n")
79+
should contain_concat__fragment('puppet.conf_main_end').with_order("1_main~end")
80+
end
6981
it 'should contain the keyvalue pair' do
7082
should contain_concat__fragment('puppet.conf_main_foo').with_content(/^\s+foo = bar:baz$/)
7183
should contain_concat__fragment('puppet.conf_main_foo').with_order("1_main_foo ")

0 commit comments

Comments
 (0)