Ansible windows

Hi,

I’m trying to filter files newer than some other file.

So, I list that file, get his creationtime, after that I calculate the difference between the current time and the creation time of that file. That is the difference in days between today and day when the file is created.

BUT, I work with fucking windows, and, there I got epoch with comma, not dot. And I’m unable to calculate difference. If I try to get int valčue from epoch, calculated value is zero.

For example, this is output of setup module on windows:

“ansible_date_time”: {
“date”: “2018-05-02”,
“day”: “02”,
“epoch”: “1525275022,0416”,

My idea was to calculate before how much day file was created with following formula:

days_since_last_backup: “{{ ((current_epoch|int - item.creationtime|int)/86400)|int }}”

But I got negative value since ansible can’t calculate integer value from some variable which has comma in self.

So, is there some option to replace in variable/string comma with dot.

hint: use replace filter :slight_smile: (To replace comma into dot)

{{ variable | replace(‘,’,’.’) }}

Probably you’ll need to use set_fact as well.

Best,
Karol

Thank you Karol…

For now I solve this issue using python slicing. That was my backup option.
But it is pretty weird that Ansible can’t work with a comma in creationtime instead of a dot.

Dana srijeda, 2. svibnja 2018. u 16:36:09 UTC+2, korisnik Karol Czeryna napisao je: