Robert Citek
2013-Mar-06 06:49 UTC
[Puppet Users] multi-line content= construct for puppet resource file command
Hello all, How does one enter multi-line content using ''puppet resource file ...'' at the command line? For example, I am trying to create a file called /tmp/hw.txt with two lines of content: $ cat /tmp/hw.txt hello world This does not work: $ puppet resource file hello_world \ path=/tmp/hw.txt \ ensure=file \ content="hello\nworld\n" This does, but use "puppet apply" : cat <<"eof" | puppet apply file { "hello_world": path => "/tmp/hw.txt", ensure => "file", content => "hello\nworld\n", } eof Does anyone have any pointers on how to construct the content= line so that I can get two lines of text? Regards, - Robert -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Felix Frank
2013-Mar-12 12:36 UTC
Re: [Puppet Users] multi-line content= construct for puppet resource file command
Hi, at first glance, it doesn''t seem to be possible. I had never thought of using puppet resource in this way. Is there a reason why you prefer it over puppet apply? On 03/06/2013 07:49 AM, Robert Citek wrote:> Hello all, > > How does one enter multi-line content using ''puppet resource file ...'' > at the command line? > > For example, I am trying to create a file called /tmp/hw.txt with two > lines of content: > > $ cat /tmp/hw.txt > hello > world > > This does not work: > > $ puppet resource file hello_world \ > path=/tmp/hw.txt \ > ensure=file \ > content="hello\nworld\n" > > This does, but use "puppet apply" : > > cat <<"eof" | puppet apply > file { "hello_world": > path => "/tmp/hw.txt", > ensure => "file", > content => "hello\nworld\n", > } > eof > > Does anyone have any pointers on how to construct the content= line so > that I can get two lines of text? > > Regards, > - Robert-- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Robert Citek
2013-Mar-12 19:55 UTC
Re: [Puppet Users] multi-line content= construct for puppet resource file command
Just preference and consistency. We''ve been using puppet as a substitute for shell commands that use the ''command [options] arguments ... '' pattern and ''puppet resource ...'' matches that pattern nicely. But if by using here-documents we can match the pattern pretty closely and we gain the additional functionality, we''ll go that way. Using ''puppet apply'' with a here-document .... puppet apply <<"eof" file { "hello_world": path => "/tmp/hw.txt", ensure => "file", content => "hello\nworld\n", } eof ... looks pretty close to using arguments to ''puppet resource'' ... $ puppet resource \ file hello_world \ path=/tmp/hw.txt \ ensure=file \ content="hello\nworld\n" ... but actually works. :) Regards, - Robert On Tue, Mar 12, 2013 at 8:36 AM, Felix Frank <felix.frank@alumni.tu-berlin.de> wrote:> Hi, > > at first glance, it doesn''t seem to be possible. > > I had never thought of using puppet resource in this way. Is there a > reason why you prefer it over puppet apply? > > On 03/06/2013 07:49 AM, Robert Citek wrote: >> Hello all, >> >> How does one enter multi-line content using ''puppet resource file ...'' >> at the command line? >> >> For example, I am trying to create a file called /tmp/hw.txt with two >> lines of content: >> >> $ cat /tmp/hw.txt >> hello >> world >> >> This does not work: >> >> $ puppet resource file hello_world \ >> path=/tmp/hw.txt \ >> ensure=file \ >> content="hello\nworld\n" >> >> This does, but use "puppet apply" : >> >> cat <<"eof" | puppet apply >> file { "hello_world": >> path => "/tmp/hw.txt", >> ensure => "file", >> content => "hello\nworld\n", >> } >> eof >> >> Does anyone have any pointers on how to construct the content= line so >> that I can get two lines of text? >> >> Regards, >> - Robert > > -- > You received this message because you are subscribed to the Google Groups "Puppet Users" group. > To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. > To post to this group, send email to puppet-users@googlegroups.com. > Visit this group at http://groups.google.com/group/puppet-users?hl=en. > For more options, visit https://groups.google.com/groups/opt_out. > >-- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Reasonably Related Threads
- Different return codes on exec during puppet agent run vs command line Windows
- LLD-linked binary segfaults at runtime on alpine linux
- LLD-linked binary segfaults at runtime on alpine linux
- LLD-linked binary segfaults at runtime on alpine linux
- [LLVMdev] Using output from dragonegg