2020-10-10 14:37:33 +00:00
|
|
|
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('/','-')
|
|
|
|
|
2020-11-15 12:32:10 +00:00
|
|
|
directories[data['mountpoint']] = {
|
|
|
|
'owner': None,
|
|
|
|
'group': None,
|
|
|
|
'mode': None,
|
|
|
|
}
|
2020-10-10 14:37:33 +00:00
|
|
|
|
|
|
|
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',
|
|
|
|
},
|
2020-11-29 11:06:34 +00:00
|
|
|
'running': None, # does not exist for automount units
|
2020-10-10 14:37:33 +00:00
|
|
|
}
|
|
|
|
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",
|
|
|
|
},
|
|
|
|
}
|