This works for me:
---
- hosts: localhost
connection: local
gather_facts: no
vars:
vlan_range: 1-9,100-103,201-204,500-507,600-604,1000-1003
tasks:
- set_fact:
vlans: "{{ vlans|default([]) | union(lookup('sequence',
item.split('-')|first + '-' + item.split('-')|last + ':%04d',
wantlist=True )) }}"
loop: "{{ vlan_range.split(',') }}"
- debug: var=vlans
TASK [debug] **********************************************************************************
ok: [localhost] =>
vlans:
- '0001'
- '0002'
- '0003'
- '0004'
- '0005'
- '0006'
- '0007'
- 0008
- 0009
- '0100'
- '0101'
- '0102'
- '0103'
- '0201'
- '0202'
- '0203'
- '0204'
- '0500'
- '0501'
- '0502'
- '0503'
- '0504'
- '0505'
- '0506'
- '0507'
- '0600'
- '0601'
- '0602'
- '0603'
- '0604'
- '1000'
- '1001'
- '1002'
- '1003'
The only thing I don't understand is how to make the formatting
understand that this is decimal - the 0008 and 0009 are treated as
octal.
Adding "map('string') |list" doesn't fix that.
Dick
> --
> You received this message because you are subscribed to the Google Groups "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
ansible-proje...@googlegroups.com.
> To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/904dbcd3-a1eb-4cf7-95cf-5e9bcf594294%40googlegroups.com.
--
Dick Visser
Trust & Identity Service Operations Manager
GÉANT