wip
This commit is contained in:
		
							parent
							
								
									c71221f16c
								
							
						
					
					
						commit
						b9b025a316
					
				
					 7 changed files with 230 additions and 125 deletions
				
			
		| 
						 | 
				
			
			@ -1,72 +1,68 @@
 | 
			
		|||
# Git-Hash for Icinga1: b63bb0ef52bf213715e567c81e3ed097024e61af
 | 
			
		||||
# 
 | 
			
		||||
# directories = {
 | 
			
		||||
#     '/etc/icinga2': {
 | 
			
		||||
#         'purge': True,
 | 
			
		||||
#         'owner': 'nagios',
 | 
			
		||||
#     },
 | 
			
		||||
#     '/etc/icinga2/conf.d': {
 | 
			
		||||
#         'purge': True,
 | 
			
		||||
#         'owner': 'nagios',
 | 
			
		||||
#     },
 | 
			
		||||
#     '/etc/icinga2/hosts.d': {
 | 
			
		||||
#         'purge': True,
 | 
			
		||||
#         'owner': 'nagios',
 | 
			
		||||
#     },
 | 
			
		||||
#     '/etc/icinga2/features.d': {
 | 
			
		||||
#         'purge': True,
 | 
			
		||||
#         'owner': 'nagios',
 | 
			
		||||
#     },
 | 
			
		||||
# }
 | 
			
		||||
# 
 | 
			
		||||
# files = {
 | 
			
		||||
#     '/etc/icinga2/icinga2.conf': {
 | 
			
		||||
#         'owner': 'nagios',
 | 
			
		||||
#     },
 | 
			
		||||
#     '/etc/icinga2/constants.conf': {
 | 
			
		||||
#         'owner': 'nagios',
 | 
			
		||||
#         'context': {
 | 
			
		||||
#             'hostname': node.metadata.get('icinga2/hostname')
 | 
			
		||||
#         },
 | 
			
		||||
#     },
 | 
			
		||||
#     '/etc/icinga2/conf.d/templates.conf': {
 | 
			
		||||
#         'source': 'conf.d/templates.conf',
 | 
			
		||||
#         'owner': 'nagios',
 | 
			
		||||
#     },
 | 
			
		||||
#     '/etc/icinga2/features/ido-pgsql.conf': {
 | 
			
		||||
#         'source': 'features/ido-pgsql.conf',
 | 
			
		||||
#         'content_type': 'mako',
 | 
			
		||||
#         'owner': 'nagios',
 | 
			
		||||
#         'context': {
 | 
			
		||||
#             'db_password': node.metadata.get('postgresql/roles/icinga2/password')
 | 
			
		||||
#         },
 | 
			
		||||
#         'needs': [
 | 
			
		||||
#             'pkg_apt:icinga2-ido-pgsql',
 | 
			
		||||
#         ],
 | 
			
		||||
#     },
 | 
			
		||||
#     '/etc/icingaweb2/setup.token': {
 | 
			
		||||
#         'content': node.metadata.get('icingaweb2/setup_token'),
 | 
			
		||||
#         'owner': 'nagios',
 | 
			
		||||
#     },
 | 
			
		||||
# }
 | 
			
		||||
# 
 | 
			
		||||
# for other_node in repo.nodes:
 | 
			
		||||
#     files[f'/etc/icinga2/hosts.d/{other_node.name}.conf'] = {
 | 
			
		||||
#         'content_type': 'mako',
 | 
			
		||||
#         'source': 'hosts.d/host.conf',
 | 
			
		||||
#         'owner': 'nagios',
 | 
			
		||||
#         'context': {
 | 
			
		||||
#             'host_name': other_node.name,
 | 
			
		||||
#             'host_settings': {},
 | 
			
		||||
#             'services': other_node.metadata.get('monitoring', {}),
 | 
			
		||||
#         },
 | 
			
		||||
#     }
 | 
			
		||||
# 
 | 
			
		||||
# svc_systemd = {
 | 
			
		||||
#     'icinga2': {
 | 
			
		||||
#         'needs': [
 | 
			
		||||
#             'pkg_apt:icinga2-ido-pgsql',
 | 
			
		||||
#             'svc_systemd:postgresql',
 | 
			
		||||
#         ],
 | 
			
		||||
#     },
 | 
			
		||||
# }
 | 
			
		||||
 | 
			
		||||
directories = {
 | 
			
		||||
    '/etc/icinga2': {
 | 
			
		||||
        'purge': True,
 | 
			
		||||
        'owner': 'nagios',
 | 
			
		||||
    },
 | 
			
		||||
    '/etc/icinga2/conf.d': {
 | 
			
		||||
        'purge': True,
 | 
			
		||||
        'owner': 'nagios',
 | 
			
		||||
    },
 | 
			
		||||
    '/etc/icinga2/hosts.d': {
 | 
			
		||||
        'purge': True,
 | 
			
		||||
        'owner': 'nagios',
 | 
			
		||||
    },
 | 
			
		||||
    '/etc/icinga2/features.d': {
 | 
			
		||||
        'purge': True,
 | 
			
		||||
        'owner': 'nagios',
 | 
			
		||||
    },
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
files = {
 | 
			
		||||
    '/etc/icinga2/icinga2.conf': {
 | 
			
		||||
        'owner': 'nagios',
 | 
			
		||||
    },
 | 
			
		||||
    '/etc/icinga2/constants.conf': {
 | 
			
		||||
        'owner': 'nagios',
 | 
			
		||||
        'context': {
 | 
			
		||||
            'hostname': node.metadata.get('icinga2/hostname')
 | 
			
		||||
        },
 | 
			
		||||
    },
 | 
			
		||||
    '/etc/icinga2/conf.d/templates.conf': {
 | 
			
		||||
        'source': 'conf.d/templates.conf',
 | 
			
		||||
        'owner': 'nagios',
 | 
			
		||||
    },
 | 
			
		||||
    '/etc/icinga2/features/ido-pgsql.conf': {
 | 
			
		||||
        'source': 'features/ido-pgsql.conf',
 | 
			
		||||
        'content_type': 'mako',
 | 
			
		||||
        'owner': 'nagios',
 | 
			
		||||
        'context': {
 | 
			
		||||
            'db_password': node.metadata.get('postgresql/roles/icinga2/password')
 | 
			
		||||
        },
 | 
			
		||||
        'needs': [
 | 
			
		||||
            'pkg_apt:icinga2-ido-pgsql',
 | 
			
		||||
        ],
 | 
			
		||||
    },
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
for other_node in repo.nodes:
 | 
			
		||||
    files[f'/etc/icinga2/hosts.d/{other_node.name}.conf'] = {
 | 
			
		||||
        'content_type': 'mako',
 | 
			
		||||
        'source': 'hosts.d/host.conf',
 | 
			
		||||
        'owner': 'nagios',
 | 
			
		||||
        'context': {
 | 
			
		||||
            'host_name': other_node.name,
 | 
			
		||||
            'host_settings': {},
 | 
			
		||||
            'services': other_node.metadata.get('monitoring', {}),
 | 
			
		||||
        },
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
svc_systemd = {
 | 
			
		||||
    'icinga2': {
 | 
			
		||||
        'needs': [
 | 
			
		||||
            'pkg_apt:icinga2-ido-pgsql',
 | 
			
		||||
            'svc_systemd:postgresql',
 | 
			
		||||
        ],
 | 
			
		||||
    },
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -3,72 +3,36 @@ from hashlib import sha3_256
 | 
			
		|||
defaults = {
 | 
			
		||||
    'apt': {
 | 
			
		||||
        'packages': {
 | 
			
		||||
            'icingadb': {},
 | 
			
		||||
            'icingadb-web': {},
 | 
			
		||||
            'icingaweb2': {},
 | 
			
		||||
            'icingadb-redis': {},
 | 
			
		||||
            'icinga2': {},
 | 
			
		||||
            'icinga2-ido-pgsql': {},
 | 
			
		||||
            'icingacli': {},
 | 
			
		||||
        },
 | 
			
		||||
        'sources': {
 | 
			
		||||
            'deb https://packages.icinga.com/debian icinga-{release} main',
 | 
			
		||||
            'deb https://packages.icinga.com/debian icinga-{release}-testing main',
 | 
			
		||||
        },
 | 
			
		||||
    },
 | 
			
		||||
    'postgresql': {
 | 
			
		||||
        'databases': {
 | 
			
		||||
            'icingadb': {
 | 
			
		||||
            'icinga2': {
 | 
			
		||||
                'owner': 'icinga2',
 | 
			
		||||
            },
 | 
			
		||||
            'icingaweb2': {
 | 
			
		||||
                'owner': 'icingaweb2',
 | 
			
		||||
            },
 | 
			
		||||
        },
 | 
			
		||||
        'roles': {
 | 
			
		||||
            'icingadb': {
 | 
			
		||||
            'icinga2': {
 | 
			
		||||
                'password': repo.vault.password_for(f'psql icinga2 on {node.name}'),
 | 
			
		||||
            },
 | 
			
		||||
            'icingaweb2': {
 | 
			
		||||
                'password': repo.vault.password_for(f'psql icingaweb2 on {node.name}'),
 | 
			
		||||
        },
 | 
			
		||||
    },
 | 
			
		||||
    'zfs': {
 | 
			
		||||
        'datasets': {
 | 
			
		||||
            'tank/icinga2': {
 | 
			
		||||
                'mountpoint': '/var/lib/icinga2',
 | 
			
		||||
                'needed_by': {
 | 
			
		||||
                    'pkg_apt:icinga2',
 | 
			
		||||
                    'pkg_apt:icingaweb2',
 | 
			
		||||
                    'pkg_apt:icinga2-ido-pgsql',
 | 
			
		||||
                },
 | 
			
		||||
            },
 | 
			
		||||
        },
 | 
			
		||||
    },
 | 
			
		||||
    # 'zfs': {
 | 
			
		||||
    #     'datasets': {
 | 
			
		||||
    #         'tank/icinga2': {
 | 
			
		||||
    #             'mountpoint': '/var/lib/icingadb',
 | 
			
		||||
    #             'needed_by': {
 | 
			
		||||
    #                 'pkg_apt:icingadb',
 | 
			
		||||
    #                 'pkg_apt:icingadb-web',
 | 
			
		||||
    #                 'pkg_apt:icingaweb2',
 | 
			
		||||
    #             },
 | 
			
		||||
    #         },
 | 
			
		||||
    #     },
 | 
			
		||||
    # },
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
# 
 | 
			
		||||
# @metadata_reactor.provides(
 | 
			
		||||
#     'icingaweb2/setup_token',
 | 
			
		||||
# )
 | 
			
		||||
# def setup_token(metadata):
 | 
			
		||||
#     return {
 | 
			
		||||
#         'icingaweb2': {
 | 
			
		||||
#             'setup_token': sha3_256(metadata.get('id').encode()).hexdigest()[:16],
 | 
			
		||||
#         },
 | 
			
		||||
#     }
 | 
			
		||||
# 
 | 
			
		||||
# 
 | 
			
		||||
# @metadata_reactor.provides(
 | 
			
		||||
#     'nginx/vhosts',
 | 
			
		||||
# )
 | 
			
		||||
# def nginx(metadata):
 | 
			
		||||
#     return {
 | 
			
		||||
#         'nginx': {
 | 
			
		||||
#             'vhosts': {
 | 
			
		||||
#                 metadata.get('icinga2/hostname'): {
 | 
			
		||||
#                     'content': 'icingaweb2/vhost.conf',
 | 
			
		||||
#                     'context': {
 | 
			
		||||
#                     },
 | 
			
		||||
#                 },
 | 
			
		||||
#             },
 | 
			
		||||
#         },
 | 
			
		||||
#     }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										14
									
								
								bundles/icingadb/items.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										14
									
								
								bundles/icingadb/items.py
									
									
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,14 @@
 | 
			
		|||
import yaml, json
 | 
			
		||||
from bundlewrap.metadata import MetadataJSONEncoder
 | 
			
		||||
 | 
			
		||||
files = {
 | 
			
		||||
    '/etc/icingadb/config.yml': {
 | 
			
		||||
        'content': yaml.dump(
 | 
			
		||||
            json.loads(
 | 
			
		||||
                json.dumps(node.metadata.get('icingadb'), sort_keys=True, cls=MetadataJSONEncoder)
 | 
			
		||||
            ),
 | 
			
		||||
        ),
 | 
			
		||||
        'mode': '0640',
 | 
			
		||||
        'owner': 'icingadb',
 | 
			
		||||
    },
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										53
									
								
								bundles/icingadb/metadata.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										53
									
								
								bundles/icingadb/metadata.py
									
									
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,53 @@
 | 
			
		|||
defaults = {
 | 
			
		||||
    'apt': {
 | 
			
		||||
        'packages': {
 | 
			
		||||
            'icingadb': {},
 | 
			
		||||
            'icingadb-redis': {},
 | 
			
		||||
            'icingadb-web': {},
 | 
			
		||||
        },
 | 
			
		||||
        'sources': {
 | 
			
		||||
            'deb https://packages.icinga.com/debian icinga-{release} main',
 | 
			
		||||
            'deb https://packages.icinga.com/debian icinga-{release}-snapshots main',
 | 
			
		||||
        },
 | 
			
		||||
    },
 | 
			
		||||
    'postgresql': {
 | 
			
		||||
        'databases': {
 | 
			
		||||
            'icingadb': {
 | 
			
		||||
                'owner': 'icingadb',
 | 
			
		||||
            },
 | 
			
		||||
        },
 | 
			
		||||
        'roles': {
 | 
			
		||||
            'icingadb': {
 | 
			
		||||
                'password': repo.vault.password_for(f'psql icingadb on {node.name}'),
 | 
			
		||||
            },
 | 
			
		||||
        },
 | 
			
		||||
    },
 | 
			
		||||
    'redis': {
 | 
			
		||||
        'icingadb': {
 | 
			
		||||
            'port': '6381',
 | 
			
		||||
        },
 | 
			
		||||
    },
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@metadata_reactor.provides(
 | 
			
		||||
    'icingadb',
 | 
			
		||||
)
 | 
			
		||||
def config(metadata):
 | 
			
		||||
    return {
 | 
			
		||||
        'icingadb': {
 | 
			
		||||
            'database': {
 | 
			
		||||
                'type': 'postgresql',
 | 
			
		||||
                'host': 'localhost',
 | 
			
		||||
                'port': 3306,
 | 
			
		||||
                'database': 'icingadb',
 | 
			
		||||
                'user': 'icingadb',
 | 
			
		||||
                'password': metadata.get('postgresql/roles/icingadb/password'),
 | 
			
		||||
            },
 | 
			
		||||
            'redis': {
 | 
			
		||||
                'address': 'localhost:6380',
 | 
			
		||||
            },
 | 
			
		||||
            'logging': {
 | 
			
		||||
                'level': 'info',
 | 
			
		||||
            },
 | 
			
		||||
        },
 | 
			
		||||
    }
 | 
			
		||||
							
								
								
									
										6
									
								
								bundles/icingaweb2/items.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								bundles/icingaweb2/items.py
									
									
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,6 @@
 | 
			
		|||
files = {
 | 
			
		||||
    '/etc/icingaweb2/setup.token': {
 | 
			
		||||
        'content': node.metadata.get('icingaweb2/setup_token'),
 | 
			
		||||
        'owner': 'nagios',
 | 
			
		||||
    },
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										67
									
								
								bundles/icingaweb2/metadata.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										67
									
								
								bundles/icingaweb2/metadata.py
									
									
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,67 @@
 | 
			
		|||
from hashlib import sha3_256
 | 
			
		||||
 | 
			
		||||
defaults = {
 | 
			
		||||
    'apt': {
 | 
			
		||||
        'packages': {
 | 
			
		||||
            'icingaweb2': {},
 | 
			
		||||
        },
 | 
			
		||||
        'sources': {
 | 
			
		||||
            'deb https://packages.icinga.com/debian icinga-{release} main',
 | 
			
		||||
            'deb https://packages.icinga.com/debian icinga-{release}-snapshots main',
 | 
			
		||||
        },
 | 
			
		||||
    },
 | 
			
		||||
    'postgresql': {
 | 
			
		||||
        'databases': {
 | 
			
		||||
            'icingaweb2': {
 | 
			
		||||
                'owner': 'icingaweb2',
 | 
			
		||||
            },
 | 
			
		||||
        },
 | 
			
		||||
        'roles': {
 | 
			
		||||
            'icingaweb2': {
 | 
			
		||||
                'password': str(repo.vault.password_for(f'psql icingaweb2 on {node.name}')),
 | 
			
		||||
            },
 | 
			
		||||
        },
 | 
			
		||||
    },
 | 
			
		||||
    'redis': {
 | 
			
		||||
        'icingadb': {},
 | 
			
		||||
    },
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@metadata_reactor.provides(
 | 
			
		||||
    'icingaweb2/hostname',
 | 
			
		||||
)
 | 
			
		||||
def hostname(metadata):
 | 
			
		||||
    return {
 | 
			
		||||
        'icingaweb2': {
 | 
			
		||||
            'hostname': metadata.get('icinga2/hostname'),
 | 
			
		||||
        },
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@metadata_reactor.provides(
 | 
			
		||||
    'icingaweb2/setup_token',
 | 
			
		||||
)
 | 
			
		||||
def setup_token(metadata):
 | 
			
		||||
    return {
 | 
			
		||||
        'icingaweb2': {
 | 
			
		||||
            'setup_token': sha3_256(metadata.get('id').encode()).hexdigest()[:16],
 | 
			
		||||
        },
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@metadata_reactor.provides(
 | 
			
		||||
    'nginx/vhosts',
 | 
			
		||||
)
 | 
			
		||||
def nginx(metadata):
 | 
			
		||||
    return {
 | 
			
		||||
        'nginx': {
 | 
			
		||||
            'vhosts': {
 | 
			
		||||
                metadata.get('icingaweb2/hostname'): {
 | 
			
		||||
                    'content': 'icingaweb2/vhost.conf',
 | 
			
		||||
                    'context': {
 | 
			
		||||
                    },
 | 
			
		||||
                },
 | 
			
		||||
            },
 | 
			
		||||
        },
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			@ -19,6 +19,8 @@
 | 
			
		|||
#        'gollum',
 | 
			
		||||
        'grafana',
 | 
			
		||||
        'icinga2',
 | 
			
		||||
        'icingadb',
 | 
			
		||||
        'icingaweb2',
 | 
			
		||||
        'influxdb2',
 | 
			
		||||
        'mirror',
 | 
			
		||||
        'postgresql',
 | 
			
		||||
| 
						 | 
				
			
			@ -71,7 +73,10 @@
 | 
			
		|||
            'influxdb_node': 'home.server',
 | 
			
		||||
        },
 | 
			
		||||
        'icinga2': {
 | 
			
		||||
            'hostname': 'icinga2.sublimity.de',
 | 
			
		||||
            'hostname': 'icinga.sublimity.de',
 | 
			
		||||
        },
 | 
			
		||||
        'icingaweb2': {
 | 
			
		||||
            'hostname': 'icinga.sublimity.de',
 | 
			
		||||
        },
 | 
			
		||||
        'influxdb': {
 | 
			
		||||
            'hostname': 'influxdb.sublimity.de',
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in a new issue