i want to add, using puppet, text in existing file in desired place. Structure of the file is as follows:
[OPTION1]
aaa
bbb
ccc
I want to add text between aaa
and bbb
. For now I have figured out how to add text at the end of the file with:
file { '/home/file.txt': ensure => present, } ->
file_line { 'Add text to /home/file.txt':
path => '/home/file.txt',
line => 'added_text'
Should I use awk
or sed
(i saw it somewhere on google) or there is another way?
file_line
has an after
parameter, which you should set to the line you want the text to be inserted after:
file_line { 'Add text to /home/file.txt':
path => '/home/file.txt',
line => 'added_text',
after => 'aaa',
}
See the file_line documentation for a full list of supported features.