++config vpn server

This commit is contained in:
Nico Schottelius 2020-12-20 13:00:36 +01:00
parent 1922a0d92d
commit 03c0b34446
2 changed files with 12 additions and 3 deletions

View file

@ -221,7 +221,7 @@ CELERY_BROKER_URL = 'redis://:uncloud.example.com:6379/0'
CELERY_RESULT_BACKEND = 'redis://:uncloud.example.com:6379/0' CELERY_RESULT_BACKEND = 'redis://:uncloud.example.com:6379/0'
CELERY_TASK_ROUTES = { CELERY_TASK_ROUTES = {
re.compile(r'cdist.*'): { 'queue': 'cdist' } re.compile(r'.*.tasks.cdist.*'): { 'queue': 'cdist' } # cdist tasks go into cdist queue
} }
# CELERY_TASK_CREATE_MISSING_QUEUES = False # CELERY_TASK_CREATE_MISSING_QUEUES = False

View file

@ -2,6 +2,7 @@ from celery import shared_task
from .models import * from .models import *
import os import os
import subprocess
@shared_task @shared_task
def whereami(): def whereami():
@ -31,12 +32,20 @@ def cdist_configure_wireguard_server(config, server):
To be executed on the cdist workers. To be executed on the cdist workers.
""" """
fname = f"/home/app/.cdist/type/__ungleich_wireguard/files/{server}" dirname= "/home/app/.cdist/type/__ungleich_wireguard/files/"
fname = os.path.join(dirname,server)
print(os.uname())
print(f"Configuring VPN server {server} (on cdist host)") print(f"Configuring VPN server {server} (on cdist host)")
with open(fname, "w") as fd: with open(fname, "w") as fd:
fd.write(config) fd.write(config)
subprocess.run(f"cd ${dirname} && git pull && git add {server} && git commit -m 'Updating config for ${server}' && git push",
shell=True)
subprocess.run(f"cdist config -vv {server}", shell=True)
# FIXME:
# ensure logs are on the server
# ensure exit codes are known
return "All good" return "All good"