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

Commit

Permalink
Merge pull request #18 from dhollinger/config_cleanup
Browse files Browse the repository at this point in the history
Clean up configuration code
  • Loading branch information
binford2k committed Nov 10, 2017
2 parents 6d0943c + b94ea29 commit cfe06b0
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 42 deletions.
2 changes: 1 addition & 1 deletion bin/puppet_webhook
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require 'webrick'
require 'webrick/https'
require 'puppet_webhook'

config_file '../config.yml'
config_file(File.join(__dir__, '..', 'config', 'server.yml'), '/etc/puppet-webhook/server.yml')

PIDFILE = settings.pidfile
LOCKFILE = settings.lockfile
Expand Down
38 changes: 0 additions & 38 deletions config.yml

This file was deleted.

31 changes: 31 additions & 0 deletions config/app.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
enable_mutex_lock: false
user: puppet
pass: puppet
protected: true
client_cfg: "/var/lib/peadmin/.mcollective"
client_timeout: "120"
use_mco_ruby: false
use_mcollective: false
slack_webhook: false
default_branch: production
discovery_timeout: '10'
ignore_environments: []
prefix: false
prefix_command: "/bin/echo example"
r10k_deploy_arguments: "-pv"
allow_uppercase: true
github_secret:
repository_events:
server_type: simple
logfile: /var/log/puppet-webhook/access.log
pidfile: /var/run/puppet-webhook/webhook.pid
lockfile: /var/run/puppet-webhook/webhook.lock
approot: './'
server_software: PuppetWebhook
bind_address: 0.0.0.0
port: 8088
enable_ssl: false
verify_ssl: false
public_key_path: ''
private_key_path: ''
command_prefix: 'umask 0022;'
13 changes: 13 additions & 0 deletions config/server.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
server_type: simple
logfile: /var/log/puppet-webhook/access.log
pidfile: /var/run/puppet-webhook/webhook.pid
lockfile: /var/run/puppet-webhook/webhook.lock
approot: './'
server_software: PuppetWebhook
bind_address: 0.0.0.0
port: 8088
enable_ssl: false
verify_ssl: false
public_key_path: ''
private_key_path: ''
command_prefix: 'umask 0022;'
5 changes: 4 additions & 1 deletion lib/puppet_webhook.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
require 'parsers/webhook_json_parser'

class PuppetWebhook < Sinatra::Base # rubocop:disable Style/Documentation
set :root, File.dirname(__FILE__)
use Rack::Parser,
parsers: { 'application/json' => Sinatra::Parsers::WebhookJsonParser.new },
handlers: { 'application/json' => proc { |e, type| [400, { 'Content-Type' => type }, [{ error: e.to_s }.to_json]] } }
register Sinatra::ConfigFile
config_file '../config.yml'

config_file(File.join(__dir__, '..', 'config', 'app.yml'), '/etc/puppet-webhook/app.yml')

set :static, false
set :lock, true if settings.enable_mutex_lock
Expand All @@ -24,6 +26,7 @@ class PuppetWebhook < Sinatra::Base # rubocop:disable Style/Documentation
return 200, { status: :success, message: 'running' }.to_json
end

# TODO: Move examples into the README.md
# Simulate a github post:
# curl -X POST \
# -H "Content-Type: application/json" \
Expand Down
4 changes: 2 additions & 2 deletions puppet-webhook.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ Gem::Specification.new do |spec|
'CHANGELOG.md',
'README.md',
'LICENSE',
'config.yml',
'config/*',
'lib/**/*',
'bin/*'
]
spec.homepage = 'https://github.com/voxpupuli/puppet-webhook'
spec.license = 'apache'
spec.executables = ['puppet_webhook']
spec.require_paths = ['lib']
spec.require_paths = %w[lib config]
spec.add_runtime_dependency 'json'
spec.add_runtime_dependency 'mcollective-client'
spec.add_runtime_dependency 'rack-parser'
Expand Down

0 comments on commit cfe06b0

Please sign in to comment.