Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for RedHat #15

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,16 @@ optional.

The available parameters are the following:

#### Note on parameters with RedHat OSFamily:
The following parameters do not work with RedHat based systems:
```puppet
mdadm { $name :
...
generate_conf => $generate_conf,
update_initramfs => $update_initramfs,
}
```

### Parameters
*See puppet doc*

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

Puppet::Type.type(:mdadm).provide(:mdadm) do
desc "Manage Md raid devices"

confine :osfamily => [:debian]

commands :mdadm_cmd => 'mdadm',
:mkconf => '/usr/share/mdadm/mkconf',
:yes => 'yes',
Expand Down
60 changes: 60 additions & 0 deletions lib/puppet/provider/mdadm/mdadm_redhat.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
require 'puppet'

Puppet::Type.type(:mdadm).provide(:mdadm) do
desc "Manage Md raid devices"
confine :osfamily => [:redhat]

commands :mdadm_cmd => 'mdadm',
:yes => 'yes'

def create
cmd = [command(:mdadm_cmd)]
cmd << "--create"
cmd << "-e #{resource[:metadata]}"
cmd << resource.name
cmd << "--level=#{resource[:level]}"
cmd << "--raid-devices=#{resource[:active_devices] || resource[:devices].size}"
cmd << "--spare-devices=#{resource[:spare_devices]}" if resource[:spare_devices]
cmd << "--parity=#{resource[:parity]}" if resource[:parity]
cmd << "--chunk=#{resource[:chunk]}" if resource[:chunk]
cmd << resource[:devices]

if resource[:force]
cmd.unshift(command(:yes), "|")
end

execute(cmd.join(" "))
end

def assemble
cmd = [command(:mdadm_cmd)]
cmd << "--assemble"
cmd << resource.name
cmd << resource[:devices]
execute(cmd)
end

def stop
cmd = [command(:mdadm_cmd)]
cmd << "--misc"
cmd << "--stop"
cmd << resource.name
execute(cmd)
end

def exists?
device_not_found = 4
begin
execute([command(:mdadm_cmd), "--detail", "--test", resource.name])
debug "Device #{resource.name} found"
return ($CHILD_STATUS.exitstatus == 0)
rescue Puppet::ExecutionFailure
if ($CHILD_STATUS.exitstatus == device_not_found)
debug "Device #{resource.name} not found"
return false
else
raise
end
end
end
end
2 changes: 1 addition & 1 deletion manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
class mdadm::config {

if ($mdadm::include_cron) {
file { '/etc/cron.d/mdadm' :
file { $mdadm::params::cron_name :
ensure => 'present',
}
}
Expand Down
13 changes: 12 additions & 1 deletion manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,20 @@
$service_hasstatus = true
}
$include_cron = true
$cron_name = '/etc/cron.d/mdadm'
}
'RedHat': {
$package_name = 'mdadm'
$package_ensure = 'present'
$service_name = 'mdmonitor'
$service_ensure = 'stopped'
$service_manage = false
$service_hasstatus = true
$include_cron = true
$cron_name = '/etc/cron.d/raid-check'
}
default: {
fail("${::operatingsystem} not supported")
fail(" osfamily: ${::osfamily}, operatingsystem: ${::operatingsystem} not supported")
}
}
}