This commit is contained in:
mwiegand 2022-03-27 18:15:35 +02:00
parent 717811a888
commit a72ef99f78
2 changed files with 115 additions and 116 deletions

View file

@ -1,72 +1,72 @@
# Git-Hash for Icinga1: b63bb0ef52bf213715e567c81e3ed097024e61af # Git-Hash for Icinga1: b63bb0ef52bf213715e567c81e3ed097024e61af
#
directories = { # directories = {
'/etc/icinga2': { # '/etc/icinga2': {
'purge': True, # 'purge': True,
'owner': 'nagios', # 'owner': 'nagios',
}, # },
'/etc/icinga2/conf.d': { # '/etc/icinga2/conf.d': {
'purge': True, # 'purge': True,
'owner': 'nagios', # 'owner': 'nagios',
}, # },
'/etc/icinga2/hosts.d': { # '/etc/icinga2/hosts.d': {
'purge': True, # 'purge': True,
'owner': 'nagios', # 'owner': 'nagios',
}, # },
'/etc/icinga2/features.d': { # '/etc/icinga2/features.d': {
'purge': True, # 'purge': True,
'owner': 'nagios', # 'owner': 'nagios',
}, # },
} # }
#
files = { # files = {
'/etc/icinga2/icinga2.conf': { # '/etc/icinga2/icinga2.conf': {
'owner': 'nagios', # 'owner': 'nagios',
}, # },
'/etc/icinga2/constants.conf': { # '/etc/icinga2/constants.conf': {
'owner': 'nagios', # 'owner': 'nagios',
'context': { # 'context': {
'hostname': node.metadata.get('icinga2/hostname') # 'hostname': node.metadata.get('icinga2/hostname')
}, # },
}, # },
'/etc/icinga2/conf.d/templates.conf': { # '/etc/icinga2/conf.d/templates.conf': {
'source': 'conf.d/templates.conf', # 'source': 'conf.d/templates.conf',
'owner': 'nagios', # 'owner': 'nagios',
}, # },
'/etc/icinga2/features/ido-pgsql.conf': { # '/etc/icinga2/features/ido-pgsql.conf': {
'source': 'features/ido-pgsql.conf', # 'source': 'features/ido-pgsql.conf',
'content_type': 'mako', # 'content_type': 'mako',
'owner': 'nagios', # 'owner': 'nagios',
'context': { # 'context': {
'db_password': node.metadata.get('postgresql/roles/icinga2/password') # 'db_password': node.metadata.get('postgresql/roles/icinga2/password')
}, # },
'needs': [ # 'needs': [
'pkg_apt:icinga2-ido-pgsql', # 'pkg_apt:icinga2-ido-pgsql',
], # ],
}, # },
'/etc/icingaweb2/setup.token': { # '/etc/icingaweb2/setup.token': {
'content': node.metadata.get('icingaweb2/setup_token'), # 'content': node.metadata.get('icingaweb2/setup_token'),
'owner': 'nagios', # 'owner': 'nagios',
}, # },
} # }
#
for other_node in repo.nodes: # for other_node in repo.nodes:
files[f'/etc/icinga2/hosts.d/{other_node.name}.conf'] = { # files[f'/etc/icinga2/hosts.d/{other_node.name}.conf'] = {
'content_type': 'mako', # 'content_type': 'mako',
'source': 'hosts.d/host.conf', # 'source': 'hosts.d/host.conf',
'owner': 'nagios', # 'owner': 'nagios',
'context': { # 'context': {
'host_name': other_node.name, # 'host_name': other_node.name,
'host_settings': {}, # 'host_settings': {},
'services': other_node.metadata.get('monitoring', {}), # 'services': other_node.metadata.get('monitoring', {}),
}, # },
} # }
#
svc_systemd = { # svc_systemd = {
'icinga2': { # 'icinga2': {
'needs': [ # 'needs': [
'pkg_apt:icinga2-ido-pgsql', # 'pkg_apt:icinga2-ido-pgsql',
'svc_systemd:postgresql', # 'svc_systemd:postgresql',
], # ],
}, # },
} # }

View file

@ -3,11 +3,10 @@ from hashlib import sha3_256
defaults = { defaults = {
'apt': { 'apt': {
'packages': { 'packages': {
'icinga2': {}, 'icingadb': {},
'icingadb-web': {},
'icingaweb2': {}, 'icingaweb2': {},
'icinga2-ido-pgsql': {}, 'icingadb-redis': {},
'icingacli': {},
'monitoring-plugins': {},
}, },
'sources': { 'sources': {
'deb https://packages.icinga.com/debian icinga-{release} main', 'deb https://packages.icinga.com/debian icinga-{release} main',
@ -15,7 +14,7 @@ defaults = {
}, },
'postgresql': { 'postgresql': {
'databases': { 'databases': {
'icinga2': { 'icingadb': {
'owner': 'icinga2', 'owner': 'icinga2',
}, },
'icingaweb2': { 'icingaweb2': {
@ -23,7 +22,7 @@ defaults = {
}, },
}, },
'roles': { 'roles': {
'icinga2': { 'icingadb': {
'password': repo.vault.password_for(f'psql icinga2 on {node.name}'), 'password': repo.vault.password_for(f'psql icinga2 on {node.name}'),
}, },
'icingaweb2': { 'icingaweb2': {
@ -31,44 +30,44 @@ defaults = {
}, },
}, },
}, },
'zfs': { # 'zfs': {
'datasets': { # 'datasets': {
'tank/icinga2': { # 'tank/icinga2': {
'mountpoint': '/var/lib/icinga2', # 'mountpoint': '/var/lib/icingadb',
'needed_by': { # 'needed_by': {
'pkg_apt:icinga2', # 'pkg_apt:icingadb',
'pkg_apt:icingaweb2', # 'pkg_apt:icingadb-web',
'pkg_apt:icinga2-ido-pgsql', # 'pkg_apt:icingaweb2',
}, # },
}, # },
}, # },
}, # },
} }
#
@metadata_reactor.provides( # @metadata_reactor.provides(
'icingaweb2/setup_token', # 'icingaweb2/setup_token',
) # )
def setup_token(metadata): # def setup_token(metadata):
return { # return {
'icingaweb2': { # 'icingaweb2': {
'setup_token': sha3_256(metadata.get('id').encode()).hexdigest()[:16], # 'setup_token': sha3_256(metadata.get('id').encode()).hexdigest()[:16],
}, # },
} # }
#
#
@metadata_reactor.provides( # @metadata_reactor.provides(
'nginx/vhosts', # 'nginx/vhosts',
) # )
def nginx(metadata): # def nginx(metadata):
return { # return {
'nginx': { # 'nginx': {
'vhosts': { # 'vhosts': {
metadata.get('icinga2/hostname'): { # metadata.get('icinga2/hostname'): {
'content': 'icingaweb2/vhost.conf', # 'content': 'icingaweb2/vhost.conf',
'context': { # 'context': {
}, # },
}, # },
}, # },
}, # },
} # }