Ask Your Question

error with multiple lines in file_line

asked 2013-11-06 07:14:47 -0600

stripybadger gravatar image

I'm trying to collapse multiple 'file_line' blocks into one. However, this is causing a strange error. Can someone please tell me if I've found a bug or if what I'm doing is invalid? (I'm fairly new to puppet so the latter is quite likely)

My class:

class mytestclass {
    file { "/opt/testFile":
        ensure => present
    } ->
    file_line { "test-1":
        path => "/opt/testFile",
        line => ["blah blah first line","blah blah third line"]

The first time it runs (when the file doesn't exist) it all works fine. But if it runs again (when the file does exist), I get the following ... (more)

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2013-11-06 10:51:06 -0600

lavaman gravatar image

What you're doing is invalid. There is a reason it's not called file_lines :)

If you're just trying to tidy up your code, you could look at using create_resources() to generate the file lines:

edit flag offensive delete link more


Thank you for that, create resources seems to be the answer, except that now I can't seem to specify any kind of ordering or dependency? Clearly, I want the ...(more)

stripybadger gravatar imagestripybadger ( 2013-11-07 04:00:25 -0600 )edit

You can actually do something like this: line => "SOMEVAR=\"$hostname\"\nNOWYOUREAMAN=\"M A N, Man\"", New line characters seem to work.

berglh gravatar imageberglh ( 2016-03-31 23:12:34 -0600 )edit

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: 2013-11-06 07:14:47 -0600

Seen: 5,187 times

Last updated: Nov 06 '13