-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add pi::cmdline & pi::cmdline::parameter
- Loading branch information
Showing
10 changed files
with
103 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,5 @@ | |
--- | ||
fixtures: | ||
forge_modules: | ||
stdlib: "camptocamp/augeas" | ||
augeas: camptocamp/augeas | ||
reboot: puppetlabs/reboot |
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,3 @@ | ||
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,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,8 @@ | ||
# | ||
# @summary Manages /boot/cmdline.txt parameters. | ||
# | ||
class pi::cmdline { | ||
augeas::lens { 'boot_cmdline': | ||
lens_content => file("${module_name}/boot_cmdline.aug"), | ||
} | ||
} |
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 | ||
# 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'], | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'spec_helper_acceptance' | ||
|
||
describe 'pi::cmdline::parameter define' do | ||
context 'without any parameters' do | ||
before(:context) do | ||
shell('mkdir -p /boot') | ||
create_remote_file('default', '/boot/cmdline.txt', 'console=serial0,115200 console=tty1 root=PARTUUID=4a435670-02 rootfstype=ext4 fsck.repair=yes rootwait quiet splash plymouth.ignore-serial-consoles') | ||
end | ||
|
||
include_examples 'the example', 'cmdline.pp' | ||
|
||
describe file('/boot/cmdline.txt') do | ||
it { is_expected.to be_file } | ||
end | ||
end | ||
end |
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,13 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'spec_helper_acceptance' | ||
|
||
describe 'pi::cmdline class' do | ||
context 'without any parameters' do | ||
include_examples 'the example', 'cmdline.pp' | ||
|
||
describe file('/opt/puppetlabs/puppet/share/augeas/lenses/boot_cmdline.aug') do | ||
it { is_expected.to be_file } | ||
end | ||
end | ||
end |
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 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'spec_helper' | ||
|
||
describe 'pi::cmdline' do | ||
on_supported_os.each do |os, os_facts| | ||
context "on #{os}" do | ||
# camptocamp/augeas 1.9.0 is using legacy facts | ||
let(:facts) { override_facts(os_facts, osfamily: os_facts[:os]['family']) } | ||
|
||
it { is_expected.to compile.with_all_deps } | ||
end | ||
end | ||
end |