Skip to content
This repository was archived by the owner on Dec 14, 2018. 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
5 changes: 4 additions & 1 deletion .kitchen.dokken.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
driver:
name: dokken
chef_version: latest
chef_version: 12.20.3
privileged: true
transport:
name: dokken
Expand Down Expand Up @@ -82,6 +82,9 @@ suites:
- name: default
provisioner:
policyfile: test/fixtures/policies/default.rb
- name: sentinel
provisioner:
policyfile: test/fixtures/policies/sentinel.rb
- name: archive
provisioner:
policyfile: test/fixtures/policies/default.rb
Expand Down
1 change: 1 addition & 0 deletions .kitchen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ driver:
name: vagrant
provisioner:
name: chef_zero
require_chef_omnibus: 12.20.3
verifier:
name: inspec
platforms:
Expand Down
3 changes: 1 addition & 2 deletions libraries/redis_installation_package.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def install_redis

if node.platform_family?('debian')
dpkg_autostart 'redis-server' do
action :nothing
action :create
allow false
end
end
Expand All @@ -112,7 +112,6 @@ def install_redis
notifies :delete, init_file, :immediately
version system_package_version if system_package_version
if node.platform_family?('debian')
notifies :create, 'dpkg_autostart[redis-server]', :immediately
options '-o Dpkg::Options::=--path-exclude=/etc/redis*'
end
end
Expand Down
10 changes: 5 additions & 5 deletions libraries/redis_sentinel.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class RedisSentinel < Chef::Resource
attribute(:config_path, kind_of: String, default: '/etc/redis-sentinel.conf')
# @!attribute config_mode
# @return [String]
attribute(:config_mode, kind_of: String, default: '0440')
attribute(:config_mode, kind_of: String, default: '0740')

# @see: https://github.com/antirez/redis/blob/3.2/sentinel.conf
attribute(:sentinel_port, kind_of: Integer, default: 26_379)
Expand All @@ -62,10 +62,10 @@ class RedisSentinel < Chef::Resource
attribute(:sentinel_client_reconfig, kind_of: [String, NilClass], default: nil)

def default_config_source
if parent.version
"#{parent.version.match(/\d\.\d/).first}/sentinel.conf.erb"
if matches = parent.options.fetch('version', '').match(/\d\.\d/)
"#{matches.first}/sentinel.conf.erb"
else
'sentinel.conf.erb'
'3.2/sentinel.conf.erb'
end
end
end
Expand Down Expand Up @@ -112,7 +112,7 @@ def action_disable

# @api private
def service_options(service)
service.command("#{new_resource.program} #{new_resource.config_path}")
service.command("#{new_resource.program} #{new_resource.config_path} --sentinel")
service.directory(new_resource.directory)
service.user(new_resource.user)
end
Expand Down
4 changes: 2 additions & 2 deletions recipes/sentinel.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@

redis_installation node['blp-redis']['sentinel']['service_name'] { version '' }

redis_sentinel node['redis']['sentinel']['service_name'] do
owner node['blp-redis']['service_owner']
redis_sentinel node['blp-redis']['sentinel']['service_name'] do
user node['blp-redis']['service_user']
group node['blp-redis']['service_group']
node['blp-redis']['sentinel']['config'].each_pair { |k, v| send(k, v) }
end
1 change: 0 additions & 1 deletion test/fixtures/policies/_base.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
default_source :community
default_source :chef_repo, '..'
cookbook 'blp-redis', path: '../../..'
run_list 'blp-redis::default'
named_run_list :centos, 'yum::default', 'yum-epel::default', run_list
named_run_list :debian, 'apt::default', run_list
named_run_list :freebsd, 'freebsd::default', run_list
3 changes: 2 additions & 1 deletion test/fixtures/policies/default.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
name 'default'
instance_eval(IO.read(File.expand_path('../_base.rb', __FILE__)))
run_list 'blp-redis::default'
instance_eval(IO.read(File.expand_path('../_base.rb', __FILE__)))
2 changes: 1 addition & 1 deletion test/fixtures/policies/sentinel.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
name 'sentinel'
run_list 'blp-redis::sentinel'
instance_eval(IO.read(File.expand_path('../_base.rb', __FILE__)))
run_list << 'blp-redis::sentinel'
7 changes: 4 additions & 3 deletions test/integration/sentinel/default_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
it { should be_running }
end

describe processes('redis-sentinel') do
describe processes('redis-server') do
its('list.length') { should eq 1 }
its('users') { should eq %w[redis] }
its('list.first.command') { should include '[sentinel]' }
end

describe group('redis') do
Expand All @@ -18,7 +19,7 @@
its('group') { should eq 'redis' }
end

describe file('/usr/bin/redis-sentinel') do
describe file('/usr/bin/redis-server') do
it { should exist }
it { should be_file }
it { should be_executable.by_user 'redis' }
Expand All @@ -29,5 +30,5 @@
it { should be_file }
it { should be_owned_by 'redis' }
it { should be_grouped_into 'redis' }
it { should be_mode 640 }
it { should be_mode 0740 }
end