forked from infra/ansible
updates-uptimes: Add update-flush command explicitly.
Signed-off-by: James Antill <james@and.org>
This commit is contained in:
parent
86a1524632
commit
339f877842
1 changed files with 12 additions and 4 deletions
|
|
@ -46,7 +46,7 @@ backups = sorted(x.removeprefix(fname + '.') for x in glob.glob(fname + '.*'))
|
|||
|
||||
cmd = "diff"
|
||||
if len(sys.argv) >= 2:
|
||||
if sys.argv[1] in ("backups", "backups-keep", "diff", "diff-u", "help", "host", "info", "list", "stats", "update", "update-fast", "update-daily", "uptime",):
|
||||
if sys.argv[1] in ("backups", "backups-keep", "diff", "diff-u", "help", "host", "info", "list", "stats", "update", "update-fast", "update-flush", "update-daily", "uptime",):
|
||||
cmd = sys.argv.pop(1)
|
||||
|
||||
_tm_d = {'d' : 60*60*24, 'h' : 60*60, 'm' : 60, 's' : 1,
|
||||
|
|
@ -171,8 +171,9 @@ def _usage():
|
|||
= Cleanup old backups.
|
||||
|
||||
diff [backup1] [backup2]
|
||||
diff-u [backup1] [backup2]
|
||||
= See the difference between the current state and backups.
|
||||
diff-u [backup1] [backup2]
|
||||
= Shows before/after instead of modified (like diff -u).
|
||||
|
||||
host [host*] [backup]
|
||||
= See the current state of a host(s), can be filtered by name.
|
||||
|
|
@ -186,6 +187,12 @@ def _usage():
|
|||
|
||||
update
|
||||
= Create the file and/or do backups.
|
||||
update-fast
|
||||
= Create the file.
|
||||
update-flush
|
||||
= Create the file, after flushing ansible caches.
|
||||
update-daily
|
||||
= update-flush and do backups.
|
||||
|
||||
uptime [duration] [backup]
|
||||
= See the current state, can be filtered for uptime >= duration.
|
||||
|
|
@ -212,16 +219,17 @@ if cmd == "backups-keep":
|
|||
os.unlink(fn)
|
||||
|
||||
if cmd == "update":
|
||||
cmd = "update-flush"
|
||||
if not os.path.exists(fname):
|
||||
cmd = "update-daily" # This does the sorting etc.
|
||||
elif not os.path.exists(fname_today):
|
||||
cmd = "update-daily"
|
||||
else:
|
||||
mtime = os.path.getmtime(fname)
|
||||
if (int(time.time()) - mtime) <= (60*60*8): # 8 hours.
|
||||
if (int(time.time()) - mtime) > conf_dur_flush_cache:
|
||||
cmd = "update-fast"
|
||||
|
||||
if cmd == "update": # Get the latest uptime.
|
||||
if cmd == "update-flush": # Get the latest uptime.
|
||||
os.chdir("/srv/web/infra/ansible/playbooks")
|
||||
os.system("ansible-playbook generate-updates-uptimes-per-host-file.yml -t updates --flush-cache")
|
||||
if cmd == "update-fast": # Use ansible FACT cache for uptime.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue