2020-08-29 19:10:22 +00:00
|
|
|
supported_os = {
|
|
|
|
'debian': {
|
|
|
|
10: 'buster',
|
2020-11-12 17:40:19 +00:00
|
|
|
11: 'bullseye',
|
2020-10-09 16:12:49 +00:00
|
|
|
99: 'unstable',
|
2020-08-29 19:10:22 +00:00
|
|
|
},
|
2020-10-03 16:36:29 +00:00
|
|
|
'raspbian': {
|
|
|
|
10: 'buster',
|
|
|
|
},
|
2020-08-29 19:10:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
assert supported_os[node.os][node.os_version[0]], '{}: OS {} {} is not supported by bundle:apt'.format(node.name, node.os, node.os_version)
|
|
|
|
|
|
|
|
|
2020-02-29 14:42:29 +00:00
|
|
|
actions = {
|
|
|
|
'apt_update': {
|
|
|
|
'command': 'apt-get update',
|
2020-08-20 08:59:45 +00:00
|
|
|
'needed_by': {
|
2020-02-29 14:42:29 +00:00
|
|
|
'pkg_apt:',
|
2020-08-20 08:59:45 +00:00
|
|
|
},
|
2020-02-29 14:42:29 +00:00
|
|
|
'triggered': True,
|
|
|
|
'cascade_skip': False,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
files = {
|
2020-11-10 08:50:20 +00:00
|
|
|
'/usr/local/share/icinga/plugins/check_unattended_upgrades': {
|
|
|
|
'mode': '0755',
|
|
|
|
},
|
2020-10-18 13:33:41 +00:00
|
|
|
'/usr/local/sbin/upgrade-and-reboot': {
|
2020-02-29 14:42:29 +00:00
|
|
|
'content_type': 'mako',
|
2020-10-18 13:33:41 +00:00
|
|
|
'mode': '0700',
|
2020-08-29 19:10:22 +00:00
|
|
|
'context': {
|
2021-04-02 06:11:17 +00:00
|
|
|
'clean_old_kernels': node.metadata.get('apt/clean_old_kernels', True),
|
2021-02-18 17:12:25 +00:00
|
|
|
'data': node.metadata.get('apt/unattended-upgrades', {}),
|
2021-04-02 06:12:51 +00:00
|
|
|
'restart_triggers': node.metadata.get('apt/restart_triggers', {}),
|
2020-08-29 19:10:22 +00:00
|
|
|
}
|
2020-02-29 14:42:29 +00:00
|
|
|
},
|
2020-08-20 09:07:18 +00:00
|
|
|
'/etc/cloud': {
|
|
|
|
'delete': True,
|
|
|
|
},
|
|
|
|
'/etc/netplan': {
|
|
|
|
'delete': True,
|
|
|
|
},
|
|
|
|
'/var/lib/cloud': {
|
|
|
|
'delete': True,
|
|
|
|
},
|
2020-08-29 19:10:22 +00:00
|
|
|
'/etc/apt/sources.list': {
|
2020-10-03 16:36:29 +00:00
|
|
|
'source': 'sources.list-{}-{}'.format(node.os, supported_os[node.os][node.os_version[0]]),
|
|
|
|
'triggers': {
|
|
|
|
'action:apt_update',
|
|
|
|
},
|
2020-08-29 19:10:22 +00:00
|
|
|
},
|
2021-02-12 17:12:24 +00:00
|
|
|
'/etc/kernel/postinst.d/unattended-upgrades': {
|
|
|
|
'source': 'kernel-postinst.d',
|
2021-03-27 07:31:29 +00:00
|
|
|
'mode': '0755',
|
2021-02-12 17:12:24 +00:00
|
|
|
},
|
2020-02-29 14:42:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
directories = {
|
2020-08-29 19:10:22 +00:00
|
|
|
'/etc/apt/sources.list.d': {
|
|
|
|
'purge': True,
|
2020-10-03 16:36:29 +00:00
|
|
|
'triggers': {
|
|
|
|
'action:apt_update',
|
|
|
|
},
|
2020-08-29 19:10:22 +00:00
|
|
|
},
|
2020-02-29 14:42:29 +00:00
|
|
|
}
|
|
|
|
|
2020-11-12 14:10:59 +00:00
|
|
|
svc_systemd = {
|
|
|
|
'apt-daily.timer': {
|
|
|
|
'running': False,
|
|
|
|
'enabled': False,
|
|
|
|
},
|
|
|
|
'apt-daily-upgrade.timer': {
|
|
|
|
'running': False,
|
|
|
|
'enabled': False,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2020-02-29 14:42:29 +00:00
|
|
|
pkg_apt = {
|
|
|
|
'apt-transport-https': {},
|
2020-08-18 13:46:42 +00:00
|
|
|
|
|
|
|
'arping': {},
|
|
|
|
'at': {},
|
2020-10-16 17:12:26 +00:00
|
|
|
'build-essential': {},
|
2020-08-18 13:46:42 +00:00
|
|
|
'bzip2': {},
|
|
|
|
'curl': {},
|
|
|
|
'diffutils': {},
|
|
|
|
'dnsutils': {},
|
2020-10-16 17:12:26 +00:00
|
|
|
'git': {},
|
2020-08-18 13:46:42 +00:00
|
|
|
'grep': {},
|
|
|
|
'gzip': {},
|
|
|
|
'htop': {},
|
|
|
|
'jq': {},
|
|
|
|
'less': {},
|
|
|
|
'logrotate': {},
|
|
|
|
'lsof': {},
|
|
|
|
'mailutils': {},
|
|
|
|
'manpages': {},
|
|
|
|
'moreutils': {},
|
|
|
|
'mount': {},
|
|
|
|
'mtr': {},
|
|
|
|
'ncdu': {},
|
|
|
|
'netcat': {},
|
|
|
|
'nmap': {},
|
|
|
|
'python3': {},
|
2020-10-16 17:14:15 +00:00
|
|
|
'python3-dev': {},
|
2020-09-06 10:04:56 +00:00
|
|
|
'python3-pip': {},
|
|
|
|
'python3-virtualenv': {},
|
2020-11-13 11:37:26 +00:00
|
|
|
'rsync': {},
|
2020-08-18 13:46:42 +00:00
|
|
|
'tar': {},
|
|
|
|
'tcpdump': {},
|
|
|
|
'telnet': {},
|
|
|
|
'tmux': {},
|
|
|
|
'tree': {},
|
|
|
|
'unzip': {},
|
2021-02-18 13:23:43 +00:00
|
|
|
'vim': {},
|
2020-08-18 13:46:42 +00:00
|
|
|
'wget': {},
|
|
|
|
'whois': {},
|
|
|
|
'zip': {},
|
2020-08-20 09:07:18 +00:00
|
|
|
|
|
|
|
'cloud-init': {
|
|
|
|
'installed': False,
|
|
|
|
},
|
|
|
|
'netplan.io': {
|
|
|
|
'installed': False,
|
|
|
|
},
|
2020-08-30 09:14:31 +00:00
|
|
|
'popularity-contest': {
|
|
|
|
'installed': False,
|
|
|
|
},
|
2020-10-18 13:33:41 +00:00
|
|
|
'unattended-upgrades': {
|
|
|
|
'installed': False,
|
|
|
|
},
|
2020-02-29 14:42:29 +00:00
|
|
|
}
|
|
|
|
|
2020-08-20 09:07:18 +00:00
|
|
|
|
2021-02-18 17:12:25 +00:00
|
|
|
for name, data in node.metadata.get('apt/repos', {}).items():
|
2020-02-29 14:42:29 +00:00
|
|
|
files['/etc/apt/sources.list.d/{}.list'.format(name)] = {
|
|
|
|
'content_type': 'mako',
|
2020-08-30 10:06:19 +00:00
|
|
|
'content': ("\n".join(sorted(data['items']))).format(
|
|
|
|
os=node.os,
|
|
|
|
os_release=supported_os[node.os][node.os_version[0]],
|
|
|
|
),
|
2020-08-20 08:59:45 +00:00
|
|
|
'triggers': {
|
2020-02-29 14:42:29 +00:00
|
|
|
'action:apt_update',
|
2020-08-20 08:59:45 +00:00
|
|
|
},
|
2020-02-29 14:42:29 +00:00
|
|
|
}
|
|
|
|
|
2020-08-20 08:59:45 +00:00
|
|
|
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),
|
|
|
|
}
|
2020-02-29 14:42:29 +00:00
|
|
|
|
2020-08-20 08:59:45 +00:00
|
|
|
files['/etc/apt/trusted.gpg.d/{}.list.asc'.format(name)] = {
|
|
|
|
'source': 'gpg-keys/{}.asc'.format(name),
|
|
|
|
'triggers': {
|
|
|
|
'action:apt_update',
|
|
|
|
},
|
|
|
|
}
|
2020-02-29 14:42:29 +00:00
|
|
|
|
2021-02-18 17:12:25 +00:00
|
|
|
if node.metadata.get('apt/packages', {}):
|
2020-02-29 14:42:29 +00:00
|
|
|
for package, options in node.metadata['apt']['packages'].items():
|
|
|
|
pkg_apt[package] = options
|