Short Answer: You need to create a custom fact that would drive the decision to 
create the new file resource.

I just went thru this issue and also performing an action based on whether or 
not a package (RPM in my case) is installed.

Same answer to both.

For the existence of a file, you can do this:

#!/bin/bash
test -f /var/www/owncloud/config/config.php
rc=$?
echo "is_my_file_there=${rc}"

That goes into /etc/facter/facts.d/ as an executable shell script and then in 
your manifest: 

if $::is_my_file_there != 0 {
   file { 'autoconfig.php': 
   .....
   }
}


“Sometimes I think the surest sign that intelligent life exists elsewhere in 
the universe is that none of it has tried to contact us.”
Bill Waterson (Calvin & Hobbes)

----- Original Message -----
From: "John Naggets" <hostingnugg...@gmail.com>
To: puppet-users@googlegroups.com
Sent: Thursday, May 30, 2013 4:04:29 PM
Subject: [Puppet Users] Run a File resource only if another file is missing

Hi, 

I would like to run the File resource below: 

file { 'autoconfig.php': 
path => '/var/www/owncloud/config/autoconfig.php', 
ensure => file, 
owner => 'www-data', 
group => 'www-data', 
content => template("owncloud/autoconfig.php.erb"), 
} 

only when a specific file (in my case: /var/www/owncloud/config/config.php) is 
missing. Is this somehow possible? Couldn't find my case in the puppet 
documentation... 

Thanks! 
John 


-- 
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 post to this group, send email to puppet-users@googlegroups.com. 
Visit this group at http://groups.google.com/group/puppet-users?hl=en . 
For more options, visit https://groups.google.com/groups/opt_out . 


-- 
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 post to this group, send email to puppet-users@googlegroups.com.
Visit this group at http://groups.google.com/group/puppet-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to