bundlewrap/bundles/users/items.py

46 lines
1.1 KiB
Python
Raw Normal View History

2020-02-29 12:30:21 +00:00
directories = {}
users = {}
files = {}
groups = {}
pkg_apt = {
'fish': {},
'tmux': {},
}
2020-02-29 12:38:27 +00:00
users['root'] = {
'home': '/root',
'shell': '/bin/bash',
'password': repo.vault.human_password_for('root on {}'.format(node.name)),
}
2020-02-29 12:30:21 +00:00
for username, attrs in node.metadata['users'].items():
home = attrs.get('home', '/home/{}'.format(username))
if attrs.get('delete', False):
users[username] = {'delete': True}
directories[home] = {'delete': True}
else:
user = users.setdefault(username, {})
user['home'] = home
user['shell'] = attrs.get('shell', '/usr/bin/fish')
user['password'] = repo.vault.human_password_for('user {} on {}'.format(username, node.name))
2020-02-29 12:38:27 +00:00
if 'groups' in attrs:
user['groups'] = attrs['groups']
2020-02-29 12:30:21 +00:00
directories[home] = {
'owner': username,
'mode': '0700',
}
if 'ssh_pubkey' in attrs:
files[home + '/.ssh/authorized_keys'] = {
'content': "\n".join(attrs['ssh_pubkey']),
'owner': username,
'mode': '0600',
}