Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

We have a server (managed by puppet) that generates a file once per day. Is there an approach I could use to make puppet do the following:

  • Recognize that the file is there on server A
  • Upload it to the puppet master
  • Ensure its existence on puppet-managed server B
  • Reload a service on server B

It's really the recognizing and uploading that I'm not clear on. I think I understand how to ensure the existence on server B and reload the service.

Any patterns or documentation would be helpful. Thanks.

share|improve this question
does it need to be on the master? – Mike Mar 18 '13 at 16:42

I'd have a look into exported resources.

You could define an additional resource using a custom fact as source for the file contents:

node servera {
    @@file { "/generated/file"
        ensure => present,
        content => $::myspecialfilecontent
        tag => myspecialfile,

and realise the resource on serverb:

node serverb {
    File <<| tag == 'myspecialfile' |>> {
        notify => Service["your_service"],

the custom puppet fact could look like follows (put it in a modules/.../lib/facter/myspecialfilecontent.rb file and enable pluginsync):

filename = '/generated/file'
Facter.add(:myspecialfilecontent) do
    setcode do
        if File.file?(filename)

you need storeconfigs = true (puppetdb) for that though.

This is not a very clean solution but it could work.

share|improve this answer

Let's assume that you have a common class or node (like the default) that applies to all the nodes managed by puppet.

Here you create the policy to manage the file created daily, but only a virtual resource.

node default {
  $fsufix = strftime("%y_%m_%d")
  @file { "everyday_file" :
    path => "/scratch/usern/file_${fsufix}",
    ensure => present,

Then for the serverA, you just need to check whether that file is present by realizing the virtual resource we just created earlier :

node 'serverA' inherits default {

After this you want serverB to do the same as serverA plus refresh a service if the file is created or modified :

node 'serverB' inherits default {
  service { "mysqld" :
    ensure => running,
    hasrestart => true,
    subscribe => File ["everyday_file"],
share|improve this answer
are you sure this will catch the content of the file? IMHO when you specify a file without source/content puppet just ensures the file is there but does not care about its content... – andrekeller Mar 19 '13 at 9:11
question of OP has nothing about the content of the file. In any case, since this file is being produced everyday, I believe the content might be different and may need some kind of template, but that's another question... – iamauser Mar 19 '13 at 12:59
as far as I understood it the file itself is generated by an application and not from within puppet... But of course I could be wrong... – andrekeller Mar 19 '13 at 13:33

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.