Skip to content
This repository has been archived by the owner on Dec 31, 2022. It is now read-only.

Commit

Permalink
feat(logrotate) implement logrotate
Browse files Browse the repository at this point in the history
Currently, frameworks (rails) and webservers (apache2 and nginx) are
supported.

Resolves #78
  • Loading branch information
ajgon committed Apr 24, 2017
1 parent e216972 commit 2bc9c51
Show file tree
Hide file tree
Showing 95 changed files with 380 additions and 77 deletions.
1 change: 1 addition & 0 deletions .kitchen.yml
Expand Up @@ -4,6 +4,7 @@ driver:

provisioner:
name: chef_zero
require_chef_omnibus: 12

# Uncomment the following verifier to leverage Inspec instead of Busser (the
# default verifier)
Expand Down
2 changes: 1 addition & 1 deletion .ruby-version
@@ -1 +1 @@
ruby-2.4.0
ruby-2.4.1
1 change: 1 addition & 0 deletions Berksfile
@@ -1,4 +1,5 @@
# frozen_string_literal: true

source 'https://supermarket.chef.io'
solver :ruby, :required

Expand Down
43 changes: 43 additions & 0 deletions Dockerfile
@@ -0,0 +1,43 @@
FROM ruby:2.4.1

RUN printf "deb http://deb.debian.org/debian testing main\ndeb http://deb.debian.org/debian testing-updates main\ndeb http://security.debian.org testing/updates main" >> /etc/apt/sources.list
RUN apt-get update && \
apt-get install --yes --no-install-recommends apt-transport-https=1.0.* && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
RUN echo 'deb https://deb.nodesource.com/node_6.x jessie main' > /etc/apt/sources.list.d/nodesource.list && \
curl -s https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add - && \
apt-get update && \
apt-get install --yes --target-release=stable --no-install-recommends python-pip python-yaml locales nodejs=6.* build-essential && \
apt-get install --yes --target-release=testing --no-install-recommends git && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
RUN gem update --no-document --system
RUN npm install -g conventional-changelog-cli

RUN echo 'en_US.UTF-8 UTF-8' >> /etc/locale.gen
RUN locale-gen
ENV LC_ALL en_US.UTF-8

ENV APP_HOME /app
RUN mkdir "$APP_HOME"

RUN curl -o /tmp/chefdk.deb https://packages.chef.io/files/stable/chefdk/1.3.43/debian/8/chefdk_1.3.43-1_amd64.deb && \
dpkg -i /tmp/chefdk.deb && \
rm -rf /tmp/chefdk.deb

RUN gem install bundler
RUN pip install yamllint>=1

WORKDIR $APP_HOME
COPY package.json $APP_HOME/
RUN npm install

COPY Gemfile* $APP_HOME/
RUN bundle install -j 4
RUN chef exec bundle install -j 4

COPY Berksfile* $APP_HOME/
COPY metadata.rb $APP_HOME/
COPY README.md $APP_HOME/
RUN chef exec berks
5 changes: 4 additions & 1 deletion Gemfile
@@ -1,4 +1,5 @@
# frozen_string_literal: true

source 'https://rubygems.org/'

group :lint do
Expand All @@ -15,7 +16,9 @@ end

group :chef do
gem 'berkshelf'
gem 'chefspec'
gem 'chef', '~> 12.0'
gem 'chef-zero', '~> 5.3'
gem 'chefspec', '~> 6.0'
gem 'kitchen-docker'
gem 'kitchen-vagrant'
gem 'rspec'
Expand Down
61 changes: 32 additions & 29 deletions Gemfile.lock
Expand Up @@ -2,10 +2,10 @@ GEM
remote: https://rubygems.org/
specs:
addressable (2.4.0)
artifactory (2.7.0)
artifactory (2.8.1)
ast (2.3.0)
backports (3.6.8)
berkshelf (5.6.3)
backports (3.7.0)
berkshelf (5.6.4)
addressable (~> 2.3, >= 2.3.4)
berkshelf-api-client (>= 2.0.2, < 4.0)
buff-config (~> 2.0)
Expand All @@ -25,7 +25,7 @@ GEM
faraday (~> 0.9)
httpclient (~> 2.7)
ridley (>= 4.5, < 6.0)
brakeman (3.5.0)
brakeman (3.6.1)
buff-config (2.0.0)
buff-extensions (~> 2.0)
varia_model (~> 0.6)
Expand Down Expand Up @@ -77,7 +77,7 @@ GEM
fuzzyurl
mixlib-config (~> 2.0)
mixlib-shellout (~> 2.0)
chef-zero (5.3.0)
chef-zero (5.3.2)
ffi-yajl (~> 2.2)
hashie (>= 2.0, < 4.0)
mixlib-log (~> 1.3)
Expand All @@ -87,7 +87,7 @@ GEM
chef (>= 12.0)
fauxhai (~> 3.6)
rspec (~> 3.0)
childprocess (0.5.9)
childprocess (0.6.3)
ffi (~> 1.0, >= 1.0.11)
cleanroom (1.0.0)
colorize (0.8.1)
Expand All @@ -114,10 +114,10 @@ GEM
ruby_parser (~> 3.7)
fauxhai (3.10.0)
net-ssh
ffi (1.9.17)
ffi (1.9.18)
ffi-yajl (2.3.0)
libyajl2 (~> 1.2)
foodcritic (9.0.0)
foodcritic (10.4.1)
cucumber-core (>= 1.3)
erubis
nokogiri (>= 1.5, < 2.0)
Expand All @@ -126,24 +126,24 @@ GEM
treetop (~> 1.4)
yajl-ruby (~> 1.1)
fuzzyurl (0.9.0)
gh (0.15.0)
gh (0.15.1)
addressable (~> 2.4.0)
backports
faraday (~> 0.8)
multi_json (~> 1.0)
net-http-persistent (~> 2.9)
net-http-pipeline
gherkin (4.0.0)
gherkin (4.1.1)
hashie (3.5.5)
highline (1.7.8)
hitimes (1.2.4)
httpclient (2.8.3)
iniparse (1.4.2)
ipaddress (0.8.3)
json (2.0.3)
json (2.1.0)
kitchen-docker (2.6.0)
test-kitchen (>= 1.0.0)
kitchen-vagrant (1.0.2)
kitchen-vagrant (1.1.0)
test-kitchen (~> 1.4)
kramdown (1.13.2)
launchy (2.4.3)
Expand All @@ -169,7 +169,7 @@ GEM
mixlib-log (1.7.1)
mixlib-shellout (2.2.7)
mixlib-versioning (1.1.0)
molinillo (0.5.6)
molinillo (0.5.7)
multi_json (1.12.1)
multipart-post (2.0.0)
net-http-persistent (2.9.4)
Expand All @@ -186,9 +186,9 @@ GEM
net-ssh-gateway (>= 1.2.0)
net-telnet (0.1.1)
nio4r (2.0.0)
nokogiri (1.7.0.1)
nokogiri (1.7.1)
mini_portile2 (~> 2.1.0)
octokit (4.6.2)
octokit (4.7.0)
sawyer (~> 0.8.0, >= 0.5.3)
ohai (8.23.0)
chef-config (>= 12.5.0.alpha.1, < 13)
Expand All @@ -202,8 +202,8 @@ GEM
plist (~> 3.1)
systemu (~> 2.6.4)
wmi-lite (~> 1.0)
overcommit (0.38.0)
childprocess (~> 0.5.8)
overcommit (0.39.1)
childprocess (~> 0.6.3)
iniparse (~> 1.4)
parser (2.4.0.0)
ast (~> 2.2)
Expand All @@ -215,7 +215,8 @@ GEM
json
websocket (~> 1.0)
rack (2.0.1)
rainbow (2.2.1)
rainbow (2.2.2)
rake
rake (12.0.0)
retryable (2.0.4)
ridley (5.1.0)
Expand Down Expand Up @@ -255,14 +256,14 @@ GEM
rspec_junit_formatter (0.2.3)
builder (< 4)
rspec-core (>= 2, < 4, != 2.12.0)
rubocop (0.47.1)
rubocop (0.48.1)
parser (>= 2.3.3.1, < 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.8.1)
ruby_parser (3.8.4)
ruby_parser (3.9.0)
sexp_processor (~> 4.1)
rufus-lru (1.1.0)
safe_yaml (1.0.4)
Expand All @@ -275,7 +276,7 @@ GEM
rspec (~> 3.0)
rspec-its
specinfra (~> 2.53)
sexp_processor (4.8.0)
sexp_processor (4.9.0)
sfl (2.3)
simplecov (0.12.0)
docile (~> 1.1.0)
Expand All @@ -285,28 +286,28 @@ GEM
solve (3.1.0)
molinillo (>= 0.5)
semverse (>= 1.1, < 3.0)
specinfra (2.67.2)
specinfra (2.67.8)
net-scp
net-ssh (>= 2.7, < 5.0)
net-telnet
sfl
syslog-logger (1.6.8)
systemu (2.6.5)
term-ansicolor (1.4.0)
term-ansicolor (1.6.0)
tins (~> 1.0)
test-kitchen (1.15.0)
test-kitchen (1.16.0)
mixlib-install (>= 1.2, < 3.0)
mixlib-shellout (>= 1.2, < 3.0)
net-scp (~> 1.1)
net-ssh (>= 2.9, < 5.0)
net-ssh-gateway (~> 1.2)
safe_yaml (~> 1.0)
thor (~> 0.18)
thor (~> 0.19, < 0.19.2)
thor (0.19.1)
timers (4.0.4)
hitimes
tins (1.13.2)
travis (1.8.6)
travis (1.8.8)
backports
faraday (~> 0.9)
faraday_middleware (~> 0.9, >= 0.9.1)
Expand All @@ -319,7 +320,7 @@ GEM
polyglot (~> 0.3)
typhoeus (0.8.0)
ethon (>= 0.8.0)
unicode-display_width (1.1.3)
unicode-display_width (1.2.1)
uuidtools (2.1.5)
varia_model (0.6.0)
buff-extensions (~> 2.0)
Expand All @@ -335,7 +336,9 @@ DEPENDENCIES
berkshelf
brakeman
bundler-audit
chefspec
chef (~> 12.0)
chef-zero (~> 5.3)
chefspec (~> 6.0)
coveralls
fasterer
foodcritic
Expand All @@ -349,4 +352,4 @@ DEPENDENCIES
travis

BUNDLED WITH
1.14.5
1.14.6
3 changes: 2 additions & 1 deletion Rakefile
@@ -1,4 +1,5 @@
# frozen_string_literal: true

require 'bundler/setup'

desc 'Run Test Kitchen integration tests'
Expand All @@ -22,4 +23,4 @@ namespace :integration do
end
end

task default: %w(integration:vagrant)
task default: %w[integration:vagrant]
9 changes: 5 additions & 4 deletions attributes/default.rb
Expand Up @@ -4,10 +4,10 @@

default['build-essential']['compile_time'] = true
default['ruby-ng']['ruby_version'] = node['ruby'].try(:[], 'version') || '2.4'
default['nginx']['source']['modules'] = %w(
default['nginx']['source']['modules'] = %w[
nginx::http_ssl_module nginx::http_realip_module nginx::http_gzip_static_module nginx::headers_more_module
nginx::http_stub_status_module
)
]

default['deploy']['timeout'] = 600

Expand All @@ -21,9 +21,10 @@
'log' => 'log'
}
default['defaults']['global']['create_dirs_before_symlink'] =
%w(tmp public config ../../shared/cache ../../shared/assets)
default['defaults']['global']['purge_before_symlink'] = %w(log tmp/cache tmp/pids public/system public/assets)
%w[tmp public config ../../shared/cache ../../shared/assets]
default['defaults']['global']['purge_before_symlink'] = %w[log tmp/cache tmp/pids public/system public/assets]
default['defaults']['global']['rollback_on_error'] = true
default['defaults']['global']['logrotate_rotate'] = 30

# database
## common
Expand Down
8 changes: 8 additions & 0 deletions docker-compose.yml
@@ -0,0 +1,8 @@
---
version: '2'

services:
chef:
build: .
volumes:
- ".:/app"
1 change: 1 addition & 0 deletions libraries/all.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true

libdir = File.expand_path('..', __FILE__)
require File.join(libdir, 'core_ext')
require File.join(libdir, 'helpers')
Expand Down
1 change: 1 addition & 0 deletions libraries/core_ext.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true

class Object
def try(*a, &b)
try!(*a, &b) if a.empty? || respond_to?(a.first)
Expand Down
1 change: 1 addition & 0 deletions libraries/drivers_appserver_base.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true

module Drivers
module Appserver
class Base < Drivers::Base
Expand Down
1 change: 1 addition & 0 deletions libraries/drivers_appserver_factory.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true

module Drivers
module Appserver
class Factory
Expand Down
1 change: 1 addition & 0 deletions libraries/drivers_appserver_null.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true

module Drivers
module Appserver
class Null < Drivers::Appserver::Base
Expand Down
3 changes: 2 additions & 1 deletion libraries/drivers_appserver_puma.rb
@@ -1,10 +1,11 @@
# frozen_string_literal: true

module Drivers
module Appserver
class Puma < Drivers::Appserver::Base
adapter :puma
allowed_engines :puma
output filter: [:log_requests, :preload_app, :thread_max, :thread_min, :timeout, :worker_processes]
output filter: %i[log_requests preload_app thread_max thread_min timeout worker_processes]

def appserver_config
'puma.rb'
Expand Down
3 changes: 2 additions & 1 deletion libraries/drivers_appserver_thin.rb
@@ -1,10 +1,11 @@
# frozen_string_literal: true

module Drivers
module Appserver
class Thin < Drivers::Appserver::Base
adapter :thin
allowed_engines :thin
output filter: [:max_connections, :max_persistent_connections, :timeout, :worker_processes]
output filter: %i[max_connections max_persistent_connections timeout worker_processes]

def appserver_config
'thin.yml'
Expand Down

0 comments on commit 2bc9c51

Please sign in to comment.