title: puppet: if one file exists then copy another file over
body: <p>I am trying to figure out how to make my puppet module work such I need to test if file exists on the client, if it does, then copy another file over. If the file does not exist then do nothing. I can't seem to get it working. Here is my module:</p>
  
  <p>class web-logs::config {</p>
  
  <pre><code>  # PATH TO LOG FILES
    $passenger='/var/tmp/puppet_test/passenger'
  
    # PATH TO LOGROTATE CONFIGS
    $passenger_logrotate='/var/tmp/puppet_test/logrotate.d/passenger'
  
    exec { 'test1':
       onlyif  =&gt; "test -f $passenger",
       path    =&gt; ['/usr/bin','/usr/sbin','/bin','/sbin'],
       refreshonly =&gt; true,
    } ~&gt;
  
    exec { 'test2':
       require =&gt; Class['web-logs::passenger']
    }
  </code></pre>
  
  <p>And the Class['web-logs::passenger'] looks like this:</p>
  
  <pre><code>class web-logs::passenger {
    file { 'passenger':                                                  
      path    =&gt; '/var/tmp/puppet_test/logrotate.d/passenger',         
      owner   =&gt; 'root',
      group   =&gt; 'root',
      mode    =&gt; '0644',
      source  =&gt; "puppet://${puppetserver}/modules/web-logs/passenger.conf",
    }
  }
  </code></pre>
  
  <p>Any help would be appreciated thanks!</p>