Can anyone tell me there is a solution I can use to do the same thing a
Python range function in Ansible?
Scenario:
Variables I am using
access_hostname:
- name: dariusz_access1
nodeid_access: 1001
from_port: '04'
vlanid:
- 201-204,500-510
podid: 1
int_mode: regular
depl_immediacy: lazy
- name: dariusz_access2
nodeid_access: 1001
from_port: '05'
vlanid:
- 10,1200
podid: 1
int_mode: regular
depl_immediacy: lazy
What I want to achieve is to expand my 'vlanid' variable into a list of
individual items:
So from this
vlanid:
- 201-204,500-510
to something like this, hopefully to the use that info in loops, etc.
dariusz_access1:
vlanid:
- '0201'
- '0202'
- '0203'
- '0204'
- '0500'
- '0501'
- '0502'
- '0503'
- '0504'
- '0505'
- '0506'
- '0507'
- '0508'
- '0509'
- '0510'
- |-
dariusz_access2:
vlanid:
- '0010'
- '1200'
I also need to get a leading zero '0' added to each vlanid that is not 4
characters in length.
The idea is to avoid having to ask the end user to input each vlanid
individually, which could take some time.
I have a python code that can split the ranges for me, with no problem, but
if there was an option in Ansible, i would prefer that.
Any guidance would be great.
--
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/904dbcd3-a1eb-4cf7-95cf-5e9bcf594294%40googlegroups.com.