bundlewrap/bundles/nfs-client/items.py

73 lines
2.2 KiB
Python

if node.has_bundle('pacman'):
package = 'pkg_pacman:nfs-utils'
else:
package = 'pkg_apt:nfs-common'
for mount, data in node.metadata.get('nfs-client/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']] = {
'owner': data.get('owner'),
'group': data.get('group'),
'mode': data.get('mode'),
}
if 'suid' not in data['mount_options']:
data['mount_options'].add('nosuid')
if 'hard' not in data['mount_options']:
data['mount_options'].add('soft')
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']),
package,
},
}
else:
files['/etc/systemd/system/{}.automount'.format(unitname)] = {
'delete': True,
'triggers': {
"action:systemd-reload",
},
}
svc_systemd['{}.mount'.format(unitname)] = {
'needs': {
'file:/etc/systemd/system/{}.mount'.format(unitname),
'directory:{}'.format(data['mountpoint']),
package,
},
}
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",
},
}