Skip to content

Commit 607109d

Browse files
authored
Merge pull request #580 from voxpupuli/allow-system-dropins
Add support for system-wide drop-ins
2 parents 3e094de + 3e58139 commit 607109d

File tree

5 files changed

+53
-2
lines changed

5 files changed

+53
-2
lines changed

REFERENCE.md

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
* [`Systemd::Capabilities`](#Systemd--Capabilities): Defines allowed capabilities
6565
* [`Systemd::CoredumpSettings`](#Systemd--CoredumpSettings): Configurations for coredump.conf
6666
* [`Systemd::Dropin`](#Systemd--Dropin): custom datatype that validates filenames/paths for valid systemd dropin files
67+
* [`Systemd::Dropin_unit`](#Systemd--Dropin_unit): Validates a drop-in unit name
6768
* [`Systemd::Interface`](#Systemd--Interface): network interface definition
6869
* [`Systemd::Interface::Link`](#Systemd--Interface--Link): Network device configuration(Link)
6970
* [`Systemd::Interface::Link::Link`](#Systemd--Interface--Link--Link): Network device configuration(Link) Link section definition
@@ -181,6 +182,7 @@
181182
* [`Systemd::Unit::Timer`](#Systemd--Unit--Timer): Possible keys for the [Timer] section of a unit file
182183
* [`Systemd::Unit::Timespan`](#Systemd--Unit--Timespan): Timer specification for systemd time spans, e.g. timers.
183184
* [`Systemd::Unit::Unit`](#Systemd--Unit--Unit): Possible keys for the [Unit] section of a unit file
185+
* [`Systemd::Unit_type`](#Systemd--Unit_type): Validates a unit types
184186

185187
### Tasks
186188

@@ -1016,7 +1018,7 @@ The following parameters are available in the `systemd::dropin_file` defined typ
10161018

10171019
##### <a name="-systemd--dropin_file--unit"></a>`unit`
10181020

1019-
Data type: `Systemd::Unit`
1021+
Data type: `Systemd::Dropin_unit`
10201022

10211023
The target unit file to create
10221024

@@ -3107,6 +3109,15 @@ custom datatype that validates filenames/paths for valid systemd dropin files
31073109

31083110
Alias of `Pattern['^[^/]+\.conf$']`
31093111

3112+
### <a name="Systemd--Dropin_unit"></a>`Systemd::Dropin_unit`
3113+
3114+
Validates a drop-in unit name
3115+
3116+
* **See also**
3117+
* https://www.freedesktop.org/software/systemd/man/systemd.unit.html
3118+
3119+
Alias of `Variant[Systemd::Unit, Systemd::Unit_type]`
3120+
31103121
### <a name="Systemd--Interface"></a>`Systemd::Interface`
31113122

31123123
network interface definition
@@ -6166,6 +6177,15 @@ Struct[{
61666177
}]
61676178
```
61686179

6180+
### <a name="Systemd--Unit_type"></a>`Systemd::Unit_type`
6181+
6182+
Validates a unit types
6183+
6184+
* **See also**
6185+
* https://www.freedesktop.org/software/systemd/man/systemd.unit.html
6186+
6187+
Alias of `Enum['automount', 'device', 'mount', 'path', 'scope', 'service', 'slice', 'socket', 'swap', 'target', 'timer']`
6188+
61696189
## Tasks
61706190

61716191
### <a name="systemctl_show"></a>`systemctl_show`

manifests/dropin_file.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
# @param daemon_reload Call systemd::daemon_reload
2121
#
2222
define systemd::dropin_file (
23-
Systemd::Unit $unit,
23+
Systemd::Dropin_unit $unit,
2424
Systemd::Dropin $filename = $name,
2525
Enum['present', 'absent', 'file'] $ensure = 'present',
2626
Stdlib::Absolutepath $path = '/etc/systemd/system',

spec/defines/dropin_file_spec.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,16 @@
183183
expect(subject).not_to create_systemd__daemon_reload(params[:unit])
184184
}
185185
end
186+
187+
context 'with system dropins' do
188+
let(:params) do
189+
super().merge(unit: 'service')
190+
end
191+
192+
it { is_expected.to compile.with_all_deps }
193+
194+
it { is_expected.to contain_file("/etc/systemd/system/#{params[:unit]}.d/#{title}") }
195+
end
186196
end
187197
end
188198
end

types/dropin_unit.pp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# @summary Validates a drop-in unit name
2+
# @see https://www.freedesktop.org/software/systemd/man/systemd.unit.html
3+
type Systemd::Dropin_unit = Variant[
4+
Systemd::Unit,
5+
Systemd::Unit_type,
6+
]

types/unit_type.pp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# @summary Validates a unit types
2+
# @see https://www.freedesktop.org/software/systemd/man/systemd.unit.html
3+
type Systemd::Unit_type = Enum[
4+
'automount',
5+
'device',
6+
'mount',
7+
'path',
8+
'scope',
9+
'service',
10+
'slice',
11+
'socket',
12+
'swap',
13+
'target',
14+
'timer',
15+
]

0 commit comments

Comments
 (0)