Hi there, I''m basically trying to change a line this: myenv_set "MY_SW_DIR_1" "/exp/dir/sw1" to myenv_set "MY_SW_DIR_1" "/exp/fs/sw1.ac.uk" in the one of the "/etc/profile.d/" file. So, I''ve defined it like this: ----------------- define env_check($file, $string, $swdir, $refreshonly = ''false'') { $q_cmd = "/usr/bin/printenv | grep -F $swdir | cut -d= -f2" exec { "/bin/sed -e \"/$swdir/{s:$($q_cmd):$string:g}\" ''$file''": #unless => "/usr/bin/printenv | grep -F $swdir | cut -d= -f2 | grep -vFxe ''$string''", unless => "eval $q_cmd | grep -vFq ''$string''", path => ''/bin'', refreshonly => $refreshonly, } } ------------------- and then use it like this: ------------------- env_check { sw_dir1: file => ''/etc/profile.d/my-env.sh'', string => ''/exp/fs/sw1.ac.uk'', swdir => ''MY_SW_DIR_1''; } } ------------------- but it''s not working. Can anyone please help? Cheers!! -- 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.
Hi, I can''t help directly with your issue cause I''m not at a computer but wouldn''t it be easier to use a file resource with a template in this case rather than mess around with the escaping in the execs? Cheers, Den On 01/12/2011, at 6:33, Sans <r.santanu.das@gmail.com> wrote:> Hi there, > > I''m basically trying to change a line this: > > myenv_set "MY_SW_DIR_1" "/exp/dir/sw1" > to > myenv_set "MY_SW_DIR_1" "/exp/fs/sw1.ac.uk" > > in the one of the "/etc/profile.d/" file. So, I''ve defined it like > this: > > ----------------- > define env_check($file, $string, $swdir, $refreshonly = ''false'') { > $q_cmd = "/usr/bin/printenv | grep -F $swdir | cut -d= -f2" > exec { "/bin/sed -e \"/$swdir/{s:$($q_cmd):$string:g}\" ''$file''": > #unless => "/usr/bin/printenv | grep -F $swdir | cut -d= -f2 > | grep -vFxe ''$string''", > unless => "eval $q_cmd | grep -vFq ''$string''", > path => ''/bin'', > refreshonly => $refreshonly, > } > } > ------------------- > > and then use it like this: > > ------------------- > env_check { sw_dir1: > file => ''/etc/profile.d/my-env.sh'', > string => ''/exp/fs/sw1.ac.uk'', > swdir => ''MY_SW_DIR_1''; > } > } > ------------------- > > but it''s not working. Can anyone please help? Cheers!! > > -- > 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. >-- 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.
Hi Den, I actually thought about file resource as well but didn''t able to work out how to manage that as there could/should be more than one line to change and I that would be need to do basis. Cheers, San On Nov 30, 8:39 pm, Denmat <tu2bg...@gmail.com> wrote:> Hi, > > I can''t help directly with your issue cause I''m not at a computer but wouldn''t it be easier to use a file resource with a template in this case rather than mess around with the escaping in the execs? > > Cheers, > Den >-- 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.
Does anyone have any other suggestions for me please? cheers!! -- 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.
Bernd Adamowicz
2011-Dec-01 15:23 UTC
AW: [Puppet Users] Re: How to make partial change to a line??
Augeas?> -----Ursprüngliche Nachricht----- > Von: puppet-users@googlegroups.com [mailto:puppet- > users@googlegroups.com] Im Auftrag von Sans > Gesendet: Donnerstag, 1. Dezember 2011 15:54 > An: Puppet Users > Betreff: [Puppet Users] Re: How to make partial change to a line?? > > Does anyone have any other suggestions for me please? cheers!! > > -- > 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.-- 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.
Augeas - does it work for any file? just tried and "augtool print / files/etc/profile.d/my-env.sh" on the agent returns nothing. Cheers!! On Dec 1, 3:23 pm, Bernd Adamowicz <Bernd.Adamow...@esailors.de> wrote:> Augeas?-- 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.
It worked! sorry for noise, guys. There was a silly mistake in my "sed" command: I should have given "-i -c" to change the line in file. For the future ref., this is what it should look like: --------------------------------------------------------------- define env_check($file, $string, $swdir, $refreshonly = ''true'') { $q_cmd = "/usr/bin/printenv | grep -F $swdir | cut -d= -f2" exec { ''chk_sw_dir'': command => "/bin/sed -i -c \"/$swdir/{s:$($q_cmd):$string:g} \" ''$file''", onlyif => "$q_cmd | grep -vFxe ''$string''", subscribe => File[''grid-env.sh''], refreshonly => $refreshonly, } } ---------------------------------------------------------------- Cheers!! Cheers!! -- 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.