-
-
Notifications
You must be signed in to change notification settings - Fork 143
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 #490 from traylenator/mount
Support Mount units for manage_unit or dropin types
- Loading branch information
Showing
8 changed files
with
210 additions
and
0 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 |
---|---|---|
|
@@ -67,6 +67,7 @@ | |
* [`Systemd::Unit::Amount`](#Systemd--Unit--Amount): Systemd definition of amount, often bytes or united bytes | ||
* [`Systemd::Unit::AmountOrPercent`](#Systemd--Unit--AmountOrPercent): Systemd definition of amount, often bytes or united bytes | ||
* [`Systemd::Unit::Install`](#Systemd--Unit--Install): Possible keys for the [Install] section of a unit file | ||
* [`Systemd::Unit::Mount`](#Systemd--Unit--Mount): Possible keys for the [Mount] section of a unit file | ||
* [`Systemd::Unit::Path`](#Systemd--Unit--Path): Possible keys for the [Path] section of a unit file | ||
* [`Systemd::Unit::Percent`](#Systemd--Unit--Percent): Systemd definition of a percentage | ||
* [`Systemd::Unit::Service`](#Systemd--Unit--Service): Possible keys for the [Service] section of a unit file | ||
|
@@ -1031,6 +1032,7 @@ The following parameters are available in the `systemd::manage_dropin` defined t | |
* [`timer_entry`](#-systemd--manage_dropin--timer_entry) | ||
* [`path_entry`](#-systemd--manage_dropin--path_entry) | ||
* [`socket_entry`](#-systemd--manage_dropin--socket_entry) | ||
* [`mount_entry`](#-systemd--manage_dropin--mount_entry) | ||
|
||
##### <a name="-systemd--manage_dropin--unit"></a>`unit` | ||
|
||
|
@@ -1174,6 +1176,14 @@ key value pairs for the [Socket] section of the unit file | |
|
||
Default value: `undef` | ||
|
||
##### <a name="-systemd--manage_dropin--mount_entry"></a>`mount_entry` | ||
|
||
Data type: `Optional[Systemd::Unit::Mount]` | ||
|
||
key value pairs for the [Mount] section of the unit file | ||
|
||
Default value: `undef` | ||
|
||
### <a name="systemd--manage_unit"></a>`systemd::manage_unit` | ||
|
||
Generate unit file from template | ||
|
@@ -1251,6 +1261,30 @@ systemd::manage_unit{'[email protected]': | |
} | ||
``` | ||
|
||
##### Mount a Filesystem and Use for a Service | ||
|
||
```puppet | ||
systemd::manage_unit { 'var-lib-sss-db.mount': | ||
ensure => present, | ||
unit_entry => { | ||
'Description' => 'Mount sss tmpfs db', | ||
}, | ||
mount_entry => { | ||
'What' => 'tmpfs', | ||
'Where' => '/var/lib/sss/db', | ||
'Type' => 'tmpfs', | ||
'Options' => 'size=300M,mode=0700,uid=sssd,gid=sssd,rootcontext=system_u:object_r:sssd_var_lib_t:s0', | ||
}, | ||
} | ||
systemd::manage_dropin { 'tmpfs-db.conf': | ||
ensure => present, | ||
unit => 'sssd.service', | ||
unit_entry => { | ||
'RequiresMountsFor' => '/var/lib/sss/db', | ||
}, | ||
} | ||
``` | ||
|
||
##### Remove a unit file | ||
|
||
```puppet | ||
|
@@ -1284,6 +1318,7 @@ The following parameters are available in the `systemd::manage_unit` defined typ | |
* [`timer_entry`](#-systemd--manage_unit--timer_entry) | ||
* [`path_entry`](#-systemd--manage_unit--path_entry) | ||
* [`socket_entry`](#-systemd--manage_unit--socket_entry) | ||
* [`mount_entry`](#-systemd--manage_unit--mount_entry) | ||
|
||
##### <a name="-systemd--manage_unit--name"></a>`name` | ||
|
||
|
@@ -1451,6 +1486,14 @@ kev value paors for [Socket] section of the unit file. | |
|
||
Default value: `undef` | ||
|
||
##### <a name="-systemd--manage_unit--mount_entry"></a>`mount_entry` | ||
|
||
Data type: `Optional[Systemd::Unit::Mount]` | ||
|
||
kev value pairs for [Mount] section of the unit file. | ||
|
||
Default value: `undef` | ||
|
||
### <a name="systemd--modules_load"></a>`systemd::modules_load` | ||
|
||
Creates a modules-load.d drop file | ||
|
@@ -2798,6 +2841,30 @@ Struct[{ | |
}] | ||
``` | ||
|
||
### <a name="Systemd--Unit--Mount"></a>`Systemd::Unit::Mount` | ||
|
||
Possible keys for the [Mount] section of a unit file | ||
|
||
* **See also** | ||
* https://www.freedesktop.org/software/systemd/man/latest/systemd.mount.html | ||
|
||
Alias of | ||
|
||
```puppet | ||
Struct[{ | ||
Optional['What'] => String[1], | ||
Optional['Where'] => Stdlib::Unixpath, | ||
Optional['Type'] => String[1], | ||
Optional['Options'] => String[1], | ||
Optional['SloppyOptions'] => Boolean, | ||
Optional['LazyUnmount'] => Boolean, | ||
Optional['ReadWriteOnly'] => Boolean, | ||
Optional['ForceUnmount'] => Boolean, | ||
Optional['DirectoryMode'] => Stdlib::Filemode, | ||
Optional['TimeoutSec'] => String[0], | ||
}] | ||
``` | ||
|
||
### <a name="Systemd--Unit--Path"></a>`Systemd::Unit::Path` | ||
|
||
Possible keys for the [Path] section of a unit file | ||
|
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
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,42 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'spec_helper' | ||
|
||
describe 'Systemd::Unit::Mount' do | ||
context 'with a key of What can have thing to mount' do | ||
it { is_expected.to allow_value({ 'What' => 'tmpfs' }) } | ||
it { is_expected.to allow_value({ 'What' => 'nfs://example.org/exports/home' }) } | ||
it { is_expected.to allow_value({ 'What' => '/dev/vda1' }) } | ||
end | ||
|
||
context 'with a key of Where can have a path to mount on' do | ||
it { is_expected.to allow_value({ 'Where' => '/mnt/foo' }) } | ||
it { is_expected.to allow_value({ 'Where' => '/mnt/foo/file.txt' }) } | ||
end | ||
|
||
context 'with a key of Type can have a path to mount on' do | ||
it { is_expected.to allow_value({ 'Type' => 'tmpfs' }) } | ||
it { is_expected.to allow_value({ 'Type' => 'ext2' }) } | ||
end | ||
|
||
context 'with a key of Options can have a path to mount on' do | ||
it { is_expected.to allow_value({ 'Options' => 'size=300M,mode=0700,uid=sssd,gid=sssd,root' }) } | ||
end | ||
|
||
context 'with a key of DirectoryMode can have a mode of' do | ||
it { is_expected.to allow_value({ 'DirectoryMode' => '0700' }) } | ||
end | ||
|
||
context 'with a key of TimeoutSec can have a mode of' do | ||
it { is_expected.to allow_value({ 'TimeoutSec' => '100' }) } | ||
it { is_expected.to allow_value({ 'TimeoutSec' => '5min 20s' }) } | ||
it { is_expected.to allow_value({ 'TimeoutSec' => '' }) } | ||
end | ||
|
||
%w[SloppyOptions LazyUnmount ReadWriteOnly ForceUnmount].each do |assert| | ||
context "with a key of #{assert} can have values of a path" do | ||
it { is_expected.to allow_value({ assert => false }) } | ||
it { is_expected.to allow_value({ assert => true }) } | ||
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
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,17 @@ | ||
# @summary Possible keys for the [Mount] section of a unit file | ||
# @see https://www.freedesktop.org/software/systemd/man/latest/systemd.mount.html | ||
# | ||
type Systemd::Unit::Mount = Struct[ | ||
{ | ||
Optional['What'] => String[1], | ||
Optional['Where'] => Stdlib::Unixpath, | ||
Optional['Type'] => String[1], | ||
Optional['Options'] => String[1], | ||
Optional['SloppyOptions'] => Boolean, | ||
Optional['LazyUnmount'] => Boolean, | ||
Optional['ReadWriteOnly'] => Boolean, | ||
Optional['ForceUnmount'] => Boolean, | ||
Optional['DirectoryMode'] => Stdlib::Filemode, | ||
Optional['TimeoutSec'] => String[0], | ||
} | ||
] |