Skip to content
This repository was archived by the owner on Jan 8, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.*.sw?
pkg
spec/fixtures
spec/fixtures/modules
.rspec_system
Gemfile.lock
.bundle
15 changes: 12 additions & 3 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
$user = $synapse::params::user,
$group = $synapse::params::group,
$stats_socket = $synapse::params::stats_socket,
$working_dir = '/run/synapse',
$haproxy_daemon = true,
$haproxy_reload_command = $synapse::params::haproxy_reload_command,
$haproxy_bind_address = 'localhost',
Expand Down Expand Up @@ -62,12 +63,20 @@
}

if str2bool($service_manage) {
class { 'synapse::system_service':
subscribe => [
initscript { 'synapse':
ulimit => {
'nofile' => '65535',
},
before_command => [
['mkdir', '-p', "${working_dir}/sockets", "${working_dir}/services"],
['chown', '-R', $user, $working_dir],
],
command => ['setuidgid', $user, '/usr/bin/synapse', '--config', $config_file],
service_ensure => $service_ensure,
subscribe => [
Class['synapse::install'],
Class['synapse::config'],
],
}
}

}
2 changes: 1 addition & 1 deletion manifests/service.pp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
}

if str2bool($synapse::service_manage) {
File[$target] ~> Service['synapse']
File[$target] ~> Initscript['synapse']
}

}
Expand Down
46 changes: 0 additions & 46 deletions manifests/system_service.pp

This file was deleted.

5 changes: 4 additions & 1 deletion metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "KyleAnderson-synapse",
"version": "0.0.5",
"author": "Kyle Anderson <kyle@xkyle.com>",
"summary": "Puppet configuration for Airbnbs system for service discovery. Configures a dynamic HAproxy based on zookeeper entries",
"summary": "Puppet configuration for Airbnb's system for service discovery. Configures a dynamic HAproxy based on zookeeper entries",
"license": "Apache-2.0",
"source": "https://github.com/solarkennedy/puppet-synapse",
"project_page": "https://github.com/solarkennedy/puppet-synapse",
Expand All @@ -11,6 +11,9 @@
{
"name": "puppetlabs/stdlib",
"version_requirement": ">= 3.0.0"
},
{
"name": "EvanKrall/puppet-initscript"
}
]
}
7 changes: 3 additions & 4 deletions spec/classes/synapse_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
it { should contain_class('synapse::params') }
it { should contain_class('synapse::install') }
it { should contain_class('synapse::config') }
it { should contain_class('synapse::system_service') }
end
end
end
Expand Down Expand Up @@ -48,7 +47,7 @@
:name => 'rubygem-synapse'
) }
end

# Config stuff
context 'config by default' do
let(:params) {{ }}
Expand Down Expand Up @@ -103,8 +102,8 @@
context 'when requested not to run' do
let(:params) {{ :service_ensure => 'stopped' }}
let(:facts) {{ :osfamily => 'Debian' }}
it { should contain_service('synapse').with(
:ensure => 'stopped'
it { should contain_initscript('synapse').with(
:service_ensure => 'stopped'
) }
end

Expand Down
9 changes: 8 additions & 1 deletion spec/defines/synapse_service_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
require 'spec_helper'
describe 'synapse::service', :type => :define do
let(:facts) {{ :osfamily => 'Debian' }}
let(:pre_condition) do
global_pre_condition +
[
"class { 'synapse': }",
]
end

describe 'With an example service' do
let :title do
Expand Down Expand Up @@ -36,7 +43,7 @@
) }

it { should contain_file('/etc/synapse/conf.d/example_service.json').with_content(/\"default_servers\":/) }

it { should contain_file('/etc/synapse/conf.d/example_service.json').with_content(/\"discovery\": \{\n \"method\": \"zookeeper\",\n \"path\": \"\/airbnb\/service\/service2\",\n \"hosts\": \[\n \"zk0\.airbnb\.com:2181\",/) }

it { should contain_file('/etc/synapse/conf.d/example_service.json').with_content(/\"haproxy\": \{\n \"port\": \"3214\",\n \"server_options\": \"check inter 2s rise 3 fall 2\",\n \"listen\": \[\n \"mode http\",\n \"option httpchk \/health\"\n \]\n\}\n\}/ ) }
Expand Down
18 changes: 18 additions & 0 deletions spec/fixtures/manifests/site.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
define initscript(
$command,
$manage_service = true,
$user = undef,
$group = undef,
$service_ensure = 'running',
$service_enable = true,
$has_reload = true,
$reload_command = undef,
$launchd_name = undef,
$description = '',
$short_description = '',
$init_style = undef,
$source_default_file = false,
$default_file_path = undef,
$before_command = [],
$ulimit = {}
) {}
18 changes: 18 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1 +1,19 @@
require 'rspec/core/shared_context'
require 'puppetlabs_spec_helper/module_spec_helper'

module GlobalHelper
extend RSpec::Core::SharedContext

def global_pre_condition
if ENV['FUTURE_PARSER'] == 'yes' or not Puppet.version =~ /^3/
[(File.read('spec/fixtures/manifests/site.pp') rescue ''),
'Package { provider => "apt" }']
else [] end
end

let(:pre_condition) { global_pre_condition }
end

RSpec.configure do |c|
c.include GlobalHelper
end
23 changes: 0 additions & 23 deletions templates/synapse.conf.upstart.erb

This file was deleted.