Hi,
Still discovering Ansible, … and Python by the way, well…
I’m rewriting the lineinfile module to match my enterprise’s needs, and I have an issue with the backup function.
We want to backup file, with our standard time-stamp, aka %file%.YYYYMMDD
I found the original module.backup_local function in ./lib/ansible/module_common.py, which use only one time-stamp format:
ext = time.strftime(“%Y-%m-%d@%H:%M~”, time.localtime(time.time()))
I try the replace the call to this function by my own function… need to figure how to do it, learning Python…
1/ Is there already something plan to customize the backup time-stamp ?
2/ Is it possible to add a overcharged backup_local function, allowing to specify the time-stamp ?
def backup_local(self, fn, tsf):
‘’‘make a date-marked backup of the specified file, return True or False on success or failure’‘’backups named basename-YYYY-MM-DD@HH:MM~
ext = time.strftime(tsf, time.localtime(time.time()))
backupdest = ‘%s.%s’ % (fn, ext)
try:
shutil.copy2(fn, backupdest)
except shutil.Error, e:
self.fail_json(msg=‘Could not make backup of %s to %s: %s’ % (fn, backupdest, e))
return backupdest
Regards,