Skip to content

Commit

Permalink
change smartd.conf ERB to use megaraid_physical_drives_{sas,sata} facts
Browse files Browse the repository at this point in the history
This modification add ssupport for polling the SMART values of SAS
drives behind a MegaRAID controller.  The `megaraid_physical_drives`
fact is no longer used internally by this module.
  • Loading branch information
Joshua Hoblitt committed Apr 14, 2014
1 parent 29e6a16 commit 824e086
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 17 deletions.
71 changes: 60 additions & 11 deletions spec/classes/smartd_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -430,14 +430,14 @@

describe 'megaraid support' do

describe 'without params + megaraid facts' do
describe 'without params + megaraid sata facts' do
let(:facts) do
{
:osfamily => 'RedHat',
:megaraid_adapters => '1',
:megaraid_virtual_drives => 'sdb,sda',
:megaraid_physical_drives => '2,1',
:smartmontools_version => '5.43',
:osfamily => 'RedHat',
:megaraid_adapters => '1',
:megaraid_virtual_drives => 'sdb,sda',
:megaraid_physical_drives_sata => '2,1',
:smartmontools_version => '5.43',
}
end

Expand All @@ -453,14 +453,63 @@
end
end

describe 'without params + megaraid sas facts' do
let(:facts) do
{
:osfamily => 'RedHat',
:megaraid_adapters => '1',
:megaraid_virtual_drives => 'sdb,sda',
:megaraid_physical_drives_sas => '2,1',
:smartmontools_version => '5.43',
}
end

it do
should contain_file('/etc/smartd.conf')\
.with_content(<<-END.gsub(/^\s+/, ""))
# Managed by Puppet -- do not edit!
DEFAULT -m root -M daily
/dev/sda -d megaraid,1
/dev/sda -d megaraid,2
DEVICESCAN
END
end
end

describe 'without params + megaraid sata+sas facts' do
let(:facts) do
{
:osfamily => 'RedHat',
:megaraid_adapters => '1',
:megaraid_virtual_drives => 'sdb,sda',
:megaraid_physical_drives_sas => '1,2',
:megaraid_physical_drives_sata => '3,4',
:smartmontools_version => '5.43',
}
end

it do
should contain_file('/etc/smartd.conf')\
.with_content(<<-END.gsub(/^\s+/, ""))
# Managed by Puppet -- do not edit!
DEFAULT -m root -M daily
/dev/sda -d sat+megaraid,3
/dev/sda -d sat+megaraid,4
/dev/sda -d megaraid,1
/dev/sda -d megaraid,2
DEVICESCAN
END
end
end

describe 'with params + megaraid facts' do
let(:facts) do
{
:osfamily => 'RedHat',
:megaraid_adapters => '1',
:megaraid_virtual_drives => 'sdb,sda',
:megaraid_physical_drives => '2,1',
:smartmontools_version => '5.43',
:osfamily => 'RedHat',
:megaraid_adapters => '1',
:megaraid_virtual_drives => 'sdb,sda',
:megaraid_physical_drives_sata => '2,1',
:smartmontools_version => '5.43',
}
end
let(:params) do
Expand Down
20 changes: 14 additions & 6 deletions templates/smartd.conf
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,21 @@ end
# if there is an entry for megaraid device options fish it out
megaraid_options = nil
@devices.each { |dev| dev['device'] == 'megaraid' ? megaraid_options = dev['options'] : nil }

if megaraid_device and megaraid_device != '' and
@megaraid_adapters and @megaraid_adapters.to_i > 0
@megaraid_physical_drives.split(/,/).sort.each do |drive| -%>
-%>
<% if megaraid_device and megaraid_device != '' and
@megaraid_adapters and @megaraid_adapters.to_i > 0 -%>
<%- unless @megaraid_physical_drives_sata.nil? -%>
<%- @megaraid_physical_drives_sata.split(/,/).sort.each do |drive| -%>
<%= megaraid_device %> -d sat+megaraid,<%= drive.to_i -%>
<% if megaraid_options %><%= ' ' + megaraid_options %><% end %>
<% end -%>
<%- if megaraid_options %><%= ' ' + megaraid_options %><% end %>
<%- end -%>
<%- end -%>
<%- unless @megaraid_physical_drives_sas.nil? -%>
<%- @megaraid_physical_drives_sas.split(/,/).sort.each do |drive| -%>
<%= megaraid_device %> -d megaraid,<%= drive.to_i -%>
<%- if megaraid_options %><%= ' ' + megaraid_options %><% end %>
<%- end -%>
<%- end -%>
<% end -%>
<% if @devicescan -%>
<% unless @enable_default -%>
Expand Down

0 comments on commit 824e086

Please sign in to comment.