1 line
7.3 KiB
JSON
1 line
7.3 KiB
JSON
{"name":"logrotate","description":"Installs logrotate package and provides a definition for logrotate configs","long_description":"logrotate Cookbook\n==================\n[](http://travis-ci.org/stevendanna/logrotate)\n\nManages the logrotate package and provides a definition to manage application specific logrotate configuration.\n\n\nRequirements\n------------\nShould work on any platform that includes a 'logrotate' package and writes logrotate configuration to /etc/logrotate.d. Tested on Ubuntu, Debian and Red Hat/CentOS.\n\n\nRecipes\n-------\n### global\nGenerates and controls a global `/etc/logrotate.conf` file that will include additional files generated by the `logrotate_app` definition (see below). The contents of the configuration file is controlled through node attributes under `node['logrotate']['global']`. The default attributes are based on the configuration from the Ubuntu logrotate package.\n\nTo define a valueless directive (e.g. `compress`, `copy`) simply add an attribute named for the directive with a truthy value :\n\n```ruby\nnode['logrotate']['global']['compress'] = 'any value here'\n```\n\nNote that defining a valueless directive with a falsey value will not make it false, but will remove it:\n\n```ruby\n# Removes a defaulted 'compress' directive; does not add a 'nocompress' directive.\nnode.override['logrotate']['global']['compress'] = false\n```\n\nTo fully overrride a booleanish directive like `compress`, you should probably remove the positive form and add the negative form:\n\n```ruby\nnode.override['logrotate']['global']['compress'] = false\nnode.override['logrotate']['global']['nocompress'] = true\n```\n\nThe same is true of frequency directives; to be certain the frequency directive you want is included in the global configuration, you should override the ones you don't want as false:\n\n```ruby\n%w[ daily, weekly, yearly ].do |freq|\n node.override['logrotate']['global'][freq] = false\nend\nnode.override['logrotate']['global']['monthly'] = true\n```\n\nTo define a parameter with a value (e.g. `create`, `mail`) add an attribute with the desired value:\n\n```ruby\nnode['logrotate']['global']['create'] = '0644 root adm'\n```\n\nTo define a path stanza in the global configuration (generally unneeded because of the `logrotate_app` definition) just add an attribute with the path as the name and a hash containing directives and parameters as described above:\n\n```ruby\nnode['logrotate']['global']['/var/log/wtmp'] = {\n 'missingok' => true,\n 'monthly' => true,\n 'create' => '0660 root utmp',\n 'rotate' => 1\n}\n```\n\n`firstaction`, `prerotate`, `postrotate`, and `lastaction` scripts can be defined either as arrays of the lines to put in the script or multiline strings:\n\n```ruby\nnode['logrotate']['global']['/var/log/foo/*.log'] = {\n 'missingok' => true,\n 'monthly' => true,\n 'create' => '0660 root adm',\n 'rotate' => 1,\n 'prerotate' => ['service foo start_rotate', 'logger started foo service log rotation'],\n 'postrotate' => <<-EOF\n service foo end_rotate\n logger completed foo service log rotation\n EOF\n}\n```\n\n\nDefinitions\n-----------\n### logrotate_app\nThis definition can be used to drop off customized logrotate config files on a per application basis.\n\nThe definition takes the following params:\n\n- `path`: specifies a single path (string) or multiple paths (array) that should have logrotation stanzas created in the config file. No default, this must be specified.\n- `enable`: true/false, if true it will create the template in /etc/logrotate.d.\n- `frequency`: sets the frequency for rotation. Default value is 'weekly'. Valid values are: daily, weekly, monthly, yearly, see the logrotate man page for more information.\n- `dateformat`: specifies date extension with %Y, %m, %d, and %s. The default value is -%Y%m%d.\n- `size`: Log files are rotated when they grow bigger than size bytes.\n- `maxsize`: Log files are rotated when they grow bigger than size bytes even before the additionally specified time interval.\n- `su`: Rotate log files set under this user and group instead of using default user/group.\n- `template`: sets the template source, default is \"logrotate.erb\".\n- `template_mode`: the mode to create the logrotate template with (default \"0440\")\n- `template_owner`: the owner of the logrotate template (default \"root\")\n- `template_group`: the group of the logrotate template (default \"root\")\n- `cookbook`: select the template source from the specified cookbook. By default it will use the cookbook where the definition is used.\n- `create`: creation parameters for the logrotate \"create\" config, follows the form \"mode owner group\". This is an optional parameter, and is nil by default.\n- `postrotate`: lines to be executed after the log file is rotated\n- `prerotate`: lines to be executed before the log file is rotated\n- `sharedscripts`: if true, the sharedscripts options is specified which makes sure prescript and postscript commands are run only once (even if multiple files match the path)\n\n\nUsage\n-----\nThe default recipe will ensure logrotate is always up to date.\n\nTo create application specific logrotate configs, use the `logrotate_app` definition. For example, to rotate logs for a tomcat application named myapp that writes its log file to `/var/log/tomcat/myapp.log`:\n\n```ruby\nlogrotate_app 'tomcat-myapp' do\n cookbook 'logrotate'\n path '/var/log/tomcat/myapp.log'\n frequency 'daily'\n rotate 30\n create '644 root adm'\nend\n```\n\nTo rotate multiple logfile paths, specify the path as an array:\n\n```ruby\nlogrotate_app 'tomcat-myapp' do\n cookbook 'logrotate'\n path ['/var/log/tomcat/myapp.log', '/opt/local/tomcat/catalina.out']\n frequency 'daily'\n create '644 root adm'\n rotate 7\nend\n```\n\nTo specify which logrotate options, specify the options as an array:\n\n```ruby\nlogrotate_app 'tomcat-myapp' do\n cookbook 'logrotate'\n path '/var/log/tomcat/myapp.log'\n options ['missingok', 'delaycompress', 'notifempty']\n frequency 'daily'\n rotate 30\n create '644 root adm'\nend\n```\n\n\nLicense & Authors\n-----------------\n- Author:: Scott M. Likens (<scott@likens.us>)\n- Author:: Joshua Timberman (<joshua@opscode.com>)\n\n```text\nCopyright 2009, Scott M. Likens\nCopyright 2011-2012, Opscode, Inc.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n```\n","maintainer":"Opscode, Inc.","maintainer_email":"cookbooks@opscode.com","license":"Apache 2.0","platforms":{"amazon":">= 0.0.0","centos":">= 0.0.0","debian":">= 0.0.0","fedora":">= 0.0.0","redhat":">= 0.0.0","scientific":">= 0.0.0","ubuntu":">= 0.0.0"},"dependencies":{},"recommendations":{},"suggestions":{},"conflicting":{},"providing":{"logrotate_app":">= 0.0.0"},"replacing":{},"attributes":{},"groupings":{},"recipes":{"logrotate":"Installs logrotate package"},"version":"1.5.0"} |