Andreas Dvorak
2014-Oct-17 13:05 UTC
[Puppet Users] resource file with option source or content depending if source does exist
Dear all, I would like to use the file resource to supply a host specific file. If it does exist choose it and if not create a file from a template. I tried this, but then /mnt/motd needs to be on all server. $a = file("/mnt/motd/motd-${::hostname}",'/dev/null') if($a != '') { file {$config_file: ensure => 'file', owner => 'root', group => 'root', mode => '0644', source => "puppet:///motd_files/motd/motd-${::hostname}", } } else { file { $config_file: ensure => 'file', owner => 'root', group => 'root', mode => '0644', content => template($template), } } If I try this $a = file("puppet:///motd_files/motd/motd-${::hostname}",'/dev/null') I get the error that Files must be fully qualified Does anybody has a solution for that? Best regards Andreas -- 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+unsubscribe@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/bb44ef68-dcda-4c35-9e47-58008e88480a%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.