2020-11-21 20:46:41 +00:00
|
|
|
from json import loads
|
|
|
|
from os.path import join
|
|
|
|
|
2021-03-21 09:30:04 +00:00
|
|
|
from bundlewrap.metadata import atomic
|
|
|
|
|
2020-11-10 11:40:12 +00:00
|
|
|
defaults = {
|
|
|
|
'apt': {
|
|
|
|
'repos': {
|
|
|
|
'icinga2': {
|
|
|
|
'items': {
|
|
|
|
'deb http://packages.icinga.com/{os} icinga-{os_release} main',
|
|
|
|
'deb-src http://packages.icinga.com/{os} icinga-{os_release} main',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2020-11-10 13:26:07 +00:00
|
|
|
'packages': {
|
2020-11-13 12:19:26 +00:00
|
|
|
'icinga2': {},
|
|
|
|
'icinga2-ido-pgsql': {},
|
|
|
|
'icingaweb2': {},
|
2023-09-09 11:55:16 +00:00
|
|
|
'python3-easysnmp': {},
|
2024-04-20 16:30:39 +00:00
|
|
|
'python3-flask': {},
|
2023-09-09 15:02:51 +00:00
|
|
|
'snmp': {},
|
2020-11-10 13:26:07 +00:00
|
|
|
}
|
2020-11-10 11:40:12 +00:00
|
|
|
},
|
2020-11-21 09:29:36 +00:00
|
|
|
'icinga2': {
|
|
|
|
'api_users': {
|
2020-12-20 08:33:17 +00:00
|
|
|
'root': {
|
|
|
|
'password': repo.vault.password_for(f'{node.name} icinga2 api root'),
|
|
|
|
'permissions': {
|
|
|
|
'*',
|
|
|
|
},
|
|
|
|
},
|
2020-11-21 09:29:36 +00:00
|
|
|
},
|
|
|
|
},
|
2020-11-22 10:38:53 +00:00
|
|
|
'icinga2_api': {
|
|
|
|
'icinga2': {
|
|
|
|
'services': {
|
|
|
|
'SIPGATE ACCOUNT BALANCE': {
|
|
|
|
'check_command': 'check_sipgate_account_balance',
|
|
|
|
'check_interval': '30m',
|
2020-11-22 10:44:09 +00:00
|
|
|
'vars.notification.mail': True,
|
2020-11-22 10:38:53 +00:00
|
|
|
},
|
2021-03-01 14:36:29 +00:00
|
|
|
'IDO-PGSQL': {
|
|
|
|
'check_command': 'ido',
|
|
|
|
'vars.ido_type': 'IdoPgsqlConnection',
|
|
|
|
'vars.ido_name': 'ido-pgsql',
|
|
|
|
'vars.ido_pending_queries_warning': 25,
|
|
|
|
'vars.ido_pending_queries_critical': 50,
|
|
|
|
},
|
2020-11-22 10:38:53 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2020-11-21 07:57:46 +00:00
|
|
|
'icingaweb2': {
|
|
|
|
'setup-token': repo.vault.password_for(f'{node.name} icingaweb2 setup-token'),
|
|
|
|
},
|
2023-09-09 11:55:16 +00:00
|
|
|
'php': {
|
|
|
|
'version': '8.2',
|
|
|
|
'packages': {
|
|
|
|
'curl',
|
|
|
|
'gd',
|
|
|
|
'intl',
|
|
|
|
'imagick',
|
|
|
|
'ldap',
|
|
|
|
'mysql',
|
|
|
|
'opcache',
|
|
|
|
'pgsql',
|
|
|
|
'readline',
|
|
|
|
'xml',
|
|
|
|
},
|
|
|
|
},
|
2020-11-10 11:40:12 +00:00
|
|
|
'postgresql': {
|
|
|
|
'roles': {
|
|
|
|
'icinga2': {
|
|
|
|
'password': repo.vault.password_for(f'{node.name} postgresql icinga2'),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
'databases': {
|
2020-11-21 07:57:46 +00:00
|
|
|
'icingaweb2': {
|
|
|
|
'owner': 'icinga2',
|
|
|
|
},
|
2020-11-10 11:40:12 +00:00
|
|
|
'icinga2': {
|
|
|
|
'owner': 'icinga2',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
2020-11-21 20:46:41 +00:00
|
|
|
|
2021-04-23 17:31:28 +00:00
|
|
|
|
2021-01-07 17:44:38 +00:00
|
|
|
@metadata_reactor.provides(
|
|
|
|
'icinga2/icinga_users',
|
|
|
|
)
|
2020-11-21 20:46:41 +00:00
|
|
|
def add_users_from_json(metadata):
|
|
|
|
with open(join(repo.path, 'users.json'), 'r') as f:
|
|
|
|
json = loads(f.read())
|
|
|
|
|
|
|
|
users = {}
|
|
|
|
for uname, config in json.items():
|
|
|
|
users[uname] = {
|
|
|
|
'email': '',
|
|
|
|
'phone': '',
|
|
|
|
'is_admin': config.get('is_admin', False),
|
|
|
|
}
|
|
|
|
|
|
|
|
if 'email' in config:
|
|
|
|
users[uname]['email'] = repo.vault.decrypt(config['email'])
|
|
|
|
if 'phone' in config:
|
|
|
|
users[uname]['phone'] = repo.vault.decrypt(config['phone'])
|
|
|
|
|
|
|
|
return {
|
|
|
|
'icinga2': {
|
|
|
|
'icinga_users': users,
|
|
|
|
},
|
|
|
|
}
|
2021-02-15 13:16:35 +00:00
|
|
|
|
|
|
|
|
|
|
|
@metadata_reactor.provides(
|
2023-09-09 11:55:16 +00:00
|
|
|
'nginx/vhosts/icingaweb2',
|
|
|
|
'nginx/vhosts/icinga_statusmonitor',
|
2021-02-15 13:16:35 +00:00
|
|
|
)
|
2023-09-09 11:55:16 +00:00
|
|
|
def nginx(metadata):
|
|
|
|
if not node.has_bundle('nginx'):
|
|
|
|
raise DoNotRunAgain
|
|
|
|
|
2021-02-15 13:16:35 +00:00
|
|
|
return {
|
2023-09-09 11:55:16 +00:00
|
|
|
'nginx': {
|
|
|
|
'vhosts': {
|
|
|
|
'icingaweb2': {
|
|
|
|
'domain': metadata.get('icinga2/web_domain'),
|
|
|
|
'webroot': '/usr/share/icingaweb2/public',
|
|
|
|
'locations': {
|
|
|
|
'/api/': {
|
|
|
|
'target': 'https://127.0.0.1:5665/',
|
|
|
|
},
|
2024-04-20 16:30:39 +00:00
|
|
|
'/statusmonitor/': {
|
|
|
|
'target': 'http://127.0.0.1:5000/',
|
|
|
|
},
|
2023-09-09 11:55:16 +00:00
|
|
|
},
|
|
|
|
'extras': True,
|
|
|
|
},
|
2021-02-15 13:16:35 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|