Skip to content

Commit

Permalink
Updated config files to match the latest packages
Browse files Browse the repository at this point in the history
  • Loading branch information
MhdSyrwan committed Dec 25, 2015
1 parent fe69796 commit 50e3400
Show file tree
Hide file tree
Showing 8 changed files with 92 additions and 17 deletions.
2 changes: 0 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
language: ruby

rvm:
- 1.9.3
- 2.0.0
- 2.1.0

before_script:
Expand Down
6 changes: 3 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ gem 'rake'

group :lint do
gem 'rubocop', '~> 0.18'
gem 'foodcritic', '~> 3.0'
gem 'foodcritic', '~> 5.0'
end

group :unit, :integration do
gem 'berkshelf', '~> 3.0'
gem 'berkshelf', '~> 4.0'
end

group :unit do
gem 'chefspec', '~> 3.1'
gem 'chefspec', '~> 4.3'
gem 'rspec-expectations', '~> 2.14.0'
end

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ This cookbook doesn't have direct dependencies on other cookbooks.
Attributes
==========

* `node[:beanstalkd][:opts]` - The opts array value, defaults to {}
* `node[:beanstalkd][:start_during_boot]` - The start during boot value, defaults to false (beanstalkd on Ubuntu only)
* `node[:beanstalkd][:opts]` - The opts array value, defaults to `{l: '127.0.01', p: '11300'}`
* `node[:beanstalkd][:start_during_boot]` - The start during boot value, defaults to false (beanstalkd on Debian only)

Usage
=====
Expand Down
7 changes: 5 additions & 2 deletions attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
# Copyright 2012-2014, Escape Studios
#

default[:beanstalkd][:opts] = {}
default[:beanstalkd][:opts] = {
:p => '11300',
:l => '127.0.0.1'
}

# Ubuntu only
# Debian Only
default[:beanstalkd][:start_during_boot] = false
25 changes: 25 additions & 0 deletions spec/unit/debian_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
require 'spec_helper'

describe 'beanstalkd::default' do
let(:chef_run) do
ChefSpec::ServerRunner.new(:platform => 'debian', :version => '7.2') do |node|
node.automatic[:fqdn] = 'myserver'
end.converge(described_recipe)
end

it 'should install beanstalkd service' do
expect(chef_run).to upgrade_package('beanstalkd')
end

it 'should start beanstalkd service' do
expect(chef_run).to enable_service('beanstalkd')
expect(chef_run).to start_service('beanstalkd')
end

it 'should creates a defaults file at /etc/default/beanstalkd' do
expect(chef_run).to(render_file('/etc/default/beanstalkd').with_content do |content|
expect(content).to include('Generated by Chef for myserver')
expect(content).to include('DAEMON_OPTS="-p 11300 -l 127.0.0.1 "')
end)
end
end
23 changes: 22 additions & 1 deletion spec/unit/default_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,26 @@
require 'spec_helper'

describe 'beanstalkd::default' do
let(:chef_run) { ChefSpec::Runner.new.converge(described_recipe) }
let(:chef_run) do
ChefSpec::ServerRunner.new(:platform_family => 'centos') do |node|
node.automatic[:fqdn] = 'myserver'
end.converge(described_recipe)
end

it 'should install beanstalkd service' do
expect(chef_run).to upgrade_package('beanstalkd')
end

it 'should start beanstalkd service' do
expect(chef_run).to enable_service('beanstalkd')
expect(chef_run).to start_service('beanstalkd')
end

it 'should creates a defaults file at /etc/sysconfig/beanstalkd' do
expect(chef_run).to(render_file('/etc/sysconfig/beanstalkd').with_content do |content|
expect(content).to include('Generated by Chef for myserver')
expect(content).to include('BEANSTALKD_ADDR=127.0.0.1')
expect(content).to include('BEANSTALKD_PORT=11300')
end)
end
end
27 changes: 27 additions & 0 deletions spec/unit/ubuntu_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
require 'spec_helper'

describe 'beanstalkd::default' do
let(:chef_run) do
ChefSpec::ServerRunner.new(:platform => 'ubuntu', :version => '14.04') do |node|
node.automatic[:fqdn] = 'myserver'
end.converge(described_recipe)
end

it 'should install beanstalkd service' do
expect(chef_run).to upgrade_package('beanstalkd')
end

it 'should start beanstalkd service' do
expect(chef_run).to enable_service('beanstalkd')
expect(chef_run).to start_service('beanstalkd')
end

it 'should creates a defaults file at /etc/default/beanstalkd' do
expect(chef_run).to(render_file('/etc/default/beanstalkd').with_content do |content|
expect(content).to include('Generated by Chef for myserver')
expect(content).to include('BEANSTALKD_LISTEN_ADDR=127.0.0.1')
expect(content).to include('BEANSTALKD_LISTEN_PORT=11300')
expect(content).to include('BEANSTALKD_EXTRA=""')
end)
end
end
15 changes: 8 additions & 7 deletions templates/ubuntu/beanstalkd.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
#
# Generated by Chef for <%= node[:fqdn] %>
#

## Defaults for the beanstalkd init script, /etc/init.d/beanstalkd on
## Debian systems. Append ``-b /var/lib/beanstalkd'' for persistent
## storage.
BEANSTALKD_EXTRA="<% @opts.each do |k,v| %><%= "-#{k} #{v}" %> <% end %>"
DAEMON_OPTS=$BEANSTALKD_EXTRA
## Debian systems.
<% @opts = @opts.to_hash # making a copy so we can delete keys %>

## Uncomment to enable startup during boot.
<% unless @start_during_boot %>#<% end %>START=yes
BEANSTALKD_LISTEN_ADDR=<%= @opts.delete('l') %>
BEANSTALKD_LISTEN_PORT=<%= @opts.delete('p') %>

# You can use BEANSTALKD_EXTRA to pass additional options. See beanstalkd(1)
# for a list of the available options.
BEANSTALKD_EXTRA="<% @opts.each do |k,v| %><%= "-#{k} #{v}" %> <% end %>"

0 comments on commit 50e3400

Please sign in to comment.