add new status page to icinga
This commit is contained in:
parent
b38bc67a60
commit
563735d31a
5 changed files with 107 additions and 43 deletions
16
bundles/icinga2-statuspage/files/icinga2-statuspage.service
Normal file
16
bundles/icinga2-statuspage/files/icinga2-statuspage.service
Normal file
|
@ -0,0 +1,16 @@
|
|||
[Unit]
|
||||
Description=icinga2-statuspage
|
||||
After=network.target
|
||||
Requires=postgresql.service
|
||||
|
||||
[Service]
|
||||
User=www-data
|
||||
Group=www-data
|
||||
Environment=APP_CONFIG=/opt/icinga2-statuspage/config.json
|
||||
WorkingDirectory=/opt/icinga2-statuspage/src
|
||||
ExecStart=/usr/bin/gunicorn statuspage:app --workers 4 --max-requests 1200 --max-requests-jitter 50 --log-level=info --bind=127.0.0.1:22110
|
||||
Restart=always
|
||||
RestartSec=10
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
34
bundles/icinga2-statuspage/items.py
Normal file
34
bundles/icinga2-statuspage/items.py
Normal file
|
@ -0,0 +1,34 @@
|
|||
directories['/opt/icinga2-statuspage/src'] = {}
|
||||
|
||||
git_deploy['/opt/icinga2-statuspage/src'] = {
|
||||
'repo': 'https://git.franzi.business/kunsi/icinga-dynamic-statuspage.git',
|
||||
'rev': 'main',
|
||||
'triggers': {
|
||||
'svc_systemd:icinga2-statuspage:restart',
|
||||
},
|
||||
}
|
||||
|
||||
files['/opt/icinga2-statuspage/config.json'] = {
|
||||
'content': repo.libs.faults.dict_as_json(node.metadata.get('icinga2-statuspage')),
|
||||
'triggers': {
|
||||
'svc_systemd:icinga2-statuspage:restart',
|
||||
},
|
||||
}
|
||||
|
||||
files['/usr/local/lib/systemd/system/icinga2-statuspage.service'] = {
|
||||
'triggers': {
|
||||
'action:systemd-reload',
|
||||
'svc_systemd:icinga2-statuspage:restart',
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
svc_systemd['icinga2-statuspage'] = {
|
||||
'needs': {
|
||||
'file:/opt/icinga2-statuspage/config.json',
|
||||
'git_deploy:/opt/icinga2-statuspage/src',
|
||||
'pkg_apt:gunicorn',
|
||||
'pkg_apt:python3-flask',
|
||||
'pkg_apt:python3-psycopg2',
|
||||
},
|
||||
}
|
47
bundles/icinga2-statuspage/metadata.py
Normal file
47
bundles/icinga2-statuspage/metadata.py
Normal file
|
@ -0,0 +1,47 @@
|
|||
defaults = {
|
||||
'apt': {
|
||||
'packages': {
|
||||
'gunicorn': {},
|
||||
'python3-flask': {},
|
||||
'python3-psycopg2': {},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@metadata_reactor.provides(
|
||||
'icinga2-statuspage',
|
||||
)
|
||||
def import_db_settings_from_icinga(metadata):
|
||||
return {
|
||||
'icinga2-statuspage': {
|
||||
'DB_USER': 'icinga2',
|
||||
'DB_PASS': metadata.get('postgresql/roles/icinga2/password'),
|
||||
'DB_NAME': 'icinga2',
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@metadata_reactor.provides(
|
||||
'nginx/vhosts/icinga2-statuspage',
|
||||
)
|
||||
def nginx(metadata):
|
||||
if not node.has_bundle('nginx'):
|
||||
raise DoNotRunAgain
|
||||
|
||||
return {
|
||||
'nginx': {
|
||||
'vhosts': {
|
||||
'icinga2-statuspage': {
|
||||
'domain': metadata.get('icinga2-statuspage/DOMAIN'),
|
||||
'locations': {
|
||||
'/': {
|
||||
'target': 'http://127.0.0.1:22110',
|
||||
},
|
||||
},
|
||||
'website_check_path': '/',
|
||||
'website_check_string': 'status page',
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue