loadbalancer, config upload moved to shared

This commit is contained in:
Zsolt Ero
2024-09-12 15:58:38 +02:00
parent 4723d3c283
commit 3cf11fe7af
4 changed files with 11 additions and 13 deletions

View File

@@ -159,6 +159,9 @@ See [dev setup docs](docs/dev_setup.md).
## Changelog ## Changelog
##### v0.6
Load-balancer implemented with new config format.
##### v0.5 ##### v0.5
Using a "done" file in the R2 buckets to mark the upload as finished. All scripts are checking for this file now. Using a "done" file in the R2 buckets to mark the upload as finished. All scripts are checking for this file now.

View File

@@ -11,7 +11,6 @@ from ssh_lib.tasks import (
run_http_host_sync, run_http_host_sync,
setup_ledns_writer, setup_ledns_writer,
setup_loadbalancer, setup_loadbalancer,
upload_config_json,
) )
from ssh_lib.utils import ( from ssh_lib.utils import (
put, put,
@@ -66,8 +65,6 @@ def http_host_static(hostname, user, port, noninteractive):
c = get_connection(hostname, user, port) c = get_connection(hostname, user, port)
prepare_shared(c) prepare_shared(c)
upload_config_json(c)
prepare_http_host(c) prepare_http_host(c)
run_http_host_sync(c) run_http_host_sync(c)
@@ -84,8 +81,6 @@ def http_host_autoupdate(hostname, user, port, noninteractive):
c.sudo('rm -f /etc/cron.d/ofm_http_host') c.sudo('rm -f /etc/cron.d/ofm_http_host')
prepare_shared(c) prepare_shared(c)
upload_config_json(c)
prepare_http_host(c) prepare_http_host(c)
run_http_host_sync(c) run_http_host_sync(c)
@@ -101,6 +96,7 @@ def tile_gen(hostname, user, port, cron, noninteractive):
return return
c = get_connection(hostname, user, port) c = get_connection(hostname, user, port)
prepare_shared(c) prepare_shared(c)
prepare_tile_gen(c, enable_cron=cron) prepare_tile_gen(c, enable_cron=cron)
@@ -134,8 +130,6 @@ def loadbalancer(hostname, user, port, noninteractive):
def debug(hostname, user, port, noninteractive): def debug(hostname, user, port, noninteractive):
c = get_connection(hostname, user, port) c = get_connection(hostname, user, port)
upload_config_json(c)
if __name__ == '__main__': if __name__ == '__main__':
cli() cli()

View File

@@ -1,8 +1,6 @@
from http_host_lib.shared import get_deployed_version
from loadbalancer_lib.cloudflare import get_zone_id, set_records_round_robin from loadbalancer_lib.cloudflare import get_zone_id, set_records_round_robin
from loadbalancer_lib.config import config from loadbalancer_lib.config import config
from loadbalancer_lib.shared import check_host_latest from loadbalancer_lib.shared import check_host_latest, get_deployed_version
from loadbalancer_lib.telegram_ import telegram_send_message from loadbalancer_lib.telegram_ import telegram_send_message

View File

@@ -29,10 +29,13 @@ def prepare_shared(c):
pkg_base(c) pkg_base(c)
rclone(c) rclone(c)
c.sudo(f'rm -rf {REMOTE_CONFIG}')
c.sudo(f'mkdir -p {REMOTE_CONFIG}') c.sudo(f'mkdir -p {REMOTE_CONFIG}')
c.sudo(f'chown ofm:ofm {REMOTE_CONFIG}') c.sudo(f'chown ofm:ofm {REMOTE_CONFIG}')
c.sudo(f'chown ofm:ofm {OFM_DIR}') c.sudo(f'chown ofm:ofm {OFM_DIR}')
upload_config_json(c)
prepare_venv(c) prepare_venv(c)
@@ -228,7 +231,7 @@ def upload_config_json(c):
def setup_loadbalancer(c): def setup_loadbalancer(c):
upload_config_json(c) c.sudo('rm -f /etc/cron.d/ofm_loadbalancer')
put( put(
c, c,
@@ -248,6 +251,6 @@ def setup_loadbalancer(c):
c.sudo(f'{VENV_BIN}/pip install -e /data/ofm/loadbalancer --use-pep517') c.sudo(f'{VENV_BIN}/pip install -e /data/ofm/loadbalancer --use-pep517')
c.sudo('mkdir -p /data/ofm/loadbalancer/logs') c.sudo('mkdir -p /data/ofm/loadbalancer/logs')
put(c, MODULES_DIR / 'loadbalancer' / 'cron.d' / 'ofm_loadbalancer', '/etc/cron.d/')
c.sudo('chown -R ofm:ofm /data/ofm/loadbalancer') c.sudo('chown -R ofm:ofm /data/ofm/loadbalancer')
put(c, MODULES_DIR / 'loadbalancer' / 'cron.d' / 'ofm_loadbalancer', '/etc/cron.d/')