Skip to content

Commit

Permalink
Add parameter to udev class to create rules automatically
Browse files Browse the repository at this point in the history
  • Loading branch information
jcpunk authored and jhoblitt committed Feb 3, 2017
1 parent eea0992 commit cbdef8e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
5 changes: 5 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
class udev(
$udev_log = $udev::params::udev_log,
$config_file_replace = $udev::params::config_file_replace,
$rules = $udev::params::rules,
) inherits udev::params {
validate_re($udev_log, '^err$|^info$|^debug$')
validate_bool($config_file_replace)
Expand All @@ -48,4 +49,8 @@
Anchor['udev:begin'] ->
class { 'udev::udevadm::logpriority': udev_log => $udev_log } ->
Anchor['udev:end']

if $rules {
create_resources('udev::rule', $rules)
}
}
1 change: 1 addition & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

$udev_log = 'err'
$udevadm_path = '/sbin'
$rules = undef

case $::osfamily {
'debian': {
Expand Down
11 changes: 11 additions & 0 deletions spec/classes/udev_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,17 @@
end
end

describe 'rule parameter' do
let(:params) {{ 'rules' => { '99-foo.rules' => { 'content' => 'generic_rule' }}}}
it { should contain_file("/etc/udev/rules.d/99-foo.rules").with({
:owner => 'root',
:group => 'root',
:mode => '0644',
:content => 'generic_rule',
})}
end

end


end

0 comments on commit cbdef8e

Please sign in to comment.