fix: generate backup icinga independant of args flag

This commit is contained in:
2023-01-14 06:28:14 +01:00
parent 709ea7dc15
commit 8a26d4ec37
2 changed files with 13 additions and 9 deletions

View File

@@ -6,7 +6,7 @@ import json
environment = jinja2.Environment(loader=jinja2.FileSystemLoader(searchpath="./templates")) environment = jinja2.Environment(loader=jinja2.FileSystemLoader(searchpath="./templates"))
def createBackupScriptStructure(backupList, baseDomain=""): def createBackupScriptStructure(backupList, baseDomain="", icingaOnly=False):
backupPath = "./build/backup/" backupPath = "./build/backup/"
@@ -79,6 +79,14 @@ def createBackupScriptStructure(backupList, baseDomain=""):
cmd = cmd.format(hostname, cur) cmd = cmd.format(hostname, cur)
sizeChangeNotifyCommands.append(cmd) sizeChangeNotifyCommands.append(cmd)
# async icinga config #
asyncIcingaConf |= { "backup_{}".format(hostnameBase) :
{ "timeout" : "30d", "token" : icingaToken }}
# continue for icinga only #
if icingaOnly:
continue
# keep order (important!) # keep order (important!)
pathsAll = list(set(basePaths)) + [ p.rstrip("/") + "/***" for p in fullPaths ] pathsAll = list(set(basePaths)) + [ p.rstrip("/") + "/***" for p in fullPaths ]
@@ -107,10 +115,6 @@ def createBackupScriptStructure(backupList, baseDomain=""):
# build filter without high data and without non-size-changed dirs # # build filter without high data and without non-size-changed dirs #
rsyncFilterMinimal = rsyncFilterTemplate.render(paths=pathsMinimal) rsyncFilterMinimal = rsyncFilterTemplate.render(paths=pathsMinimal)
# async icinga config #
asyncIcingaConf |= { "backup_{}".format(hostnameBase) :
{ "timeout" : "30d", "token" : icingaToken }}
# write script # # write script #
scriptName = "rsync-backup-{}.sh".format(hostnameBase) scriptName = "rsync-backup-{}.sh".format(hostnameBase)
scriptNames.append(scriptName) scriptNames.append(scriptName)

View File

@@ -58,6 +58,6 @@ if __name__ == "__main__":
f.write("\n") f.write("\n")
# backup # # backup #
if args.backup:
with open("./config/backup.json") as f: with open("./config/backup.json") as f:
backup.createBackupScriptStructure(json.load(f), baseDomain=MASTER_ADDRESS) backup.createBackupScriptStructure(json.load(f), baseDomain=MASTER_ADDRESS,
icingaOnly=not args.backup)