Skip to content

Commit

Permalink
Merge pull request #144 from jordiprats/master
Browse files Browse the repository at this point in the history
systemd::mount
  • Loading branch information
jordiprats authored Jun 19, 2019
2 parents 2eb28eb + 38f1fe3 commit 74c57ab
Show file tree
Hide file tree
Showing 6 changed files with 103 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# CHANGELOG

## 0.2.8

* added define for mounts: **systemd::mount**

## 0.2.7

* configurable restart for **systemd::sysvwrapper**
Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,14 @@ systemd-journald is a system service that collects and stores logging data

### defines

#### systemd::mount

* **what**: Takes an absolute path of a device node, file or other resource to mount. See mount(8) for details. If this refers to a device node, a dependency on the respective device unit is automatically created. (See systemd.device(5) for more information.) This option is mandatory.
* **where**: Takes an absolute path of a directory for the mount point; in particular, the destination cannot be a symbolic link. If the mount point does not exist at the time of mounting, it is created. This string must be reflected in the unit filename. (See above.) This option is mandatory. (default: resource's name)
* **type**: Takes a string for the file system type. See mount(8) for details. This setting is optional.
* **options**: Mount options to use when mounting. This takes a comma-separated list of options. This setting is optional. Note that the usual specifier expansion is applied to this setting, literal percent characters should hence be written as "%%".
(...)

#### systemd::service

* **execstart**: command to start daemon (default: undef)
Expand Down
5 changes: 5 additions & 0 deletions examples/mount_demo.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
systemd::mount { '/boot/efi':
what => '/dev/sda1',
type => 'vfat',
options => [ 'rw', 'relatime', 'fmask=0077', 'dmask=0077', 'codepage=437', 'iocharset=iso8859-1', 'shortname=mixed', 'errors=remount-ro' ],
}
76 changes: 76 additions & 0 deletions manifests/mount.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
#
# [Unit]
# Description=Things devices
# After=network.target
#
# [Mount]
# What=172.16.24.192:/mnt/things
# Where=/mnt/things
# Type=nfs
# Options=_netdev,auto
#
# [Install]
# WantedBy=multi-user.target
#
define systemd::mount(
$what,
$where = $name,
$type = undef,
$options = [],
# install
$also = [],
$default_instance = undef,
$service_alias = [],
$wantedby = [ 'multi-user.target' ],
$requiredby = [],
# unit
$description = undef,
$documentation = undef,
$wants = [],
$after = undef,
$after_units = [],
$before_units = [],
$requires = [],
$binds_to = [],
$conflicts = [],
$on_failure = [],
$partof = undef,
$allow_isolate = undef,
) {
if versioncmp($::puppetversion, '4.0.0') >= 0
{
contain ::systemd
}
else
{
include ::systemd
}

$mount_name = regsubst(regsubst($where, '/', '-', 'G'), '^-', '', '')

concat { "/etc/systemd/system/${mount_name}.mount":
ensure => 'present',
owner => 'root',
group => 'root',
mode => '0644',
notify => Exec['systemctl daemon-reload'],
}

concat::fragment { "mount ${mount_name} unit":
target => "/etc/systemd/system/${mount_name}.mount",
order => '00',
content => template("${module_name}/section/unit.erb"),
}

concat::fragment { "mount ${mount_name} install":
target => "/etc/systemd/system/${mount_name}.mount",
order => '01',
content => template("${module_name}/section/install.erb"),
}

concat::fragment { "mount ${mount_name} mount":
target => "/etc/systemd/system/${mount_name}.mount",
order => '02',
content => template("${module_name}/section/mount.erb"),
}
}
2 changes: 1 addition & 1 deletion metadata.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "eyp-systemd",
"version": "0.2.7",
"version": "0.2.8",
"author": "eyp",
"summary": "management of systemd services, services dropins, sockets, timers, timesyncd, journald, logind and resolved",
"license": "Apache-2.0",
Expand Down
9 changes: 9 additions & 0 deletions templates/section/mount.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[Mount]
What=<%= @what %>
Where=<%= @where %>
<% if defined?(@type) -%>
Type=<%= @type %>
<% end -%>
<% if @options.any? -%>
Options=<%= @options.join(',') %>
<% end -%>

0 comments on commit 74c57ab

Please sign in to comment.