Ask Your Question

FILE_LINE does not work when i want to add multiple line in a file

asked 2014-08-12 01:48:08 -0600

yogu2912 gravatar image

updated 2014-08-26 17:30:07 -0600

ramindk gravatar image
    path => '/etc/mcp/templates/sysctl.conf_try',
    line => "\n# Settings done for Hardening\n# Disable kernel core dump\nkern.coredump=0",
    match => "^#[\s]+Settings[\s]+done[\s]+for[\s]+Hardening[\s]*[\n]+^#[\s]+Disable[\s]+kernel[\s]+core[\s]+dump[\s]*[\n]+kern.coredump",

Here I want to add 3 lines in file as below, if they does not exist.

# Settings done for Hardening
# Disable kernel core dump

It works fine, if those 3 lines are not present means at that time those 3 lines get added to file. But it does not work , when 3 lines are already present. In this case it is adding one more time those lines. So here it should not do anything.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2015-12-11 02:15:07 -0600

puppet_learner gravatar image

Well I think this is no time to answer such an old question but I thought I'll give it a try. I have just started with puppet & faced similar problem. The way file_line works is it adds the line if it's not present in the file. So instead of matching it try after removing match directive.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2014-08-12 01:48:08 -0600

Seen: 4,653 times

Last updated: Dec 11 '15