-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from lsst-it/IT-4907/boot-cmdline
fwv
- Loading branch information
Showing
26 changed files
with
545 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,5 @@ | |
|
||
inherit_gem: | ||
voxpupuli-test: rubocop.yml | ||
RSpec/BeforeAfterAll: | ||
Enabled: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
include pi::cmdline |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
class { 'pi::cmdline': | ||
reboot => false, # reboots are problematic for acceptance testing | ||
} | ||
|
||
pi::cmdline::parameter { '8250.nr_uarts=0': } | ||
pi::cmdline::parameter { 'coherent_pool=1M': } | ||
pi::cmdline::parameter { 'snd_bcm2835.enable_headphones=0': } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
include pi::config |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
class { 'pi::config': | ||
reboot => false, # reboots are problematic for acceptance testing | ||
} | ||
|
||
pi::config::fragment { 'disable_overscan=1': } | ||
pi::config::fragment { 'dtparam=audio=on': | ||
order => 1, | ||
} | ||
pi::config::fragment { 'hdmi_mode=1': | ||
order => 99, | ||
} | ||
pi::config::fragment { 'foo': | ||
content => "hdmi_safe=1\n", | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
class { 'pi::config': | ||
reboot => false, # reboots are problematic for acceptance testing | ||
fragments => { | ||
'dtoverlay=pps-gpio,gpiopin=4' => { | ||
'order' => 99, | ||
}, | ||
'dtparam=i2c_arm=on' => { | ||
'order' => 1, | ||
}, | ||
'dtparam=spi=on' => {}, | ||
'serial port' => { | ||
# lint:ignore:strict_indent | ||
'content' => @("CONTENT"), | ||
enable_uart=1 | ||
init_uart_baud=9600 | ||
| CONTENT | ||
# lint:endignore | ||
}, | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
class { 'pi::cmdline': | ||
reboot => false, # reboots are problematic for acceptance testing | ||
parameters => { | ||
'coherent_pool=1M' => {}, | ||
'bcm2708_fb.fbwidth=0' => {}, | ||
'bcm2708_fb.fbswap=1' => {}, | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
(* /boot/cmdline.txt module for Augeas *) | ||
|
||
module Boot_Cmdline = | ||
autoload xfm | ||
|
||
let word = /[^ \n\t]+/ | ||
let cmdline = [ seq "cmdline" . Util.indent . | ||
[ label "parameter" . store word ] . | ||
[ label "parameter" . Sep.space . store word ]* | ||
. Util.eol ] | ||
|
||
let lns = cmdline | ||
|
||
let xfm = transform lns (incl "/boot/cmdline.txt") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# | ||
# @summary Manages /boot/cmdline.txt parameters. | ||
# | ||
# @param parameters | ||
# A hash of pi::cmdline::parameter resources to create. | ||
# | ||
# @param reboot | ||
# Whether or not to force a reboot when `/boot/cmdline.txt` parameters change. | ||
# | ||
class pi::cmdline ( | ||
Hash[String[1], Hash] $parameters = {}, | ||
Boolean $reboot = true, | ||
) { | ||
augeas::lens { 'boot_cmdline': | ||
lens_content => file("${module_name}/boot_cmdline.aug"), | ||
} | ||
|
||
$parameters.each | String $name, Hash $conf | { | ||
pi::cmdline::parameter { $name: | ||
* => $conf, | ||
} | ||
} | ||
|
||
if ($reboot) { | ||
reboot { '/boot/cmdline.txt': | ||
apply => finished, | ||
message => 'Rebooting to apply /boot/config.txt changes', | ||
when => refreshed, | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# @summary | ||
# Manage a single /boot/cmdline.txt kernel parameter | ||
# | ||
# @param parameter | ||
# The kernel parameter to manage. E.g. 8250.nr_uarts=1 | ||
# | ||
# Note that the management of parameters is not very intelligent. | ||
# 8250.nr_uarts=1 and 8250.nr_uarts=2 would be treated as two different | ||
# parameters. | ||
# | ||
define pi::cmdline::parameter ( | ||
Optional[String[1]] $parameter = undef, | ||
) { | ||
include pi::cmdline | ||
|
||
$_real_parameter = $parameter ? { | ||
undef => $name, | ||
default => $parameter, | ||
} | ||
|
||
augeas { $name: | ||
context => '/files/boot/cmdline.txt/1', | ||
lens => 'Boot_Cmdline.lns', | ||
incl => '/boot/cmdline.txt', | ||
changes => [ | ||
"set parameter[. = '${_real_parameter}'] '${_real_parameter}'", | ||
], | ||
require => Augeas::Lens['boot_cmdline'], | ||
} | ||
|
||
if Class['pi::cmdline']['reboot'] { | ||
Augeas[$name] ~> Reboot['/boot/cmdline.txt'] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# @summary | ||
# Manages `/boot/config.txt` | ||
# | ||
# @param fragments | ||
# A hash of profile::pi::config::fragments to be concatenated into | ||
# `/boot/config.txt`. | ||
# | ||
# @param reboot | ||
# Whether or not to force a reboot when `/boot/config.txt` changes. | ||
# | ||
class pi::config ( | ||
Hash[String[1], Hash] $fragments = {}, | ||
Boolean $reboot = true, | ||
) { | ||
concat { '/boot/config.txt': | ||
ensure => present, | ||
mode => '0755', # this is the default, +x seems odd | ||
} | ||
|
||
$fragments.each | String $name, Hash $conf | { | ||
pi::config::fragment { $name: | ||
* => $conf, | ||
} | ||
} | ||
|
||
if ($reboot) { | ||
reboot { '/boot/config.txt': | ||
apply => finished, | ||
message => 'Rebooting to apply /boot/config.txt changes', | ||
when => refreshed, | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# @summary | ||
# Create a /boot/config.txt fragment | ||
# | ||
# @param content | ||
# /boot/config.txt configuration fragment | ||
# | ||
# @param order | ||
# Order of the fragment within /boot/config.txt | ||
# | ||
define pi::config::fragment ( | ||
Optional[String[1]] $content = undef, | ||
Integer[1] $order = 50, | ||
) { | ||
include pi::config | ||
|
||
$_real_content = $content ? { | ||
undef => "${name}\n", | ||
default => $content, | ||
} | ||
|
||
concat::fragment { $name: | ||
target => '/boot/config.txt', | ||
content => $_real_content, | ||
order => $order, | ||
} | ||
|
||
if Class['pi::config']['reboot'] { | ||
Concat::Fragment[$name] ~> Reboot['/boot/config.txt'] | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'spec_helper_acceptance' | ||
|
||
describe 'pi::cmdline::parameter define' do | ||
context 'without any parameters' do | ||
include_context 'cmdline.txt test setup' | ||
include_examples 'the example', 'cmdline_parameter.pp' | ||
|
||
describe file('/boot/cmdline.txt') do | ||
it { is_expected.to be_file } | ||
|
||
%w[ | ||
8250.nr_uarts=0 | ||
coherent_pool=1M | ||
snd_bcm2835.enable_headphones=0 | ||
].each do |param| | ||
its(:content) { is_expected.to match param } | ||
end | ||
end | ||
end | ||
end |
Oops, something went wrong.