bundles/nfs-client: introduce

This commit is contained in:
Franzi 2020-10-10 16:37:33 +02:00
parent 21da0a7b80
commit 6a8768fb2f
Signed by: kunsi
GPG key ID: 12E3D2136B818350
5 changed files with 93 additions and 5 deletions

View file

@ -0,0 +1,6 @@
[Unit]
Description=Automount ${mount} on access
[Automount]
Where=${mountpoint}
TimeoutIdleSec=5min

View file

@ -0,0 +1,14 @@
[Unit]
Description=Mount ${mount}
After=network.target
[Mount]
What=${serverpath}
Where=${mountpoint}
Type=nfs
Options=${','.join(sorted(mount_options))}
[Install]
WantedBy=multi-user.target

View file

@ -0,0 +1,55 @@
for mount, data in node.metadata.get('nfs-client',{}).get('mounts',{}).items():
data['mount'] = mount
data['mount_options'] = set(data.get('mount_options', set()))
unitname = data.get('mountpoint','')[1:].replace('-','\\x2d').replace('/','-')
directories[data['mountpoint']] = {}
for parameter in ['mode', 'owner', 'group']:
if parameter in data:
directories[data['mountpoint']][parameter] = data[parameter]
if data.get('automount', True):
data['mount_options'].add('x-systemd.automount')
files['/etc/systemd/system/{}.automount'.format(unitname)] = {
'mode': "0644",
'owner': "root",
'group': "root",
'source': "nfs.automount",
'content_type': 'mako',
'context': data,
'triggers': {
"action:systemd-reload",
},
}
svc_systemd['{}.automount'.format(unitname)] = {
'needs': {
'file:/etc/systemd/system/{}.mount'.format(unitname),
'file:/etc/systemd/system/{}.automount'.format(unitname),
'directory:{}'.format(data['mountpoint']),
'pkg_apt:nfs-common',
},
}
else:
svc_systemd['{}.mount'.format(unitname)] = {
'needs': {
'file:/etc/systemd/system/{}.mount'.format(unitname),
'directory:{}'.format(data['mountpoint']),
'pkg_apt:nfs-common',
},
}
files['/etc/systemd/system/{}.mount'.format(unitname)] = {
'mode': "0644",
'owner': "root",
'group': "root",
'source': "nfs.mount",
'content_type': 'mako',
'context': data,
'triggers': {
"action:systemd-reload",
},
}

View file

@ -0,0 +1,7 @@
defaults = {
'apt': {
'packages': {
'nfs-common': {},
},
},
}

View file

@ -2,6 +2,7 @@ nodes['home.kodi-wohnzimmer'] = {
'hostname': '172.19.138.24',
'bundles': {
'kodi',
'nfs-client',
},
'groups': set(),
'metadata': {
@ -15,11 +16,16 @@ nodes['home.kodi-wohnzimmer'] = {
'mac': '94:C6:91:1E:B8:1F',
},
},
'apt': {
'packages': {
# This node mounts the NAS via NFS. Configured manually,
# because i'm lazy.
'nfs-common': {},
'nfs-client': {
'mounts': {
'nas-storage': {
'mountpoint': '/mnt/nas',
'serverpath': '172.19.138.20:/storage/nas',
'mount_options': {
'retry=0',
'ro',
},
},
},
},
'vm': {