++config vpn server
This commit is contained in:
parent
1922a0d92d
commit
03c0b34446
2 changed files with 12 additions and 3 deletions
|
@ -221,7 +221,7 @@ CELERY_BROKER_URL = 'redis://:uncloud.example.com:6379/0'
|
|||
CELERY_RESULT_BACKEND = 'redis://:uncloud.example.com:6379/0'
|
||||
|
||||
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
|
||||
|
|
|
@ -2,6 +2,7 @@ from celery import shared_task
|
|||
from .models import *
|
||||
|
||||
import os
|
||||
import subprocess
|
||||
|
||||
@shared_task
|
||||
def whereami():
|
||||
|
@ -31,12 +32,20 @@ def cdist_configure_wireguard_server(config, server):
|
|||
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)")
|
||||
with open(fname, "w") as fd:
|
||||
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"
|
||||
|
|
Loading…
Reference in a new issue