Skip to content
Snippets Groups Projects
Commit ebdb57bb authored by Thomas Bellman's avatar Thomas Bellman
Browse files

Use systemd Puppet module for systemd unit files.

The systemd module makes it a little bit easier to manage systemd
unit files.  Specifying unit options as a hash is easier than e.g.
having to build a string from a list of lines ourselves.  The module
also creates the /etc/systemd/system/<UNIT>.d directory, and tells
systemd to reload its configuration, without us having to do it.
parent 4730cb4e
No related branches found
No related tags found
No related merge requests found
...@@ -31,6 +31,8 @@ If not, see <http://www.gnu.org/licenses/>. ...@@ -31,6 +31,8 @@ If not, see <http://www.gnu.org/licenses/>.
- bootloader - bootloader
Can be found at https://git.lysator.liu.se/bellman/puppet-bootloader.git. Can be found at https://git.lysator.liu.se/bellman/puppet-bootloader.git.
- systemd
Can be found at https://git.lysator.liu.se/bellman/puppet-systemd.git.
===== OFFICIAL SOURCE ===== ===== OFFICIAL SOURCE =====
......
...@@ -24,25 +24,21 @@ class console::screensaver::disable ...@@ -24,25 +24,21 @@ class console::screensaver::disable
} }
} }
'systemd': { 'systemd': {
$lines = [ systemd::unit {
'# This file is under Puppet control', 'screensaver-disable.service':
'', options => {
'[Unit]', 'Unit' => {
'Description=Disable screensaver on the console', 'Description'=>'Disable screensaver on the console',
'', },
'[Service]', 'Service' => {
'Type=oneshot', 'Type' => 'oneshot',
"ExecStart=/bin/sh -c '${setterm_cmd}'", 'ExecStart' => "/bin/sh -c '${setterm_cmd}'",
'', },
'[Install]', 'Install' => {
'WantedBy=basic.target', 'WantedBy' => 'basic.target',
] },
file { },
'/etc/systemd/system/screensaver-disable.service': notify => Service['screensaver-disable'];
ensure => file,
content => inline_template('<%=@lines.join("\n")+"\n" %>'),
owner => 'root', group => 'root', mode => '0444',
before => Service['screensaver-disable'];
} }
service { service {
'screensaver-disable': 'screensaver-disable':
......
...@@ -97,7 +97,6 @@ define console::serial::login::systemd( ...@@ -97,7 +97,6 @@ define console::serial::login::systemd(
$termtype, $termtype,
) )
{ {
$svcdir = "/etc/systemd/system/serial-getty@${name}.service.d"
# Systemd cmdline quoting is not *exactly* like shell, but close enough. # Systemd cmdline quoting is not *exactly* like shell, but close enough.
$agetty_cmdline = shellquote( $agetty_cmdline = shellquote(
# agetty(8) doc says tty name should be before speeds, but default # agetty(8) doc says tty name should be before speeds, but default
...@@ -108,23 +107,17 @@ define console::serial::login::systemd( ...@@ -108,23 +107,17 @@ define console::serial::login::systemd(
'%I', '%I',
$termtype $termtype
) )
$svc_params_cfg = (
"[Service]\nExecStart=\nExecStart=-${agetty_cmdline}\n"
)
file { systemd::unit_options {
$svcdir: "serial-getty@${name}.service/param":
ensure => $ensure ? { ensure => $ensure ? {
'enabled' => directory, 'disabled' => undef, 'enabled' => 'present', 'disabled' => 'absent',
},
options => {
'Service' => {
'-ExecStart' => "-${agetty_cmdline}",
}, },
owner => 'root', group => 'root', mode => '0755';
"${svcdir}/param.conf":
ensure => $ensure ? {
'enabled' => file, 'disabled' => absent,
}, },
content => $svc_params_cfg,
owner => 'root', group => 'root', mode => '0444',
notify => Service["serial-getty@${name}"]; notify => Service["serial-getty@${name}"];
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment