bundlewrap/bundles/influxdb2/metadata.py
CroneKorkN 186d5039af
migrate to bundlewrap 5
- pin bundlewrap ~=5.0
- rewrite non-reading and KeyError-driven metadata reactors per
  https://docs.bundlewrap.org/guide/migrate_45/ (defaults / metadata.get
  paths / MetadataUnavailable)
- rename custom Download item methods (cdict/sdict/get_auto_deps ->
  expected_state/actual_state/get_auto_attrs)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-10 11:56:49 +02:00

92 lines
2.1 KiB
Python

from ipaddress import ip_interface
defaults = {
'apt': {
'packages': {
'influxdb2': {},
'influxdb2-cli': {},
},
'sources': {
'influxdata': {
'urls': {
'https://repos.influxdata.com/debian',
},
'suites': {
'stable',
},
'components': {
'main',
},
},
},
},
'nftables': {
'input': {
'tcp dport 8200 accept',
},
},
'influxdb': {
'port': '8200',
'username': 'admin',
'org': 'default',
'bucket': 'default',
'config': {
'bolt-path': '/var/lib/influxdb/influxd.bolt',
'engine-path': '/var/lib/influxdb/engine',
'reporting-disabled': True,
'http-bind-address': ':8200',
},
},
}
if node.has_bundle('zfs'):
defaults['zfs'] = {
'datasets': {
'tank/influxdb': {
'mountpoint': '/var/lib/influxdb',
'recordsize': '8192',
'atime': 'off',
},
},
}
@metadata_reactor.provides(
'influxdb/password',
'influxdb/admin_token',
)
def admin_password(metadata):
return {
'influxdb': {
'password': repo.vault.password_for(f"{metadata.get('id')} influxdb admin"),
'admin_token': repo.vault.random_bytes_as_base64_for(f"{metadata.get('id')} influxdb default token", length=64),
},
}
@metadata_reactor.provides(
'dns',
)
def dns(metadata):
return {
'dns': {
metadata.get('influxdb/hostname'): repo.libs.ip.get_a_records(metadata),
}
}
@metadata_reactor.provides(
'nginx/vhosts',
)
def nginx(metadata):
return {
'nginx': {
'vhosts': {
metadata.get('influxdb/hostname'): {
'content': 'nginx/proxy_pass.conf',
'context': {
'target': 'http://127.0.0.1:8200',
}
},
},
},
}