Ask Your Question

file resource loglevel

asked 2013-09-09 10:23:39 -0600

Andyh1983 gravatar image

updated 2013-09-12 00:58:09 -0600

golja gravatar image


I have been having a play with mcollective and have everything setup now and its working well in my test environment.

I took some of the tips from the puppet documentation whilst installing and setting up, specifically the population of the mcollective facts.yaml file using the below file resource:

      owner    => root,
      group    => root,
      mode     => 400,
      loglevel => debug, # reduce noise in Puppet reports
      content  => inline_template("<%= scope.to_hash.reject { |k,v| k.to_s =~ /(uptime_seconds|timestamp|free)/ }.to_yaml %>"), # exclude rapidly changing facts

This works as expected, however on each puppet run it shows up in the ... (more)

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2013-09-09 15:18:07 -0600

ramindk gravatar image

updated 2013-09-10 16:04:13 -0600

loglevel => debug will send the most logs to Puppet, not the least.

This isn't a problem with logging or the file resource, but a problem with the Puppetlabs documentation. The inline template you're using will not sort the facts consistently which causes the content of the file to change each time Puppet runs. You should replace the inline_template with the following erb template which sorts the data so it is consistent between Puppet runs.

file { '/etc/mcollective/facts.yaml':
  owner    => root,
  group    => root,
  mode     => 400,
  content  => template('mcollective/facts.yaml.erb'),


    # remove ...
edit flag offensive delete link more


Cheers for the responses guys, this solution seems to of done the trick for me.

Andyh1983 gravatar imageAndyh1983 ( 2013-09-10 03:24:32 -0600 )edit

minor fix sshfp.* rather than sshfp_* else it generates broken yaml

ramindk gravatar imageramindk ( 2013-09-10 16:05:46 -0600 )edit

answered 2013-09-09 15:03:25 -0600

GregLarkin gravatar image

Other folks have run into this problem, and there's some talk that the original author of the file resource relied on ordering emitted by a specific Ruby version or didn't worry about the reordering. I'm not finding any documentation that indicates loglevel => debug suppresses logging either, but I haven't looked too hard.

Has the file actually changed, even if just the ordering of the lines in it? In any case, you should be able to do one of the following:

  • Manage facts.yaml with some other means outside of Puppet
  • Add show_diff => false to the file ...
edit flag offensive delete link more


Unfortunately the linked solution doesn't work as well as advertised. It will keep the order consistent until the Puppet agent is restarted. At least that has been my experience ...(more)

ramindk gravatar imageramindk ( 2013-09-09 15:40:59 -0600 )edit

Thanks for the better solution, Ramindk.

GregLarkin gravatar imageGregLarkin ( 2013-09-09 16:05:33 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2013-09-09 10:23:39 -0600

Seen: 239 times

Last updated: Sep 10 '13