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,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