Ask Your Question
1

file resource loglevel

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

Andyh1983 gravatar image

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

golja gravatar image

Hiya,

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:

file{"/etc/mcollective/facts.yaml":
      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
1

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

ramindk gravatar image

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

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'),
}

modules/mcollective/templates/facts.yaml.erb

<%=
    # remove ...
(more)
edit flag offensive delete link more

Comments

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

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

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

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

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

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 ...
(more)
edit flag offensive delete link more

Comments

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 -0500 )edit

Thanks for the better solution, Ramindk.

GregLarkin gravatar imageGregLarkin ( 2013-09-09 16:05:33 -0500 )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

Stats

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

Seen: 168 times

Last updated: Sep 10 '13