sous-chefs/logrotate

Global frequency

simo2409 opened this issue · 4 comments

Hi,
I'm trying to change the global frequency to "daily" with no luck.

I tried, following the readme, to do:

%w[ weekly monthly yearly ].each do |freq|
  node.override['logrotate']['global'][freq] = false
end
node.override['logrotate']['global']['daily'] = true

But /etc/logrotate.conf seems un-touched

I also tried to specify some logrotate_app and they work perfectly, thank you for your work!

Target is CentOs7 (if it helps)

@simo2409 Thanks for filing this issue. I'll try to take a look at it by the end of this week. Some quick thoughts: Where did you place that example code? Are you sure it is being processed before the logrotate::global recipe in the compile phase of the chef-client run?

I'm using chef to provision a CentOS 7 server on my local machine (running in vagrant) and starting from base (minimal) centos 7 image.

I tried two ways (both unsuccessful):

1 - I specified in host's json (nodes/127.0.0.1.json):

"logrotate": {
    "global": {
      "weekly": "false",
      "daily": "true"
    }
  },

It didn't work so

2 - I tried to put node.override into the cookbook I created called "logrotate" in which (in recipes/default.rb) I have:

%w[ weekly monthly yearly ].each do |freq|
  node.override['logrotate']['global'][freq] = false
end
node.override['logrotate']['global']['daily'] = true

# Some logrotate_app which work properly

I don't know if it's a bug or simply I didn't understand how it should work.
Thank you very much

"logrotate": {
    "global": {
      "weekly": "false",
      "daily": "true"
    }
  },

What if you try the barewords true and false rather than the strings "true" and "false"?

2 - I tried to put node.override into the cookbook I created called "logrotate" in which (in recipes/default.rb) I have:

Does that recipe call include_recipe "logrotate::global" or is logrotate::global in the node's run list?

That was the problem! I didn't call logrotate::global nor I called include_recipe "logrotate::global", now it works properly with the data in node's json (with true/false, not "true"/"false").

Thank you so much!

If it's useful I can send you a PR to include a note in readme about "logrotate::global", it would be helped me in this case