Hi all, im trying to make a module to add a line at the end of the /etc/profile file to redirect all the loggins to a remote server. It´s something like this: class syslog { define append_if_no_such_line ($file, $line) { exec { "Line1" : command => "/bin/echo ''$line'' >> ''$file''", unless => "/bin/grep -Fx ''$line'' ''$file''", alias => "Line1", } } append_if_no_such_line { "modify.profile.redhat" : file => "/etc/profile", line => " PROMPT_COMMAND=''history -a >(tee -a ~/.bash_history | logger -t "USER: $USER[$$] SSH: $SSH_CONNECTION $PWD")'' ", } } The problem is that the line i want to add have a lot of " " and '' '' and puppet cut the line and give me an error of execution. Anyone know how to pass this line: PROMPT_COMMAND=''history -a >(tee -a ~/.bash_history | logger -t "USER: $USER[$$] SSH: $SSH_CONNECTION $PWD")'' as a single line in puppet? Thanks a lot, sorry about my english Javier Arduini -- 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/-/q6R6cMcysRIJ. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
First, put the whole line in single quotes in order to prevent Puppet from trying to resolve all the dollar signs as variables. Then simply escape all quotes within your string. I didn''t test it, but this should work: line => ''PROMPT_COMMAND=\''history -a >(tee -a ~/.bash_history | logger -t \"USER: $USER[$$] SSH: $SSH_CONNECTION $PWD\")\'''' , As an alternative you might want to have a look at Puppet''s Augeas. Bernd From: puppet-users@googlegroups.com [mailto:puppet-users@googlegroups.com] On Behalf Of Javier Arduini Sent: Dienstag, 11. Dezember 2012 13:16 To: puppet-users@googlegroups.com Subject: [Puppet Users] exec command Hi all, im trying to make a module to add a line at the end of the /etc/profile file to redirect all the loggins to a remote server. It´s something like this: class syslog { define append_if_no_such_line ($file, $line) { exec { "Line1" : command => "/bin/echo ''$line'' >> ''$file''", unless => "/bin/grep -Fx ''$line'' ''$file''", alias => "Line1", } } append_if_no_such_line { "modify.profile.redhat" : file => "/etc/profile", line => " PROMPT_COMMAND=''history -a >(tee -a ~/.bash_history | logger -t "USER: $USER[$$] SSH: $SSH_CONNECTION $PWD")'' ", } } The problem is that the line i want to add have a lot of " " and '' '' and puppet cut the line and give me an error of execution. Anyone know how to pass this line: PROMPT_COMMAND=''history -a >(tee -a ~/.bash_history | logger -t "USER: $USER[$$] SSH: $SSH_CONNECTION $PWD")'' as a single line in puppet? Thanks a lot, sorry about my english Javier Arduini -- 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/-/q6R6cMcysRIJ. To post to this group, send email to puppet-users@googlegroups.com<mailto:puppet-users@googlegroups.com>. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com<mailto:puppet-users+unsubscribe@googlegroups.com>. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en. -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Hello Bernd, thanks for the answer, but when i trie to escape the quotes puppet print this error message: err: /Stage[main]/Logger/Logger::Append_if_no_such_line7[modify.profile.redhat]/Exec[Line7]/returns: change from notrun to 0 failed: /bin/echo ''PROMPT_COMMAND\=''history'' >> ''/etc/profile'' returned 1 instead of one of [0] at /etc/puppet/modules/logger/manifests/init.pp:69 im going to read about augeas. Em terça-feira, 11 de dezembro de 2012 14h18min29s UTC-2, badamowicz escreveu:> > First, put the whole line in single quotes in order to prevent Puppet from > trying to resolve all the dollar signs as variables. Then simply escape all > quotes within your string. I didn’t test it, but this should work: > > > > line => ‘PROMPT_COMMAND=\''history -a >(tee -a ~/.bash_history | logger -t > \"USER: $USER[$$] SSH: $SSH_CONNECTION $PWD\")\''’ , > > > > As an alternative you might want to have a look at Puppet’s Augeas. > > > > Bernd > > > > *From:* puppet...@googlegroups.com <javascript:> [mailto: > puppet...@googlegroups.com <javascript:>] *On Behalf Of *Javier Arduini > *Sent:* Dienstag, 11. Dezember 2012 13:16 > *To:* puppet...@googlegroups.com <javascript:> > *Subject:* [Puppet Users] exec command > > > > Hi all, im trying to make a module to add a line at the end of the > /etc/profile file to redirect all the loggins to a remote server. It´s > something like this: > > > > class syslog { > > > > define append_if_no_such_line ($file, $line) { > > exec { "Line1" : > > command => "/bin/echo ''$line'' >> ''$file''", > > unless => "/bin/grep -Fx ''$line'' ''$file''", > > alias => "Line1", > > } > > } > > > > append_if_no_such_line { > > "modify.profile.redhat" : > > file => "/etc/profile", > > line => " PROMPT_COMMAND=''history -a >(tee -a ~/.bash_history | > logger -t "USER: $USER[$$] SSH: $SSH_CONNECTION $PWD")'' ", > > } > > > > } > > > > The problem is that the line i want to add have a lot of " " and '' '' and > puppet cut the line and give me an error of execution. > > Anyone know how to pass this line: PROMPT_COMMAND=''history -a >(tee -a > ~/.bash_history | logger -t "USER: $USER[$$] SSH: $SSH_CONNECTION $PWD")'' > as a single line in puppet? > > Thanks a lot, sorry about my english > > Javier Arduini > > -- > 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/-/q6R6cMcysRIJ. > To post to this group, send email to puppet...@googlegroups.com<javascript:> > . > To unsubscribe from this group, send email to > puppet-users...@googlegroups.com <javascript:>. > For more options, visit this group at > http://groups.google.com/group/puppet-users?hl=en. >-- 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/-/U_CLzTGH0jIJ. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
On Tuesday, December 11, 2012 7:16:17 AM UTC-5, Javier Arduini wrote:> Hi all, im trying to make a module to add a line at the end of the > /etc/profile file to redirect all the loggins to a remote server. It´s > something like this: > > class syslog { > > define append_if_no_such_line ($file, $line) { > exec { "Line1" : > command => "/bin/echo ''$line'' >> ''$file''", > unless => "/bin/grep -Fx ''$line'' ''$file''", > alias => "Line1", > } > } > > append_if_no_such_line { > "modify.profile.redhat" : > file => "/etc/profile", > line => " PROMPT_COMMAND=''history -a >(tee -a ~/.bash_history | > logger -t "USER: $USER[$$] SSH: $SSH_CONNECTION $PWD")'' ", > } > > } > > The problem is that the line i want to add have a lot of " " and '' '' and > puppet cut the line and give me an error of execution. > Anyone know how to pass this line: PROMPT_COMMAND=''history -a >(tee -a > ~/.bash_history | logger -t "USER: $USER[$$] SSH: $SSH_CONNECTION $PWD")'' > as a single line in puppet? > Thanks a lot, sorry about my english > Javier Arduini >Javier, Your English is fine, but your quotes are not. :) I ran a few different tests and found that quoting the line value as follows will result in the line actually being appended to /etc/profile: line => ''PROMPT_COMMAND="history -a >(tee -a ~/.bash_history | logger -t \"USER: $USER[$$] SSH: $SSH_CONNECTION $PWD\")" '', -- Peter -- 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/-/DBPzXfAJ0TUJ. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Hi Peter, the problem with is that i need something like this: line => ''PROMPT_COMMAND=''history -a >(tee -a ~/.bash_history | logger -t \"USER: $USER[$$] SSH: $SSH_CONNECTION $PWD\")'' '', ''history and not "history and in the end )'' not )" Any clues how to solve this? Thanks for the answer!! :) Em terça-feira, 11 de dezembro de 2012 16h35min10s UTC-2, pmbuko escreveu:> > On Tuesday, December 11, 2012 7:16:17 AM UTC-5, Javier Arduini wrote: > >> Hi all, im trying to make a module to add a line at the end of the >> /etc/profile file to redirect all the loggins to a remote server. It´s >> something like this: >> >> class syslog { >> >> define append_if_no_such_line ($file, $line) { >> exec { "Line1" : >> command => "/bin/echo ''$line'' >> ''$file''", >> unless => "/bin/grep -Fx ''$line'' ''$file''", >> alias => "Line1", >> } >> } >> >> append_if_no_such_line { >> "modify.profile.redhat" : >> file => "/etc/profile", >> line => " PROMPT_COMMAND=''history -a >(tee -a ~/.bash_history >> | logger -t "USER: $USER[$$] SSH: $SSH_CONNECTION $PWD")'' ", >> } >> >> } >> >> The problem is that the line i want to add have a lot of " " and '' '' and >> puppet cut the line and give me an error of execution. >> Anyone know how to pass this line: PROMPT_COMMAND=''history -a >(tee -a >> ~/.bash_history | logger -t "USER: $USER[$$] SSH: $SSH_CONNECTION $PWD")'' >> as a single line in puppet? >> Thanks a lot, sorry about my english >> Javier Arduini >> > > Javier, > > Your English is fine, but your quotes are not. :) I ran a few different > tests and found that quoting the line value as follows will result in the > line actually being appended to /etc/profile: > > line => ''PROMPT_COMMAND="history -a >(tee -a ~/.bash_history | logger -t > \"USER: $USER[$$] SSH: $SSH_CONNECTION $PWD\")" '', > > -- > Peter >-- 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/-/NXGpGrgJ9FIJ. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Hi Peter, the problem with is that i need something like this: line => ''PROMPT_COMMAND=''history -a >(tee -a ~/.bash_history | logger -t \"USER: $USER[$$] SSH: $SSH_CONNECTION $PWD\")'' '', ''history and not "history and in the end )'' not )" Any clues how to solve this? Thanks for the answer!! :) Em terça-feira, 11 de dezembro de 2012 16h35min10s UTC-2, pmbuko escreveu:> > On Tuesday, December 11, 2012 7:16:17 AM UTC-5, Javier Arduini wrote: > >> Hi all, im trying to make a module to add a line at the end of the >> /etc/profile file to redirect all the loggins to a remote server. It´s >> something like this: >> >> class syslog { >> >> define append_if_no_such_line ($file, $line) { >> exec { "Line1" : >> command => "/bin/echo ''$line'' >> ''$file''", >> unless => "/bin/grep -Fx ''$line'' ''$file''", >> alias => "Line1", >> } >> } >> >> append_if_no_such_line { >> "modify.profile.redhat" : >> file => "/etc/profile", >> line => " PROMPT_COMMAND=''history -a >(tee -a ~/.bash_history >> | logger -t "USER: $USER[$$] SSH: $SSH_CONNECTION $PWD")'' ", >> } >> >> } >> >> The problem is that the line i want to add have a lot of " " and '' '' and >> puppet cut the line and give me an error of execution. >> Anyone know how to pass this line: PROMPT_COMMAND=''history -a >(tee -a >> ~/.bash_history | logger -t "USER: $USER[$$] SSH: $SSH_CONNECTION $PWD")'' >> as a single line in puppet? >> Thanks a lot, sorry about my english >> Javier Arduini >> > > Javier, > > Your English is fine, but your quotes are not. :) I ran a few different > tests and found that quoting the line value as follows will result in the > line actually being appended to /etc/profile: > > line => ''PROMPT_COMMAND="history -a >(tee -a ~/.bash_history | logger -t > \"USER: $USER[$$] SSH: $SSH_CONNECTION $PWD\")" '', > > -- > Peter >-- 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/-/Fxip932V5E0J. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.