Switch to filter plugin instead of python script (#14)
parent
366bacb03c
commit
24d998f0b6
@ -0,0 +1,15 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
class FilterModule(object):
|
||||||
|
def filters(self):
|
||||||
|
return {
|
||||||
|
'keep_last': self._keep_last,
|
||||||
|
}
|
||||||
|
|
||||||
|
"""
|
||||||
|
_keep_last keeps the last n items of a list of lists
|
||||||
|
"""
|
||||||
|
def _keep_last(self, list_of_lists, num_to_keep):
|
||||||
|
lists_to_return = []
|
||||||
|
for list_items in list_of_lists:
|
||||||
|
lists_to_return.append(list_items[0:-num_to_keep])
|
||||||
|
return lists_to_return
|
||||||
@ -1,21 +0,0 @@
|
|||||||
#!/usr/bin/python
|
|
||||||
import os
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
|
||||||
s3_result = eval(os.getenv("S3_RESULTS"))
|
|
||||||
num_backups_to_keep = int(os.getenv("NUM_BACKUPS_TO_KEEP"))
|
|
||||||
|
|
||||||
items_to_delete = []
|
|
||||||
for res in s3_result:
|
|
||||||
s3_keys = res["s3_keys"]
|
|
||||||
# fetch all of the backups before the desired number.
|
|
||||||
# these are the ones we want to delete.
|
|
||||||
items_to_delete.extend(s3_keys[0:-num_backups_to_keep])
|
|
||||||
|
|
||||||
for item in items_to_delete:
|
|
||||||
print(item)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
main()
|
|
||||||
@ -1,21 +0,0 @@
|
|||||||
#!/usr/bin/python
|
|
||||||
import os
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
|
||||||
s3_result = eval(os.getenv("S3_RESULTS"))
|
|
||||||
num_backups_to_keep = int(os.getenv("NUM_BACKUPS_TO_KEEP"))
|
|
||||||
|
|
||||||
items_to_delete = []
|
|
||||||
for res in s3_result:
|
|
||||||
s3_keys = res["s3_keys"]
|
|
||||||
# fetch all of the backups before the desired number.
|
|
||||||
# these are the ones we want to delete.
|
|
||||||
items_to_delete.extend(s3_keys[0:-num_backups_to_keep])
|
|
||||||
|
|
||||||
for item in items_to_delete:
|
|
||||||
print(item)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
main()
|
|
||||||
@ -1,3 +1,4 @@
|
|||||||
[defaults]
|
[defaults]
|
||||||
roles_path = roles
|
roles_path = roles
|
||||||
vault_password_file=tests/vault_key.sh
|
vault_password_file=tests/vault_key.sh
|
||||||
|
filter_plugins = plugins/filter
|
||||||
|
|||||||
Loading…
Reference in New Issue