If you need information from the client, then you should think 'facter'.

Or you could write a custom fact, or use external facts.

http://puppetlabs.com/blog/facter-1-7-introduces-external-facts
http://docs.puppetlabs.com/guides/custom_facts.html

HTH

Jo


On 02/14/2014 12:18 AM, Ray 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.


--
Johan De Wit

Open Source Consultant

Red Hat Certified Engineer         (805008667232363)
Puppet Certified Professional 2013 (PCP0000006)
_________________________________________________________
Open-Future Phone +32 (0)2/255 70 70
Zavelstraat 72              Fax       +32 (0)2/255 70 71
3071 KORTENBERG             Mobile    +32 (0)474/42 40 73
BELGIUM                     http://www.open-future.be
_________________________________________________________

Next Events:
Zabbix Certified Training | 
http://www.open-future.be/zabbix-certified-training-10-till-12th-march
Zabbix for Large Environments Training | 
http://www.open-future.be/zabbix-large-environments-training-13-till-14th-march
Puppet Intruction Course | 
http://www.open-future.be/puppet-introduction-course-14th-april
Puppet Advanced Training | 
http://www.open-future.be/puppet-advanced-training-15-till-17th-april
Subscribe to our newsletter | http://eepurl.com/BUG8H

--
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/52FE164C.6070803%40open-future.be.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to