Windows Manifest Newline Syntax and Append to file Questions

169 views
Skip to first unread message

jim

unread,
Nov 20, 2012, 6:23:52 AM11/20/12
to puppet...@googlegroups.com
Hello all,

I'm fairly new to puppet and in the majority a windows shop

I have two questions

1.) As windows syntax is slight different than linux syntax, how do I create a new line within a bit of content, e.g. hosts file "for windows not linux"

e.g.

        file {'c:/Windows/System32/drivers/etc/hosts':
        content         =>
                "127.0.0.1      puppet.office \n
                127.0.0.1       puppet8081.office",
        }

As it seems to ignore the \n

2.) also can you append to a file, for example your base machines get the standard host file and futher down the tree it goes it might get host entries amended to it.

Kind Regards

James

Josh Cooper

unread,
Nov 20, 2012, 1:26:07 PM11/20/12
to puppet...@googlegroups.com
Hi James,

On Tue, Nov 20, 2012 at 3:23 AM, jim <str...@gmail.com> wrote:
> Hello all,
>
> I'm fairly new to puppet and in the majority a windows shop
>
> I have two questions
>
> 1.) As windows syntax is slight different than linux syntax, how do I create
> a new line within a bit of content, e.g. hosts file "for windows not linux"
>
> e.g.
>
> file {'c:/Windows/System32/drivers/etc/hosts':
> content =>
> "127.0.0.1 puppet.office \n
> 127.0.0.1 puppet8081.office",
> }
>
> As it seems to ignore the \n

To manage a text file using native Windows line endings, you'll want
to use \r\n (carriage return, newline). Specifying carriage returns
(\r) in the file resources's content property was fixed in 2.7.20[1],
released yesterday[2]. Alternatively, you can create a file containing
\r\n on the puppetmaster and then specify the source parameter using a
puppet URI, e.g. puppet:///modules/mymodule/hosts

With that said, is there a reason you are not using the `host`
resource[3]? It should do-the-right-thing on both *nix and windows. Is
filesystem redirection causing problems?

> 2.) also can you append to a file, for example your base machines get the
> standard host file and futher down the tree it goes it might get host
> entries amended to it.

I imagine this is a common issue when using the `host` resource, I'm
curious how other people have solved this.

>
> Kind Regards
>
> James
>
> --
> You received this message because you are subscribed to the Google Groups
> "Puppet Users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/puppet-users/-/IUFifHBoo6IJ.
> To post to this group, send email to puppet...@googlegroups.com.
> To unsubscribe from this group, send email to
> puppet-users...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/puppet-users?hl=en.

Josh

[1] http://projects.puppetlabs.com/issues/16119
[2] https://groups.google.com/d/topic/puppet-users/nPkPm3yqo4Q/discussion
[3] http://docs.puppetlabs.com/windows/writing.html#hosthost

--
Josh Cooper
Developer, Puppet Labs
Reply all
Reply to author
Forward
0 new messages