Update more cookbooks

This commit is contained in:
Greg Karékinian
2017-06-16 11:25:49 +02:00
parent 7da2c5a738
commit f5858319a7
129 changed files with 1095 additions and 101571 deletions

View File

@@ -1,3 +1,15 @@
*.rbc
.config
coverage
InstalledFiles
lib/bundler/man
pkg
rdoc
spec/reports
test/tmp
test/version_tmp
tmp
_Store
*~
*#
.#*
@@ -7,19 +19,33 @@
*.tmp
*.bk
*.bkup
.kitchen.local.yml
Berksfile.lock
.bundle/
.cache/
.kitchen/
.vagrant/
.vagrant.d/
bin/
tmp/
vendor/
# RVM
# ruby/bundler files
.ruby-version
.ruby-gemset
.rvmrc
.rvmrc
Gemfile.lock
.bundle
*.gem
# YARD artifacts
.yardoc
_yardoc
doc/
.idea
# chef stuff
Berksfile.lock
.kitchen
.kitchen.local.yml
vendor/
.coverage/
.zero-knife.rb
Policyfile.lock.json
Cheffile.lock
.librarian/
# vagrant stuff
.vagrant/
.vagrant.d/
.kitchen/

View File

@@ -1,12 +1,21 @@
driver_plugin: vagrant
driver_config:
require_chef_omnibus: true
driver:
name: vagrant
provisioner:
name: chef_zero
# We have tests that ensure our deprecated features still
# work so we can't turn this on globally.
# deprecations_as_errors: true
platforms:
- name: ubuntu-12.04
run_list:
- recipe[fake::prep]
- name: centos-6.7
- name: centos-6.8
- name: centos-7.3
# - name: debian-7.11
- name: debian-8.6
- name: fedora-25
- name: opensuse-leap-42.1
- name: ubuntu-14.04
- name: ubuntu-16.04
suites:
- name: default

View File

@@ -1,4 +0,0 @@
AllCops:
Exclude:
- vendor/**
- .kitchen/**

View File

@@ -1,10 +1,20 @@
# Use Travis's cointainer based infrastructure
sudo: false
addons:
apt:
sources:
- chef-stable-precise
packages:
- chefdk
branches:
only:
- master
language: ruby
cache: bundler
rvm:
- 2.2
# Ensure we make ChefDK's Ruby the default
install: echo "Using ChefDK for all dependencies"
before_script:
- eval "$(/opt/chefdk/bin/chef shell-init bash)"
script:
- make travis

View File

@@ -1,7 +1,7 @@
source "https://supermarket.getchef.com"
source 'https://supermarket.chef.io'
metadata
group :development do
cookbook "fake", path: "test/fixtures/cookbooks/fake"
cookbook 'fake', path: 'test/fixtures/cookbooks/fake'
end

View File

@@ -3,6 +3,34 @@ logrotate Cookbook CHANGELOG
This file is used to list changes made in each version of the
logrotate cookbook.
v2.2.0
------
# Compatibility Notes
The `compat_resource` dependency was removed. This means we now
require Chef 12.5 or higher. It also means we now better support Chef
13.
# Enhancements
- The global configuration now supports scripts.
- The package install action (upgrade by default) is now configurable
via an attribute.
- The development environment now more closely follows modern cookbook
practices.
# Bug Fixes
- ChefSpec matcher now correctly calls ChefSpec.define_matcher.
-
# Contributors
- Austin Heiman
- Baptiste Courtois
- Bogdan Katynski
- Thomas Dziedzic
- Tim Smith
v2.1.0
------

View File

@@ -16,7 +16,7 @@
### Requirements
- Ruby 2.0+
- Bundler (`gem install bundler`)
- Latest ChefDK
- [Vagrant](https://vagrantup.com)
- [VirtualBox](https://virtualbox.org)
@@ -24,15 +24,15 @@
1. Clone the git repository from GitHub:
$ git clone git@github.com:stevendanna/logrotate.git
git clone git@github.com:stevendanna/logrotate.git
2. Install the dependencies using bundler:
2. Ensure you have ChefDK installed:
$ bundle install
chef --version
3. Create a branch for your changes:
$ git checkout -b my_bug_fix
git checkout -b my_bug_fix
4. Make any changes

View File

@@ -1,11 +0,0 @@
source "https://rubygems.org"
gem "berkshelf", "~> 4.0"
gem "chefspec", "~> 4.0"
gem "foodcritic", "~> 6.0"
gem "chefstyle", github: "chef/chefstyle"
group :integration do
gem "test-kitchen", "~> 1.0"
gem "kitchen-vagrant", "~> 0.11"
end

View File

@@ -1,275 +0,0 @@
GIT
remote: git://github.com/chef/chefstyle.git
revision: cc37808b7849fdcf49f04011626143940f83fe92
specs:
chefstyle (0.3.1)
rubocop (= 0.39.0)
GEM
remote: https://rubygems.org/
specs:
addressable (2.4.0)
artifactory (2.3.2)
ast (2.2.0)
berkshelf (4.3.2)
addressable (~> 2.3, >= 2.3.4)
berkshelf-api-client (~> 2.0, >= 2.0.2)
buff-config (~> 1.0)
buff-extensions (~> 1.0)
buff-shell_out (~> 0.1)
celluloid (= 0.16.0)
celluloid-io (~> 0.16.1)
cleanroom (~> 1.0)
faraday (~> 0.9)
httpclient (~> 2.7)
minitar (~> 0.5, >= 0.5.4)
octokit (~> 4.0)
retryable (~> 2.0)
ridley (~> 4.5)
solve (~> 2.0)
thor (~> 0.19)
berkshelf-api-client (2.0.2)
faraday (~> 0.9.1)
httpclient (~> 2.7.0)
ridley (~> 4.5)
buff-config (1.0.1)
buff-extensions (~> 1.0)
varia_model (~> 0.4)
buff-extensions (1.0.0)
buff-ignore (1.1.1)
buff-ruby_engine (0.1.0)
buff-shell_out (0.2.0)
buff-ruby_engine (~> 0.1.0)
builder (3.2.2)
celluloid (0.16.0)
timers (~> 4.0.0)
celluloid-io (0.16.2)
celluloid (>= 0.16.0)
nio4r (>= 1.1.0)
chef (12.9.38)
bundler (>= 1.10)
chef-config (= 12.9.38)
chef-zero (~> 4.5)
diff-lcs (~> 1.2, >= 1.2.4)
erubis (~> 2.7)
ffi-yajl (~> 2.2)
highline (~> 1.6, >= 1.6.9)
mixlib-authentication (~> 1.4)
mixlib-cli (~> 1.4)
mixlib-log (~> 1.3)
mixlib-shellout (~> 2.0)
net-sftp (~> 2.1, >= 2.1.2)
net-ssh (>= 2.9, < 4.0)
net-ssh-multi (~> 1.1)
ohai (>= 8.6.0.alpha.1, < 9)
plist (~> 3.2)
proxifier (~> 1.0)
rspec-core (~> 3.4)
rspec-expectations (~> 3.4)
rspec-mocks (~> 3.4)
rspec_junit_formatter (~> 0.2.0)
serverspec (~> 2.7)
specinfra (~> 2.10)
syslog-logger (~> 1.6)
uuidtools (~> 2.1.5)
chef-config (12.9.38)
fuzzyurl (~> 0.8.0)
mixlib-config (~> 2.0)
mixlib-shellout (~> 2.0)
chef-zero (4.6.1)
ffi-yajl (~> 2.2)
hashie (>= 2.0, < 4.0)
mixlib-log (~> 1.3)
rack
uuidtools (~> 2.1)
chefspec (4.6.1)
chef (>= 11.14)
fauxhai (~> 3.2)
rspec (~> 3.0)
cleanroom (1.0.0)
cucumber-core (1.4.0)
gherkin (~> 3.2.0)
diff-lcs (1.2.5)
erubis (2.7.0)
faraday (0.9.2)
multipart-post (>= 1.2, < 3)
fauxhai (3.3.0)
net-ssh
ffi (1.9.10)
ffi-yajl (2.2.3)
libyajl2 (~> 1.2)
foodcritic (6.1.1)
cucumber-core (>= 1.3)
erubis
nokogiri (>= 1.5, < 2.0)
rake
rufus-lru (~> 1.0)
treetop (~> 1.4)
yajl-ruby (~> 1.1)
fuzzyurl (0.8.0)
gherkin (3.2.0)
hashie (3.4.3)
highline (1.7.8)
hitimes (1.2.3)
httpclient (2.7.1)
ipaddress (0.8.3)
json (1.8.3)
kitchen-vagrant (0.20.0)
test-kitchen (~> 1.4)
libyajl2 (1.2.0)
mini_portile2 (2.0.0)
minitar (0.5.4)
mixlib-authentication (1.4.0)
mixlib-log
rspec-core (~> 3.2)
rspec-expectations (~> 3.2)
rspec-mocks (~> 3.2)
mixlib-cli (1.5.0)
mixlib-config (2.2.1)
mixlib-install (1.0.7)
artifactory
mixlib-shellout
mixlib-versioning
mixlib-log (1.6.0)
mixlib-shellout (2.2.6)
mixlib-versioning (1.1.0)
molinillo (0.4.4)
multi_json (1.11.2)
multipart-post (2.0.0)
net-scp (1.2.1)
net-ssh (>= 2.6.5)
net-sftp (2.1.2)
net-ssh (>= 2.6.5)
net-ssh (3.1.1)
net-ssh-gateway (1.2.0)
net-ssh (>= 2.6.5)
net-ssh-multi (1.2.1)
net-ssh (>= 2.6.5)
net-ssh-gateway (>= 1.2.0)
net-telnet (0.1.1)
nio4r (1.2.1)
nokogiri (1.6.7.2)
mini_portile2 (~> 2.0.0.rc2)
octokit (4.3.0)
sawyer (~> 0.7.0, >= 0.5.3)
ohai (8.14.0)
chef-config (>= 12.5.0.alpha.1, < 13)
ffi (~> 1.9)
ffi-yajl (~> 2.2)
ipaddress
mixlib-cli
mixlib-config (~> 2.0)
mixlib-log
mixlib-shellout (~> 2.0)
plist (~> 3.1)
systemu (~> 2.6.4)
wmi-lite (~> 1.0)
parser (2.3.0.7)
ast (~> 2.2)
plist (3.2.0)
polyglot (0.3.5)
powerpack (0.1.1)
proxifier (1.0.3)
rack (1.6.4)
rainbow (2.1.0)
rake (11.1.2)
retryable (2.0.3)
ridley (4.5.0)
addressable
buff-config (~> 1.0)
buff-extensions (~> 1.0)
buff-ignore (~> 1.1)
buff-shell_out (~> 0.1)
celluloid (~> 0.16.0)
celluloid-io (~> 0.16.1)
chef-config (>= 12.5.0)
erubis
faraday (~> 0.9.0)
hashie (>= 2.0.2, < 4.0.0)
httpclient (~> 2.7)
json (>= 1.7.7)
mixlib-authentication (>= 1.3.0)
retryable (~> 2.0)
semverse (~> 1.1)
varia_model (~> 0.4.0)
rspec (3.4.0)
rspec-core (~> 3.4.0)
rspec-expectations (~> 3.4.0)
rspec-mocks (~> 3.4.0)
rspec-core (3.4.4)
rspec-support (~> 3.4.0)
rspec-expectations (3.4.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.4.0)
rspec-its (1.2.0)
rspec-core (>= 3.0.0)
rspec-expectations (>= 3.0.0)
rspec-mocks (3.4.1)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.4.0)
rspec-support (3.4.1)
rspec_junit_formatter (0.2.3)
builder (< 4)
rspec-core (>= 2, < 4, != 2.12.0)
rubocop (0.39.0)
parser (>= 2.3.0.7, < 3.0)
powerpack (~> 0.1)
rainbow (>= 1.99.1, < 3.0)
ruby-progressbar (~> 1.7)
unicode-display_width (~> 1.0, >= 1.0.1)
ruby-progressbar (1.7.5)
rufus-lru (1.0.5)
safe_yaml (1.0.4)
sawyer (0.7.0)
addressable (>= 2.3.5, < 2.5)
faraday (~> 0.8, < 0.10)
semverse (1.2.1)
serverspec (2.31.1)
multi_json
rspec (~> 3.0)
rspec-its
specinfra (~> 2.53)
sfl (2.2)
solve (2.0.3)
molinillo (~> 0.4.2)
semverse (~> 1.1)
specinfra (2.56.1)
net-scp
net-ssh (>= 2.7, < 4.0)
net-telnet
sfl
syslog-logger (1.6.8)
systemu (2.6.5)
test-kitchen (1.7.3)
mixlib-install (~> 1.0, >= 1.0.4)
mixlib-shellout (>= 1.2, < 3.0)
net-scp (~> 1.1)
net-ssh (>= 2.9, < 4.0)
safe_yaml (~> 1.0)
thor (~> 0.18)
thor (0.19.1)
timers (4.0.4)
hitimes
treetop (1.6.5)
polyglot (~> 0.3)
unicode-display_width (1.0.3)
uuidtools (2.1.5)
varia_model (0.4.1)
buff-extensions (~> 1.0)
hashie (>= 2.0.2, < 4.0.0)
wmi-lite (1.0.0)
yajl-ruby (1.2.1)
PLATFORMS
ruby
DEPENDENCIES
berkshelf (~> 4.0)
chefspec (~> 4.0)
chefstyle!
foodcritic (~> 6.0)
kitchen-vagrant (~> 0.11)
test-kitchen (~> 1.0)
BUNDLED WITH
1.11.2

View File

@@ -1,13 +1,11 @@
travis: bundle berks
bundle exec chefstyle -D
bundle exec foodcritic .
bundle exec rspec --color --format doc
all: delivery
integration: bundle berks
bundle exec kitchen test
travis: debug_version_info all
bundle:
bundle install
debug_version_info:
/opt/chefdk/embedded/bin/chef --version
/opt/chefdk/embedded/bin/cookstyle --version
/opt/chefdk/embedded/bin/foodcritic --version
berks:
bundle exec berks install
delivery:
/opt/chefdk/bin/chef exec delivery local all

View File

@@ -6,11 +6,22 @@ application specific logrotate configuration.
## Requirements
### Platforms
Should work on any platform that includes a 'logrotate' package and
writes logrotate configuration to /etc/logrotate.d. Tested on Ubuntu
and Centos.
### Chef
- Chef 12.5+
### Cookbooks
- none
## Recipes
### global
@@ -118,7 +129,7 @@ The resource takes the following properties:
"logrotate.erb".
- `template_mode`: the mode to create the logrotate template with
(default: "0440")
(default: "0644")
- `template_owner`: the owner of the logrotate template (default:
"root")

View File

@@ -1,10 +1,10 @@
#
# Cookbook Name:: logrotate
# Cookbook:: logrotate
# Attribute:: default
#
# Copyright 2013, Chef Software, Inc
# Copyright 2015-2016, Steven Danna
# Copyright 2016, Bloomberg Finance L.P.
# Copyright:: 2013-2017, Chef Software, Inc
# Copyright:: 2015-2017, Steven Danna
# Copyright:: 2016-2017, Bloomberg Finance L.P.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -19,36 +19,37 @@
# limitations under the License.
#
default["logrotate"]["package"] = {
"name" => "logrotate",
"source" => nil,
"version" => nil,
"provider" => nil,
default['logrotate']['package'] = {
'name' => 'logrotate',
'source' => nil,
'version' => nil,
'provider' => nil,
'action' => :upgrade,
}
default["logrotate"]["directory"] = "/etc/logrotate.d"
default["logrotate"]["cron"]["install"] = platform?("solaris2") || platform?("aix")
default["logrotate"]["cron"]["name"] = "logrotate"
default["logrotate"]["cron"]["command"] = "/usr/sbin/logrotate /etc/logrotate.conf"
default["logrotate"]["cron"]["minute"] = 35
default["logrotate"]["cron"]["hour"] = 2
default['logrotate']['directory'] = '/etc/logrotate.d'
default['logrotate']['cron']['install'] = platform?('solaris2') || platform?('aix')
default['logrotate']['cron']['name'] = 'logrotate'
default['logrotate']['cron']['command'] = '/usr/sbin/logrotate /etc/logrotate.conf'
default['logrotate']['cron']['minute'] = 35
default['logrotate']['cron']['hour'] = 2
default["logrotate"]["global"] = {
"weekly" => true,
"rotate" => 4,
"create" => "",
default['logrotate']['global'] = {
'weekly' => true,
'rotate' => 4,
'create' => '',
"/var/log/wtmp" => {
"missingok" => true,
"monthly" => true,
"create" => "0664 root utmp",
"rotate" => 1,
'/var/log/wtmp' => {
'missingok' => true,
'monthly' => true,
'create' => '0664 root utmp',
'rotate' => 1,
},
"/var/log/btmp" => {
"missingok" => true,
"monthly" => true,
"create" => "0660 root utmp",
"rotate" => 1,
'/var/log/btmp' => {
'missingok' => true,
'monthly' => true,
'create' => '0660 root utmp',
'rotate' => 1,
},
}

View File

@@ -0,0 +1,102 @@
# Put files/directories that should be ignored in this file when uploading
# to a chef-server or supermarket.
# Lines that start with '# ' are comments.
# OS generated files #
######################
.DS_Store
Icon?
nohup.out
ehthumbs.db
Thumbs.db
# SASS #
########
.sass-cache
# EDITORS #
###########
\#*
.#*
*~
*.sw[a-z]
*.bak
REVISION
TAGS*
tmtags
*_flymake.*
*_flymake
*.tmproj
.project
.settings
mkmf.log
## COMPILED ##
##############
a.out
*.o
*.pyc
*.so
*.com
*.class
*.dll
*.exe
*/rdoc/
# Testing #
###########
.watchr
.rspec
spec/*
spec/fixtures/*
test/*
features/*
examples/*
Guardfile
Procfile
.kitchen*
.rubocop.yml
spec/*
Rakefile
.travis.yml
.foodcritic
.codeclimate.yml
# SCM #
#######
.git
*/.git
.gitignore
.gitmodules
.gitconfig
.gitattributes
.svn
*/.bzr/*
*/.hg/*
*/.svn/*
# Berkshelf #
#############
Berksfile
Berksfile.lock
cookbooks/*
tmp
# Cookbooks #
#############
CONTRIBUTING*
CHANGELOG*
TESTING*
MAINTAINERS.toml
# Strainer #
############
Colanderfile
Strainerfile
.colander
.strainer
# Vagrant #
###########
.vagrant
Vagrantfile

View File

@@ -1,8 +1,8 @@
#
# Cookbook Name:: logrotate
# Cookbook:: logrotate
# Library:: CookbookLogrotate
#
# Copyright 2013, Chef
# Copyright:: 2013-2017, Chef
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -19,24 +19,24 @@
# Helper module for Logrotate configuration module CookbookLogrotate
module CookbookLogrotate
DIRECTIVES = %w{compress copy copytruncate daily dateext
dateyesterday delaycompress hourly ifempty mailfirst maillast
missingok monthly nocompress nocopy nocopytruncate nocreate nocreateolddir
nodelaycompress nodateext nomail nomissingok noolddir
nosharedscripts noshred notifempty renamecopy sharedscripts shred weekly
yearly} unless const_defined?(:DIRECTIVES)
DIRECTIVES = %w(compress copy copytruncate daily dateext
dateyesterday delaycompress hourly ifempty mailfirst maillast
missingok monthly nocompress nocopy nocopytruncate nocreate nocreateolddir
nodelaycompress nodateext nomail nomissingok noolddir
nosharedscripts noshred notifempty renamecopy sharedscripts shred weekly
yearly).freeze unless const_defined?(:DIRECTIVES)
VALUES = %w{compresscmd uncompresscmd compressext compressoptions
create createolddir dateformat include mail extension maxage minsize maxsize
rotate size shredcycles start tabooext su olddir} unless const_defined?(:VALUES)
VALUES = %w(compresscmd uncompresscmd compressext compressoptions
create createolddir dateformat include mail extension maxage minsize maxsize
rotate size shredcycles start tabooext su olddir).freeze unless const_defined?(:VALUES)
SCRIPTS = %w{firstaction prerotate postrotate lastaction preremove} unless const_defined?(:SCRIPTS)
SCRIPTS = %w(firstaction prerotate postrotate lastaction preremove).freeze unless const_defined?(:SCRIPTS)
DIRECTIVES_AND_VALUES = DIRECTIVES + VALUES unless const_defined?(:DIRECTIVES_AND_VALUES)
DIRECTIVES_AND_VALUES_AND_SCRIPTS = DIRECTIVES + VALUES + SCRIPTS unless const_defined?(:DIRECTIVES_AND_VALUES_AND_SCRIPTS)
# Helper class for creating configurations
class LogrotateConfiguration
attr_reader :directives, :values, :paths
attr_reader :directives, :values, :scripts, :paths
class << self
def from_hash(hash)
@@ -52,27 +52,23 @@ module CookbookLogrotate
end
def paths_from(hash)
hash.select { |k| !(DIRECTIVES_AND_VALUES.include?(k)) }.reduce({}) do |accum_paths, (path, config)|
hash.select { |k| !DIRECTIVES_AND_VALUES_AND_SCRIPTS.include?(k) }.each_with_object({}) do |(path, config), accum_paths|
accum_paths[path] = {
"directives" => directives_from(config),
"values" => values_from(config),
"scripts" => scripts_from(config),
'directives' => directives_from(config),
'values' => values_from(config),
'scripts' => scripts_from(config),
}
accum_paths
end
end
def scripts_from(hash)
defined_scripts = hash.select { |k| SCRIPTS.include?(k) }
defined_scripts.reduce({}) do |accum_scripts, (script, lines)|
if lines.respond_to?(:join)
accum_scripts[script] = lines.join("\n")
else
accum_scripts[script] = lines
end
accum_scripts
defined_scripts.each_with_object({}) do |(script, lines), accum_scripts|
accum_scripts[script] = if lines.respond_to?(:join)
lines.join("\n")
else
lines
end
end
end
end
@@ -82,6 +78,7 @@ module CookbookLogrotate
def initialize(hash)
@directives = LogrotateConfiguration.directives_from(hash)
@values = LogrotateConfiguration.values_from(hash)
@scripts = LogrotateConfiguration.scripts_from(hash)
@paths = LogrotateConfiguration.paths_from(hash)
end
end

View File

@@ -1,4 +1,6 @@
if defined?(ChefSpec)
ChefSpec.define_matcher :logrotate_app
def enable_logrotate_app(resource)
ChefSpec::Matchers::ResourceMatcher.new(:logrotate_app, :enable, resource)
end

View File

@@ -16,7 +16,7 @@
"ubuntu": ">= 0.0.0"
},
"dependencies": {
"compat_resource": ">= 0.0.0"
},
"recommendations": {
@@ -42,12 +42,14 @@
"recipes": {
"logrotate": "Installs logrotate package"
},
"version": "2.1.0",
"version": "2.2.0",
"source_url": "https://github.com/stevendanna/logrotate",
"issues_url": "https://github.com/stevendanna/logrotate/issues",
"privacy": false,
"chef_versions": [
[
">= 12.5"
]
],
"ohai_versions": [

View File

@@ -1,19 +1,18 @@
name "logrotate"
maintainer "Steven Danna"
maintainer_email "steve@chef.io"
license "Apache 2.0"
description "Installs logrotate package and provides a definition for logrotate configs"
long_description "Installs the logrotate package, manages /etc/logrotate.conf, and provides a logrotate_app definition."
version "2.1.0"
name 'logrotate'
maintainer 'Steven Danna'
maintainer_email 'steve@chef.io'
license 'Apache 2.0'
description 'Installs logrotate package and provides a definition for logrotate configs'
long_description 'Installs the logrotate package, manages /etc/logrotate.conf, and provides a logrotate_app definition.'
version '2.2.0'
source_url "https://github.com/stevendanna/logrotate" if respond_to?(:source_url)
issues_url "https://github.com/stevendanna/logrotate/issues" if respond_to?(:issues_url)
recipe 'logrotate', 'Installs logrotate package'
provides 'logrotate_app'
recipe "logrotate", "Installs logrotate package"
provides "logrotate_app"
depends "compat_resource"
%w{amazon centos debian fedora redhat scientific solaris2 ubuntu}.each do |platform|
%w(amazon centos debian fedora redhat scientific solaris2 ubuntu).each do |platform|
supports platform
end
source_url 'https://github.com/stevendanna/logrotate'
issues_url 'https://github.com/stevendanna/logrotate/issues'
chef_version '>= 12.5' if respond_to?(:chef_version)

View File

@@ -1,10 +1,10 @@
#
# Cookbook Name:: logrotate
# Cookbook:: logrotate
# Recipe:: default
#
# Copyright 2009-2013, Chef Software, Inc.
# Copyright 2015-2016, Steven Danna
# Copyright 2016, Bloomberg Finance L.P.
# Copyright:: 2009-2017, Chef Software, Inc.
# Copyright:: 2015-2017, Steven Danna
# Copyright:: 2016-2017, Bloomberg Finance L.P.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -18,25 +18,25 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
return if platform?("windows")
return if platform?('windows')
package node["logrotate"]["package"]["name"] do
provider node["logrotate"]["package"]["provider"] if node["logrotate"]["package"]["provider"]
source node["logrotate"]["package"]["source"] if node["logrotate"]["package"]["source"]
version node["logrotate"]["package"]["version"] if node["logrotate"]["package"]["version"]
action :upgrade
package node['logrotate']['package']['name'] do
provider node['logrotate']['package']['provider'] if node['logrotate']['package']['provider']
source node['logrotate']['package']['source'] if node['logrotate']['package']['source']
version node['logrotate']['package']['version'] if node['logrotate']['package']['version']
action node['logrotate']['package']['action']
end
directory node["logrotate"]["directory"] do
owner "root"
group node["root_group"]
mode "0755"
directory node['logrotate']['directory'] do
owner 'root'
group node['root_group']
mode '0755'
end
if node["logrotate"]["cron"]["install"] # ~FC023
cron node["logrotate"]["cron"]["name"] do
minute node["logrotate"]["cron"]["minute"]
hour node["logrotate"]["cron"]["hour"]
command node["logrotate"]["cron"]["command"]
if node['logrotate']['cron']['install'] # ~FC023
cron node['logrotate']['cron']['name'] do
minute node['logrotate']['cron']['minute']
hour node['logrotate']['cron']['hour']
command node['logrotate']['cron']['command']
end
end

View File

@@ -1,8 +1,8 @@
#
# Cookbook Name:: logrotate
# Cookbook:: logrotate
# Recipe:: default
#
# Copyright 2009-2013, Chef Software, Inc.
# Copyright:: 2009-2017, Chef Software, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -17,14 +17,14 @@
# limitations under the License.
#
include_recipe "logrotate::default"
include_recipe 'logrotate::default'
parsed_configuration = CookbookLogrotate::LogrotateConfiguration.from_hash(node["logrotate"]["global"].to_hash)
parsed_configuration = CookbookLogrotate::LogrotateConfiguration.from_hash(node['logrotate']['global'].to_hash)
template "/etc/logrotate.conf" do
source "logrotate-global.erb"
mode "0644"
template '/etc/logrotate.conf' do
source 'logrotate-global.erb'
mode '0644'
variables(
:configuration => parsed_configuration
configuration: parsed_configuration
)
end

View File

@@ -1,5 +1,5 @@
#
# Copyright 2016, Steven Danna
# Copyright:: 2016-2017, Steven Danna
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -17,20 +17,20 @@
resource_name :logrotate_app
property :path, [String, Array], required: true
property :frequency, String, default: "weekly"
property :cookbook, default: "logrotate"
property :template_name, default: "logrotate.erb"
property :template_mode, default: "0644"
property :template_owner, default: "root"
property :template_group, default: "root"
property :base_dir, String, default: "/etc/logrotate.d"
property :frequency, String, default: 'weekly'
property :cookbook, default: 'logrotate'
property :template_name, default: 'logrotate.erb'
property :template_mode, default: '0644'
property :template_owner, default: 'root'
property :template_group, default: 'root'
property :base_dir, String, default: '/etc/logrotate.d'
property :options, [Array, String], default: %w{missingok compress delaycompress copytruncate notifempty}
property :options, [Array, String], default: %w(missingok compress delaycompress copytruncate notifempty)
default_action :enable
CookbookLogrotate::SCRIPTS.each do |script_name|
property script_name.to_sym, coerce: Proc.new { |val| Array(val).join("\n") }
property script_name.to_sym, coerce: proc { |val| Array(val).join("\n") }
end
CookbookLogrotate::VALUES.each do |configurable_name|
@@ -42,15 +42,15 @@ property :sharedscripts, [TrueClass, FalseClass], default: false
property :enable, [TrueClass, FalseClass], default: true
action :enable do
if !new_resource.enable
Chef::Log.deprecation "Use `action :disable` rather than `enable false` in the logrotate_app resource"
unless new_resource.enable
Chef::Log.deprecation 'Use `action :disable` rather than `enable false` in the logrotate_app resource'
action_disable
return true
end
logrotate_config = {
# The path should be a space separated list of quoted filesystem paths
path: Array(new_resource.path).map { |path| path.to_s.inspect }.join(" "),
path: Array(new_resource.path).map { |path| path.to_s.inspect }.join(' '),
frequency: new_resource.frequency,
directives: handle_options(new_resource),
scripts: handle_scripts(new_resource),
@@ -58,9 +58,9 @@ action :enable do
}
directory new_resource.base_dir do
owner "root"
group node["root_group"]
mode "0755"
owner 'root'
group node['root_group']
mode '0755'
action :create
end
@@ -84,7 +84,7 @@ end
def handle_configurables(new_resource)
configurables = {}
CookbookLogrotate::VALUES.each do |opt_name|
if value = new_resource.send(opt_name.to_sym)
if value = new_resource.send(opt_name.to_sym) # rubocop: disable Lint/AssignmentInCondition
configurables[opt_name] = value
end
end
@@ -94,7 +94,7 @@ end
def handle_scripts(new_resource)
scripts = {}
CookbookLogrotate::SCRIPTS.each do |script_name|
if script_body = new_resource.send(script_name.to_sym)
if script_body = new_resource.send(script_name.to_sym) # rubocop: disable Lint/AssignmentInCondition
scripts[script_name] = script_body
end
end
@@ -109,8 +109,8 @@ def handle_options(new_resource)
end
if new_resource.sharedscripts
Chef::Log.deprecation("The sharedscripts resource property is deprecated. Use the options property instead to set this value")
opts << "sharedscripts"
Chef::Log.deprecation('The sharedscripts resource property is deprecated. Use the options property instead to set this value')
opts << 'sharedscripts'
end
opts
end

View File

@@ -9,6 +9,12 @@
<%= k %> <%= v %>
<% end -%>
<% @configuration.scripts.each do | scripttype, body | -%>
<%= scripttype %>
<%= body %>
endscript
<% end -%>
include /etc/logrotate.d
<% @configuration.paths.each do |path, path_config| -%>