Hi, I think that the problem here is a big misunderstood about how puppet works. Puppet DSL is a declarative language, you do not have to tell what to do (grep "xxx" on file "yyy"), you have to tell which final state do you want. Obviously this final state may depend on data (facts/hiera) but never on an action (grep)
Moreover, puppet manifests are compiled in the puppetmaster (so if it would be possible to do a grep or any other action, it would be made on the master). The problem you are facing is that the code if "any string that you may want" is always true (at least the string is empty) that's why always falls in the first condition. regards, On Fri, Feb 14, 2014 at 12:18 AM, Ray <raym...@rlscott.com> wrote: > Newbie question: > I need to be able to apply a specific template based on whether a string > is found in an > existing file on the client or not. I tried the following (found an > example somewhere... it does not work.. always falls into the first > condition) > > What would be the correct way to check for the value in the file? > > > if "grep STANDARD /var/adm/buildIT/ServerBuild.dat 2>/dev/null" > { > file { '/etc/openssh/sshd_config': > ensure => file, > backup => false, > content => template("sshdconfig/sshdconfigsol.erb"), > notify => Service['ssh'] > } > > service { 'ssh': > ensure => running, > enable => true, > hasstatus => true, > hasrestart => true, > } > } > else > { > file { '/etc/openssh/sshd_config': > ensure => file, > backup => false, > content => template("sshdconfig/sshdconfigsolpm.erb"), > notify => Service['ssh'] > } > > service { 'ssh': > ensure => running, > enable => true, > hasstatus => true, > hasrestart => true, > } > } > > -- > 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+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/puppet-users/e502a7ac-cebc-4454-900e-d504f2a89956%40googlegroups.com > . > For more options, visit https://groups.google.com/groups/opt_out. > -- José Luis Ledesma -- 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+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/CAF_B3dcQ1AzcKCY3Qb0zA-26uL1tkTEs0z1PMNLZT5A3Nen-xA%40mail.gmail.com. For more options, visit https://groups.google.com/groups/opt_out.