Skip to content

Commit

Permalink
Merge pull request #1611 from lsst-it/IT-5846_udev_usb
Browse files Browse the repository at this point in the history
(role/laserrpi) add new udev rule ttyusb
  • Loading branch information
cbarria authored Jan 14, 2025
2 parents b0ac035 + 5b90157 commit e51f168
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 2 deletions.
2 changes: 1 addition & 1 deletion hieradata/role/laserrpi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ classes:
- "profile::core::docker"
- "profile::core::gpio"
- "profile::pi::add_usb"
- "profile::pi::ftdi"
- "profile::pi::pigpio"
- "profile::pi::ttyusb"
- "profile::ts::dco"

files:
Expand Down
16 changes: 16 additions & 0 deletions site/profile/manifests/pi/ttyusb.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# @summary
# Manages the permissions group for rpi USB devices
#
class profile::pi::ttyusb {
if defined(Class['profile::core::docker']) {
$group = Class['profile::core::docker']['socket_group']
} else {
$group = '70014'
}

systemd::udev::rule { '90-tty-usb.rules':
rules => [
"KERNEL==\"ttyUSB[0-9]*\", GROUP=\"${group}\", MODE=\"0660\"",
],
}
}
15 changes: 15 additions & 0 deletions spec/classes/pi/ttyusb_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# frozen_string_literal: true

require 'spec_helper'

describe 'profile::pi::ttyusb' do
on_supported_os.each do |os, os_facts|
context "on #{os}" do
let(:facts) { os_facts }

it { is_expected.to compile.with_all_deps }

include_examples 'ttyusb'
end
end
end
2 changes: 1 addition & 1 deletion spec/hosts/roles/laserrpi_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
include_examples 'docker'
include_examples('gpio', os_facts:)
include_examples 'pigpio'
include_examples 'ftdi'
include_examples 'ttyusb'
include_examples 'dco'
include_examples 'add_usb'

Expand Down
11 changes: 11 additions & 0 deletions spec/support/spec/ttyusb.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# frozen_string_literal: true

shared_examples 'ttyusb' do
it do
is_expected.to contain_systemd__udev__rule('90-tty-usb.rules').with(
rules: [
'KERNEL=="ttyUSB[0-9]*", GROUP="70014", MODE="0660"',
]
)
end
end

0 comments on commit e51f168

Please sign in to comment.