2021-01-17 09:15:49 +00:00
|
|
|
assert not node.has_bundle('apt'), f'{node.name} - bundle:apt is incompatible with ansible managed c3voc hosts'
|
|
|
|
assert not node.has_bundle('nginx'), f'{node.name} - bundle:nginx is incompatible with ansible managed c3voc hosts'
|
|
|
|
assert not node.has_bundle('users'), f'{node.name} - bundle:users is incompatible with ansible managed c3voc hosts'
|
|
|
|
|
2021-01-16 19:57:33 +00:00
|
|
|
pkg_apt = {
|
|
|
|
'apt-transport-https': {},
|
|
|
|
|
|
|
|
'build-essential': {},
|
|
|
|
'curl': {},
|
|
|
|
'git': {},
|
|
|
|
'grep': {},
|
|
|
|
'gzip': {},
|
|
|
|
'htop': {},
|
|
|
|
'jq': {},
|
|
|
|
'less': {},
|
|
|
|
'mtr': {},
|
|
|
|
'ncdu': {},
|
|
|
|
'netcat': {},
|
|
|
|
'python3': {},
|
|
|
|
'python3-dev': {},
|
|
|
|
'python3-pip': {},
|
|
|
|
'python3-virtualenv': {},
|
|
|
|
'rsync': {},
|
|
|
|
'tar': {},
|
|
|
|
'tmux': {},
|
|
|
|
'tree': {},
|
|
|
|
'wget': {},
|
|
|
|
}
|
|
|
|
|
2021-02-18 17:12:25 +00:00
|
|
|
if node.metadata.get('apt/packages', {}):
|
2021-01-16 19:57:33 +00:00
|
|
|
for package, options in node.metadata['apt']['packages'].items():
|
|
|
|
pkg_apt[package] = options
|
|
|
|
|
|
|
|
actions = {
|
|
|
|
'systemd-reload': {
|
|
|
|
'command': 'systemctl daemon-reload',
|
|
|
|
'cascade_skip': False,
|
|
|
|
'triggered': True,
|
|
|
|
'needed_by': {
|
|
|
|
'svc_systemd:',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
directories = {
|
|
|
|
'/etc/nginx/sites-enabled': {
|
|
|
|
'purge': True,
|
|
|
|
'triggers': {
|
|
|
|
'svc_systemd:nginx:restart',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2021-01-17 17:43:30 +00:00
|
|
|
files = {
|
2021-02-12 17:12:24 +00:00
|
|
|
'/etc/kernel/postinst.d/unattended-upgrades': {
|
|
|
|
'source': 'kernel-postinst.d',
|
|
|
|
},
|
2021-01-17 17:43:30 +00:00
|
|
|
'/usr/local/share/icinga/plugins/check_unattended_upgrades': {
|
|
|
|
'mode': '0755',
|
|
|
|
},
|
|
|
|
'/usr/local/sbin/upgrade-and-reboot': {
|
|
|
|
'content_type': 'mako',
|
|
|
|
'mode': '0700',
|
|
|
|
'context': {
|
2021-02-18 17:12:25 +00:00
|
|
|
'data': node.metadata.get('apt/unattended-upgrades', {}),
|
2021-01-17 17:43:30 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2021-01-19 12:34:23 +00:00
|
|
|
for crontab, content in node.metadata.get('cron', {}).items():
|
|
|
|
files['/etc/cron.d/{}'.format(crontab)] = {
|
|
|
|
'source': 'cron_template',
|
|
|
|
'content_type': 'mako',
|
|
|
|
'context': {
|
|
|
|
'cron': content,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-02-18 17:12:25 +00:00
|
|
|
for vhost, config in node.metadata.get('nginx/vhosts', {}).items():
|
2021-01-16 19:57:33 +00:00
|
|
|
if not 'domain' in config:
|
|
|
|
config['domain'] = vhost
|
|
|
|
|
|
|
|
files['/etc/nginx/sites-available/{}'.format(vhost)] = {
|
|
|
|
'source': 'site_template',
|
|
|
|
'content_type': 'mako',
|
|
|
|
'context': {
|
|
|
|
'vhost': vhost,
|
|
|
|
**config,
|
|
|
|
},
|
|
|
|
'triggers': {
|
|
|
|
'svc_systemd:nginx:restart',
|
|
|
|
},
|
|
|
|
}
|
|
|
|
symlinks['/etc/nginx/sites-enabled/{}'.format(vhost)] = {
|
|
|
|
'target': '/etc/nginx/sites-available/{}'.format(vhost),
|
|
|
|
'triggers': {
|
|
|
|
'svc_systemd:nginx:restart',
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
if not 'webroot' in config:
|
|
|
|
directories['/var/www/{}'.format(vhost)] = config.get('webroot_config', {})
|
|
|
|
|
|
|
|
svc_systemd = {
|
|
|
|
'nginx': {},
|
2021-01-17 17:43:30 +00:00
|
|
|
'apt-daily.timer': {
|
|
|
|
'running': False,
|
|
|
|
'enabled': False,
|
|
|
|
},
|
|
|
|
'apt-daily-upgrade.timer': {
|
|
|
|
'running': False,
|
|
|
|
'enabled': False,
|
|
|
|
},
|
2021-01-16 19:57:33 +00:00
|
|
|
}
|