2021-03-11 14:23:47 +00:00
|
|
|
if node.has_bundle('pacman'):
|
|
|
|
package = 'pkg_pacman:nfs-utils'
|
|
|
|
else:
|
|
|
|
package = 'pkg_apt:nfs-common'
|
|
|
|
|
2021-02-18 17:12:25 +00:00
|
|
|
for mount, data in node.metadata.get('nfs-client/mounts',{}).items():
|
2020-10-10 14:37:33 +00:00
|
|
|
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']] = {
|
2022-04-27 03:39:34 +00:00
|
|
|
'owner': data.get('owner'),
|
|
|
|
'group': data.get('group'),
|
|
|
|
'mode': data.get('mode'),
|
2020-11-15 12:32:10 +00:00
|
|
|
}
|
2020-10-10 14:37:33 +00:00
|
|
|
|
2022-02-20 18:44:05 +00:00
|
|
|
if 'suid' not in data['mount_options']:
|
|
|
|
data['mount_options'].add('nosuid')
|
|
|
|
|
|
|
|
if 'hard' not in data['mount_options']:
|
|
|
|
data['mount_options'].add('soft')
|
|
|
|
|
2020-10-10 14:37:33 +00:00
|
|
|
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']),
|
2022-07-10 11:32:11 +00:00
|
|
|
'svc_systemd:systemd-networkd',
|
2021-03-11 14:23:47 +00:00
|
|
|
package,
|
2020-10-10 14:37:33 +00:00
|
|
|
},
|
|
|
|
}
|
|
|
|
else:
|
2022-04-27 03:39:34 +00:00
|
|
|
files['/etc/systemd/system/{}.automount'.format(unitname)] = {
|
|
|
|
'delete': True,
|
|
|
|
'triggers': {
|
|
|
|
"action:systemd-reload",
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2020-10-10 14:37:33 +00:00
|
|
|
svc_systemd['{}.mount'.format(unitname)] = {
|
|
|
|
'needs': {
|
|
|
|
'file:/etc/systemd/system/{}.mount'.format(unitname),
|
|
|
|
'directory:{}'.format(data['mountpoint']),
|
2022-07-10 11:32:11 +00:00
|
|
|
'svc_systemd:systemd-networkd',
|
2021-03-11 14:23:47 +00:00
|
|
|
package,
|
2020-10-10 14:37:33 +00:00
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
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",
|
|
|
|
},
|
|
|
|
}
|