bundles/nfs-client: introduce
This commit is contained in:
parent
21da0a7b80
commit
6a8768fb2f
5 changed files with 93 additions and 5 deletions
6
bundles/nfs-client/files/nfs.automount
Normal file
6
bundles/nfs-client/files/nfs.automount
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
[Unit]
|
||||||
|
Description=Automount ${mount} on access
|
||||||
|
|
||||||
|
[Automount]
|
||||||
|
Where=${mountpoint}
|
||||||
|
TimeoutIdleSec=5min
|
14
bundles/nfs-client/files/nfs.mount
Normal file
14
bundles/nfs-client/files/nfs.mount
Normal 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
|
55
bundles/nfs-client/items.py
Normal file
55
bundles/nfs-client/items.py
Normal 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",
|
||||||
|
},
|
||||||
|
}
|
7
bundles/nfs-client/metadata.py
Normal file
7
bundles/nfs-client/metadata.py
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
defaults = {
|
||||||
|
'apt': {
|
||||||
|
'packages': {
|
||||||
|
'nfs-common': {},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
|
@ -2,6 +2,7 @@ nodes['home.kodi-wohnzimmer'] = {
|
||||||
'hostname': '172.19.138.24',
|
'hostname': '172.19.138.24',
|
||||||
'bundles': {
|
'bundles': {
|
||||||
'kodi',
|
'kodi',
|
||||||
|
'nfs-client',
|
||||||
},
|
},
|
||||||
'groups': set(),
|
'groups': set(),
|
||||||
'metadata': {
|
'metadata': {
|
||||||
|
@ -15,11 +16,16 @@ nodes['home.kodi-wohnzimmer'] = {
|
||||||
'mac': '94:C6:91:1E:B8:1F',
|
'mac': '94:C6:91:1E:B8:1F',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
'apt': {
|
'nfs-client': {
|
||||||
'packages': {
|
'mounts': {
|
||||||
# This node mounts the NAS via NFS. Configured manually,
|
'nas-storage': {
|
||||||
# because i'm lazy.
|
'mountpoint': '/mnt/nas',
|
||||||
'nfs-common': {},
|
'serverpath': '172.19.138.20:/storage/nas',
|
||||||
|
'mount_options': {
|
||||||
|
'retry=0',
|
||||||
|
'ro',
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
'vm': {
|
'vm': {
|
||||||
|
|
Loading…
Reference in a new issue