Oops I guess that'll teach me for trying to use a shortcut for posting. On Nov 8, 11:57 am, "Matthew Black" <mjbl...@gmail.com> wrote: > I am still new to the ruby language and I figured I'd share my file_exists > function to see if it is the correct approach and to offer it out there for > people who may have the same issue. We build our vhosts based off a template > and have come across the need to add in items for specific customers in > their vhost. The problem is if you file() and the file does not exist puppet > throws an error and does not continue to run that manifest. The solution was > to add in a file_exists function to allow us to bypass that issue. > > require 'puppet' > > module Puppet::Parser::Functions > newfunction(:file_exists, :type => :rvalue) do |args| > if File.exists?(args[0]) > return 1 > else > return 0 > end > end > end > > define customer::vhost($env, $url = "", $aliases = "") { > if file_exists("customers/$name/$env/web/httpd.conf") == 1 { > $extra = file("customers/$name/$env/web/httpd.conf") > } > file { "$name.conf": > path => "/etc/httpd/conf.d/$name.conf", > owner => root, > group => root, > mode => 644, > require => Package["httpd"], > content => template("customers/cust-vhost.erb"), > } > > > > }- Hide quoted text - > > - Show quoted text -
-- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-us...@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.