This repository has been archived by the owner on Jun 13, 2019. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bumping papertrail cookbook to reflect PR to upstream
- Loading branch information
fh
committed
Mar 22, 2016
1 parent
753b84d
commit 581c1ff
Showing
15 changed files
with
246 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
inherit_from: .rubocop_todo.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
# This configuration was generated by | ||
# `rubocop --auto-gen-config` | ||
# on 2016-03-21 16:30:19 +0100 using RuboCop version 0.38.0. | ||
# The point is for the user to remove these configuration records | ||
# one by one as the offenses are removed from the code base. | ||
# Note that changes in the inspected code, or installation of new | ||
# versions of RuboCop, may require this file to be generated again. | ||
|
||
# Offense count: 1 | ||
# Cop supports --auto-correct. | ||
Lint/DeprecatedClassMethods: | ||
Exclude: | ||
- 'recipes/default.rb' | ||
|
||
# Offense count: 10 | ||
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes. | ||
# URISchemes: http, https | ||
Metrics/LineLength: | ||
Max: 132 | ||
|
||
# Offense count: 2 | ||
# Cop supports --auto-correct. | ||
# Configuration parameters: EnforcedStyle, SupportedStyles. | ||
# SupportedStyles: braces, no_braces, context_dependent | ||
Style/BracesAroundHashParameters: | ||
Exclude: | ||
- 'recipes/default.rb' | ||
|
||
# Offense count: 1 | ||
# Cop supports --auto-correct. | ||
# Configuration parameters: EnforcedStyle, SupportedStyles, AllowInnerBackticks. | ||
# SupportedStyles: backticks, percent_x, mixed | ||
Style/CommandLiteral: | ||
Exclude: | ||
- 'recipes/default.rb' | ||
|
||
# Offense count: 1 | ||
# Cop supports --auto-correct. | ||
# Configuration parameters: SingleLineConditionsOnly. | ||
Style/ConditionalAssignment: | ||
Exclude: | ||
- 'recipes/default.rb' | ||
|
||
# Offense count: 2 | ||
# Cop supports --auto-correct. | ||
# Configuration parameters: AllowForAlignment, ForceEqualSignAlignment. | ||
Style/ExtraSpacing: | ||
Exclude: | ||
- 'metadata.rb' | ||
- 'recipes/default.rb' | ||
|
||
# Offense count: 11 | ||
# Cop supports --auto-correct. | ||
# Configuration parameters: EnforcedStyle, SupportedStyles, UseHashRocketsWithSymbolValues. | ||
# SupportedStyles: ruby19, ruby19_no_mixed_keys, hash_rockets | ||
Style/HashSyntax: | ||
Enabled: false | ||
|
||
# Offense count: 1 | ||
# Cop supports --auto-correct. | ||
Style/NumericLiterals: | ||
MinDigits: 7 | ||
|
||
# Offense count: 2 | ||
# Cop supports --auto-correct. | ||
# Configuration parameters: PreferredDelimiters. | ||
Style/PercentLiteralDelimiters: | ||
Exclude: | ||
- 'metadata.rb' | ||
- 'recipes/default.rb' | ||
|
||
# Offense count: 1 | ||
# Cop supports --auto-correct. | ||
Style/SpaceAfterComma: | ||
Exclude: | ||
- 'recipes/default.rb' | ||
|
||
# Offense count: 2 | ||
# Cop supports --auto-correct. | ||
# Configuration parameters: AllowForAlignment. | ||
Style/SpaceBeforeFirstArg: | ||
Exclude: | ||
- 'metadata.rb' | ||
- 'recipes/default.rb' | ||
|
||
# Offense count: 2 | ||
# Cop supports --auto-correct. | ||
# Configuration parameters: EnforcedStyle, SupportedStyles, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters. | ||
# SupportedStyles: space, no_space | ||
Style/SpaceInsideBlockBraces: | ||
Enabled: false | ||
|
||
# Offense count: 4 | ||
# Cop supports --auto-correct. | ||
# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SupportedStyles. | ||
# SupportedStyles: space, no_space | ||
Style/SpaceInsideHashLiteralBraces: | ||
Enabled: false | ||
|
||
# Offense count: 39 | ||
# Cop supports --auto-correct. | ||
# Configuration parameters: EnforcedStyle, SupportedStyles, ConsistentQuotesInMultiline. | ||
# SupportedStyles: single_quotes, double_quotes | ||
Style/StringLiterals: | ||
Enabled: false | ||
|
||
# Offense count: 1 | ||
Style/ZeroLengthPredicate: | ||
Exclude: | ||
- 'recipes/default.rb' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
language: ruby | ||
rvm: | ||
- 2.2.4 | ||
script: | ||
- bundle exec rake --trace |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/usr/bin/env ruby | ||
# ^syntax detection | ||
|
||
source "https://supermarket.chef.io" | ||
|
||
metadata | ||
|
||
cookbook 'rsyslog' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
DEPENDENCIES | ||
papertrail | ||
path: . | ||
metadata: true | ||
rsyslog | ||
|
||
GRAPH | ||
compat_resource (12.9.0) | ||
papertrail (0.0.7) | ||
rsyslog (>= 0.0.0) | ||
rsyslog (4.0.0) | ||
compat_resource (>= 0.0.0) |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,12 @@ | ||
source "http://rubygems.org" | ||
|
||
gem 'chefspec', git: 'git://github.com/acrmp/chefspec.git' | ||
gem 'librarian-chef' | ||
group :style do | ||
gem 'foodcritic' | ||
gem 'rubocop' | ||
gem 'rubocop-rspec' | ||
end | ||
|
||
group :unit do | ||
gem 'chefspec', '~> 4' | ||
gem 'berkshelf' | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
require 'rspec/core/rake_task' | ||
require 'rubocop/rake_task' | ||
require 'foodcritic' | ||
|
||
namespace :style do | ||
desc 'Run Ruby style checks' | ||
RuboCop::RakeTask.new(:ruby) | ||
|
||
desc 'Run Chef style checks' | ||
FoodCritic::Rake::LintTask.new(:chef) do |t| | ||
t.options = { | ||
fail_tags: ['any'], | ||
tags: ['~FC064', '~FC065'] # FC064 and FC065 breakcookbooks with chef11 | ||
} | ||
end | ||
end | ||
|
||
desc 'Run all style checks' | ||
task style: ['style:chef', 'style:ruby'] | ||
|
||
# Rspec and ChefSpec | ||
desc "Run ChefSpec examples" | ||
RSpec::Core::RakeTask.new(:spec) | ||
|
||
task default: %w(style spec) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,70 @@ | ||
require 'spec_helper' | ||
|
||
describe 'papertrail-cookbook::default' do | ||
describe 'papertrail::default' do | ||
let(:runner) { ChefSpec::SoloRunner.new } | ||
let(:chef_run) { runner.converge(described_recipe) } | ||
let(:node) { runner.node } | ||
let(:default_configfile) { '/etc/rsyslog.d/65-papertrail.conf' } | ||
let(:watchfiles_configfile) { '/etc/rsyslog.d/60-watch-files.conf' } | ||
let(:fixhost_configfile) { '/etc/rsyslog.d/61-fixhostnames.conf' } | ||
|
||
it 'require rsyslog' do | ||
expect(runner.converge('papertrail-cookbook::default')).to include_recipe 'rsyslog' | ||
expect(chef_run).to include_recipe 'rsyslog' | ||
end | ||
|
||
it 'uses the basename of the filename as the suffix for state file name' do | ||
chef_run = runner('test', { | ||
papertrail: { | ||
watch_files: { | ||
'test/file/name.jpg' => 'test_file' | ||
} | ||
} | ||
}).converge('papertrail-cookbook::default') | ||
|
||
expect(chef_run).to create_file_with_content '/etc/rsyslog.d/60-watch-files.conf', '$InputFileName test/file/name.jpg' | ||
expect(chef_run).to create_file_with_content '/etc/rsyslog.d/60-watch-files.conf', '$InputFileTag test_file' | ||
expect(chef_run).to create_file_with_content '/etc/rsyslog.d/60-watch-files.conf', '$InputFileStateFile state_file_name_test_file' | ||
it 'uses attributes to generate configuration' do | ||
expect(chef_run).to render_file(default_configfile) | ||
.with_content('$ActionResumeRetryCount -1') | ||
expect(chef_run).to render_file(default_configfile) | ||
.with_content('$ActionQueueMaxDiskSpace 100M') | ||
expect(chef_run).to render_file(default_configfile) | ||
.with_content('$ActionQueueSize 100000') | ||
expect(chef_run).to render_file(default_configfile) | ||
.with_content('$ActionQueueFileName papertrailqueue') | ||
end | ||
|
||
it 'uses attributes to generate configuration' do | ||
chef_run = runner.converge('papertrail-cookbook::default') | ||
expect(chef_run).to create_file_with_content '/etc/rsyslog.d/65-papertrail.conf', '$ActionResumeRetryCount -1' | ||
expect(chef_run).to create_file_with_content '/etc/rsyslog.d/65-papertrail.conf', '$ActionQueueMaxDiskSpace 100M' | ||
expect(chef_run).to create_file_with_content '/etc/rsyslog.d/65-papertrail.conf', '$ActionQueueSize 100000' | ||
expect(chef_run).to create_file_with_content '/etc/rsyslog.d/65-papertrail.conf', '$ActionQueueFileName /var/log/rsyslog_queue_main' | ||
it 'does not create watch files conf' do | ||
expect(chef_run).not_to render_file(watchfiles_configfile) | ||
end | ||
|
||
it 'does not create fix hostnames conf' do | ||
expect(chef_run).not_to render_file(fixhost_configfile) | ||
end | ||
|
||
it 'does not add the fixhostname cmd to the log target' do | ||
expect(chef_run).not_to render_file(default_configfile) | ||
.with_content(';FixHostname') | ||
end | ||
|
||
describe 'with watchfiles added' do | ||
before do | ||
node.set['papertrail']['watch_files'] = { 'test/file/name.jpg' => 'test_file' } | ||
end | ||
|
||
it 'uses the basename of the filename as the suffix for state file name' do | ||
expect(chef_run).to render_file(watchfiles_configfile) | ||
.with_content('$InputFileName test/file/name.jpg') | ||
expect(chef_run).to render_file(watchfiles_configfile) | ||
.with_content('$InputFileTag test_file') | ||
expect(chef_run).to render_file(watchfiles_configfile) | ||
.with_content('$InputFileStateFile state_file_name_test_file') | ||
end | ||
end | ||
|
||
describe 'with hostname set' do | ||
before do | ||
# no good idea how to mock something to test hostname_cmd.. :/ | ||
node.set['papertrail']['hostname_name'] = 'some.host.tld' | ||
end | ||
|
||
it 'creates the fix host template' do | ||
expect(chef_run).to render_file(fixhost_configfile) | ||
.with_content('FixHostname,"<%pri%>%timestamp% some.host.tld %syslogtag%') | ||
end | ||
|
||
it 'sets the fix host template in papertrail conf' do | ||
expect(chef_run).to render_file(default_configfile) | ||
.with_content(';FixHostname') | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,8 @@ | ||
require 'chefspec' | ||
require 'chefspec/berkshelf' | ||
|
||
Dir['./spec/support/**/*.rb'].sort.each {|f| require f} | ||
|
||
def runner(environment = 'test', attributes = {}) | ||
cookbook_paths = %W(#{File.expand_path('..', Dir.pwd)} #{File.expand_path(Dir.pwd)}/cookbooks) | ||
|
||
# A workaround so that ChefSpec can work with Chef environments (from https://github.com/acrmp/chefspec/issues/54) | ||
@runner ||= ChefSpec::ChefRunner.new(cookbook_path: cookbook_paths, platform: 'ubuntu', version: '10.04') do |node| | ||
env = Chef::Environment.new | ||
env.name environment | ||
node.stub(:chef_environment).and_return env.name | ||
Chef::Environment.stub!(:load).and_return env | ||
|
||
attributes.each_pair do |key, val| | ||
node.set[key] = val | ||
end | ||
end | ||
RSpec.configure do |c| | ||
c.platform = 'ubuntu' | ||
c.version = '12.04' | ||
# c.log_level = :debug | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
# A template that renames our hostname | ||
# See http://www.rsyslog.com/doc/v8-stable/configuration/property_replacer.html for the msg replace templates | ||
$template FixHostname,"<%pri%> %timestamp% <%= @name %> %syslogtag%%msg:::sp-if-no-1st-sp%%msg:::drop-last-lf%\n" | ||
$template FixHostname,"<%%pri%>%timestamp% <%= @name %> %syslogtag%%msg:::sp-if-no-1st-sp%%msg:::drop-last-lf%\n" |