fix: add nsca config generation

This commit is contained in:
2022-12-28 20:19:18 +01:00
parent 4f5c415874
commit 0224997b55
3 changed files with 25 additions and 1 deletions

11
main.py
View File

@@ -13,6 +13,10 @@ location /.well-known/acme-challenge/ {
if __name__ == "__main__":
password = None
with open("password.txt") as f:
password = f.read().strip("\n")
FILE = "./config/vms.json"
with open(FILE) as f:
jsonList = json.load(f)
@@ -88,4 +92,9 @@ if __name__ == "__main__":
f.write(template.render(hostname=vmo.hostname, ip=vmo.ip))
f.write("\n")
# dump ansible
with open("./ansible/files/nsca_server.conf", "w") as f:
env = jinja2.Environment(loader=jinja2.FileSystemLoader(searchpath="./templates"))
template = env.get_template("nsca_server.conf.j2")
f.write(template.render(vmList=set(filter(lambda x: x.ansible, vmList)),
password=password))