bundlewrap/bundles/apt/items.py

156 lines
3.4 KiB
Python

supported_os = {
'debian': {
10: 'buster',
11: 'bullseye',
99: 'unstable',
},
'raspbian': {
10: 'buster',
},
}
assert supported_os[node.os][node.os_version[0]], '{}: OS {} {} is not supported by bundle:apt'.format(node.name, node.os, node.os_version)
actions = {
'apt_update': {
'command': 'apt-get update',
'needed_by': {
'pkg_apt:',
},
'triggered': True,
'cascade_skip': False,
},
}
files = {
'/usr/local/share/icinga/plugins/check_unattended_upgrades': {
'mode': '0755',
},
'/usr/local/sbin/upgrade-and-reboot': {
'content_type': 'mako',
'mode': '0700',
'context': {
'data': node.metadata.get('apt', {}).get('unattended-upgrades', {}),
}
},
'/etc/cloud': {
'delete': True,
},
'/etc/netplan': {
'delete': True,
},
'/var/lib/cloud': {
'delete': True,
},
'/etc/apt/sources.list': {
'source': 'sources.list-{}-{}'.format(node.os, supported_os[node.os][node.os_version[0]]),
'triggers': {
'action:apt_update',
},
},
}
directories = {
'/etc/apt/sources.list.d': {
'purge': True,
'triggers': {
'action:apt_update',
},
},
}
svc_systemd = {
'apt-daily.timer': {
'running': False,
'enabled': False,
},
'apt-daily-upgrade.timer': {
'running': False,
'enabled': False,
},
}
pkg_apt = {
'apt-transport-https': {},
'arping': {},
'at': {},
'build-essential': {},
'bzip2': {},
'curl': {},
'diffutils': {},
'dnsutils': {},
'git': {},
'grep': {},
'gzip': {},
'htop': {},
'jq': {},
'less': {},
'logrotate': {},
'lsof': {},
'mailutils': {},
'manpages': {},
'molly-guard': {},
'moreutils': {},
'mount': {},
'mtr': {},
'ncdu': {},
'netcat': {},
'nmap': {},
'python3': {},
'python3-dev': {},
'python3-pip': {},
'python3-virtualenv': {},
'tar': {},
'tcpdump': {},
'telnet': {},
'tmux': {},
'tree': {},
'unzip': {},
'wget': {},
'whois': {},
'zip': {},
'cloud-init': {
'installed': False,
},
'netplan.io': {
'installed': False,
},
'popularity-contest': {
'installed': False,
},
'unattended-upgrades': {
'installed': False,
},
}
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(sorted(data['items']))).format(
os=node.os,
os_release=supported_os[node.os][node.os_version[0]],
),
'triggers': {
'action:apt_update',
},
}
if data.get('install_gpg_key', True):
files['/etc/apt/sources.list.d/{}.list'.format(name)]['needs'] = {
'file:/etc/apt/trusted.gpg.d/{}.list.asc'.format(name),
}
files['/etc/apt/trusted.gpg.d/{}.list.asc'.format(name)] = {
'source': 'gpg-keys/{}.asc'.format(name),
'triggers': {
'action:apt_update',
},
}
if node.metadata.get('apt', {}).get('packages', {}):
for package, options in node.metadata['apt']['packages'].items():
pkg_apt[package] = options