add apt bundle

This commit is contained in:
Franzi 2020-02-29 14:42:29 +00:00
parent e5539d508b
commit ad7b164533
Signed by: kunsi
GPG key ID: 12E3D2136B818350
3 changed files with 96 additions and 0 deletions

View file

@ -0,0 +1,27 @@
Unattended-Upgrade::Origins-Pattern {
"origin=Debian,codename=\$\{distro_codename\},label=Debian";
"origin=Debian,codename=\$\{distro_codename\},label=Debian-Security";
// External packages
% for item in sorted(data.get('origins')):
"origin=${item}";
% endfor
};
Unattended-Upgrade::AutoFixInterruptedDpkg "true";
Unattended-Upgrade::MinimalSteps "true";
% if data.get('mail', None):
Unattended-Upgrade::Mail "${data['mail']}";
Unattended-Upgrade::MailOnlyOnError "false";
% endif
Unattended-Upgrade::Remove-Unused-Kernel-Packages "true";
Unattended-Upgrade::Remove-New-Unused-Dependencies "true";
Unattended-Upgrade::Remove-Unused-Dependencies "true";
% if data.get('reboot', False):
Unattended-Upgrade::Automatic-Reboot "true";
% else:
Unattended-Upgrade::Automatic-Reboot "false";
% endif

68
bundles/apt/items.py Normal file
View file

@ -0,0 +1,68 @@
actions = {
'apt_update': {
'command': 'apt-get update',
'needed_by': [
'pkg_apt:',
],
'triggered': True,
'cascade_skip': False,
},
}
files = {
'/etc/apt/apt.conf.d/50unattended-upgrades': {
'content_type': 'mako',
'source': 'apt.conf-unattended-upgrades',
'context': {'data': node.metadata.get('apt', {}).get('unattended-upgrades', {})}
},
}
directories = {
'/etc/apt/sources.list.d': {},
}
pkg_apt = {
'apt-transport-https': {},
'unattended-upgrades': {},
}
gpg_keys = set()
for name, data in node.metadata.get('apt', {}).get('repos', {}).items():
files['/etc/apt/sources.list.d/{}.list'.format(name)] = {
'content_type': 'mako',
'content': "\n".join(data['items']),
'triggers': [
'action:apt_update',
],
}
if 'key' in data:
gpg_keys.add(data['key'])
files['/etc/apt/sources.list.d/{}.list'.format(name)]['needs'] = [
'action:add_gpg_key_{}'.format(data['key']),
]
previous_action = None
for key in gpg_keys:
files['/etc/apt/gpg-keys/{}'.format(key)] = {
'source': 'gpg-keys/{}'.format(key),
}
action_name = 'add_gpg_key_{}'.format(key)
action_item_name = 'action:' + action_name
actions[action_name] = {
'command': 'apt-key add /etc/apt/gpg-keys/{}'.format(key),
'unless': 'apt-key export {} 2>/dev/null | grep -q "END PGP PUBLIC KEY BLOCK"'.format(key),
'cascade_skip': False,
'needed_by': ["action:apt_update"],
'needs': list(filter(None, [
'file:/etc/apt/gpg-keys/{}'.format(key),
previous_action,
])),
}
previous_action = action_item_name
if node.metadata.get('apt', {}).get('packages', {}):
for package, options in node.metadata['apt']['packages'].items():
pkg_apt[package] = options

View file

@ -3,6 +3,7 @@ groups['all'] = {
r".*",
),
'bundles': {
'apt',
'users',
},
'metadata': {