hsngztk
(hasan goztok)
April 1, 2026, 11:21am
1
Hi!
I need to create an inventory which consists vms that created past week. config.createDate format is ansible_date_time.iso8601
Do you have any suggestion to do that?
filters:
- runtime.powerState == "poweredOn"
- config.guestId is not match('windows*')
- config.name is match('test*')
- config.createDate >= "{{ '%Y-%m-%dT%H:%M:%SZ'|strftime( (ansible_date_time.epoch|int) - (60*60*24*7)) }}" #not works
# - config.createDate <= "{{ ansible_date_time.iso8601 }}" #gathered all vms as expected
# - config.createDate >= "2026-03-25T00:00:00Z" #works but need to dynamically update
mariolenz
(Mario Lenz)
April 1, 2026, 2:37pm
2
I don’t know how to do it. However, are we talking about community.vmware.vmware_vm_inventory here?
If so, please note that this has been deprecated in 5.4.0 and will be removed in 7.0.0 in half a year or so. I dont know how to do it with vmware.vmware.vms , either, but maybe you should try to find a solution for this plugin. It would be more future-proof.
2 Likes
hsngztk
(hasan goztok)
April 10, 2026, 3:32pm
3
Thanks for advice.
I created a group with
groups:
newly_created: config.createDate > "{{ lookup('pipe', 'date -d \"7 days ago\" +%Y-%m-%dT%H:%M:%S') }}"
Then I created a smart inventory for filtering by group name
I thought I could handle it with filters in inventory yaml, it seems to have limited capabilities for arithmetic operations.