Skip to content

Commit

Permalink
add class udev::udevadm to manage udevadm trigger
Browse files Browse the repository at this point in the history
  • Loading branch information
Joshua Hoblitt committed Sep 19, 2013
1 parent b6821fe commit 112ebab
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 0 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,15 @@ Usage
include udev
```

### Manually trigging a udev rules reload

```puppet
file { '/etc/etc/udev/rules.d/99-myfrobnicator.rules':
...
notify => Class['udev::udevadm'],
}
```


Limitations
-----------
Expand Down
4 changes: 4 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
# simple template
#
class udev inherits udev::params {

package{ $udev::params::udev_package:
ensure => present,
}

class { 'udev::udevadm': } ->
Class['udev']
}
1 change: 1 addition & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#
class udev::params {
$udev_package = 'udev'
$udevadm_path = '/sbin'

case $::osfamily {
'redhat': {}
Expand Down
25 changes: 25 additions & 0 deletions manifests/udevadm.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# == Class: udev::udevadm
#
# This class should not being included into the manifest directly. It's
# function is to receive messages that the udev configuration files have
# changed.
#
# === Example
#
# file { '/etc/etc/udev/rules.d/99-myfrobnicator.rules':
# ...
# notify => Class['udev::udevadm'],
# }
#
class udev::udevadm inherits udev::params {

# adding `udevadm control --reload-rules` may be needed some day for edge
# cases.
# http://unix.stackexchange.com/questions/39370/how-to-reload-udev-rules-without-reboot

exec { 'udevadm trigger':
command => 'udevadm trigger',
refreshonly => true,
path => [$udev::params::udevadm_path],
}
}
1 change: 1 addition & 0 deletions spec/classes/udev_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

it { should include_class('udev') }
it { should contain_package('udev').with_ensure(:present) }
it { should contain_class('udev::udevadm') }
end

end
18 changes: 18 additions & 0 deletions spec/classes/udevadm_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
require 'spec_helper'

describe 'udev::udevadm', :type => :class do

describe 'for osfamily RedHat' do
let(:facts) {{ :osfamily => 'RedHat' }}

it { should include_class('udev::udevadm') }
it do
should contain_exec('udevadm trigger').with({
:command => 'udevadm trigger',
:refreshonly => true,
:path => ['/sbin'],
})
end
end

end

0 comments on commit 112ebab

Please sign in to comment.