Ansible-NFS-Aktion: app.py aktualisieren
This commit is contained in:
parent
6092c432fe
commit
fde0b2d469
1 changed files with 20 additions and 11 deletions
31
app.py
31
app.py
|
|
@ -1571,25 +1571,34 @@ async def ansible_run(request: Request, _=Depends(_verify)):
|
||||||
if not hostname:
|
if not hostname:
|
||||||
return JSONResponse({"error": "limit/hostname required"}, status_code=400)
|
return JSONResponse({"error": "limit/hostname required"}, status_code=400)
|
||||||
action = body.get("action", "setup")
|
action = body.get("action", "setup")
|
||||||
if action not in {"setup", "tune", "pvetune"}:
|
if action not in {"setup", "tune", "pvetune", "nfs"}:
|
||||||
return JSONResponse({"error": "action must be setup, tune or pvetune"}, status_code=400)
|
return JSONResponse({"error": "action must be setup, tune, pvetune or nfs"}, status_code=400)
|
||||||
if not re.fullmatch(r"[a-zA-Z0-9_.:-]+", hostname):
|
if not re.fullmatch(r"[a-zA-Z0-9_.:-]+", hostname):
|
||||||
return JSONResponse({"error": "invalid hostname/limit"}, status_code=400)
|
return JSONResponse({"error": "invalid hostname/limit"}, status_code=400)
|
||||||
if action in {"tune", "pvetune"}:
|
if action in {"tune", "pvetune", "nfs"}:
|
||||||
approved_files = (
|
if action == "nfs":
|
||||||
"roles/sysctl/defaults/main.yml",
|
approved_files = (
|
||||||
"roles/sysctl/tasks/main.yml",
|
"roles/nfs_stability/tasks/main.yml",
|
||||||
"group_vars/vps/sysctl.yml",
|
"nfs-stability.yml",
|
||||||
"sysctl-proxmox.yaml",
|
"pfannkuchen.sh",
|
||||||
"roles/sysctl_proxmox/tasks/main.yml",
|
)
|
||||||
)
|
prepare = "mkdir -p roles/nfs_stability/tasks && "
|
||||||
|
else:
|
||||||
|
approved_files = (
|
||||||
|
"roles/sysctl/defaults/main.yml",
|
||||||
|
"roles/sysctl/tasks/main.yml",
|
||||||
|
"group_vars/vps/sysctl.yml",
|
||||||
|
"sysctl-proxmox.yaml",
|
||||||
|
"roles/sysctl_proxmox/tasks/main.yml",
|
||||||
|
)
|
||||||
|
prepare = ""
|
||||||
file_sync = " && ".join(
|
file_sync = " && ".join(
|
||||||
f"git show origin/master:{path} > {path}" for path in approved_files
|
f"git show origin/master:{path} > {path}" for path in approved_files
|
||||||
)
|
)
|
||||||
command = (
|
command = (
|
||||||
"cd /app-config/ansible && "
|
"cd /app-config/ansible && "
|
||||||
"git fetch origin master && "
|
"git fetch origin master && "
|
||||||
f"{file_sync} && "
|
f"{prepare}{file_sync} && "
|
||||||
f"bash pfannkuchen.sh {action} {hostname}"
|
f"bash pfannkuchen.sh {action} {hostname}"
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue