# How to pass range of input with vars\_prompt

**URL:** <https://forum.ansible.com/t/how-to-pass-range-of-input-with-vars-prompt/29349>\
**Category:** Ansible Project\
**Created:** [January 2, 2019, 10:48am UTC](https://forum.ansible.com/t/how-to-pass-range-of-input-with-vars-prompt/29349 "2019-01-02T10:48:37Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![a.srini](https://avatars.discourse-cdn.com/v4/letter/a/958977/32.png) [@a.srini](https://forum.ansible.com/u/a.srini)\
**Post date:** [January 2, 2019, 10:48am UTC](https://forum.ansible.com/t/how-to-pass-range-of-input-with-vars-prompt/29349/1 "2019-01-02T10:48:37Z")

</div>

Hi Experts,

I have a question, can we pass a range of inputs with vars\_prompt.  
example:  
From the below playbook, i am able to pass multiple port numbers split by **“,”**.

```auto
prompt: Please enter the port name: 0/1,0/2,0/3,0/4,0/5

```

But when I want to pass the input of ports in a range.

```auto
prompt: Please enter the port name: 0/1-0/5

```

Any suggestion on how to pass that.

```auto
- hosts: localhost
  gather_facts: no
  vars_prompt:
  - name: ip_addr
    prompt: Please enter the switch name
    private: no
  - name: port_name
    prompt: Please enter the port name
    private: no

  vars_files:
    - ../vars/password.yml

  vars:
    port_speed: "8"

  tasks:
  - add_host:
      name: "{{ip_addr}}"
      groups: dynamically_created_hosts
    with_items: "{{ip_addr.split(',')}}" 
  - name: Change port speed
    port_speed_change:
      switch_ip: "{{item}}"
      user: "{{user}}"
      password: "{{password}}"
      checkmode: "{{ansible_check_mode}}"
      name: "{{port_name}}"
      speed: "{{port_speed}}"

```

---

<div class="post-metadata">

**Author:** ![Eric\_Leung](https://avatars.discourse-cdn.com/v4/letter/e/ee7513/32.png) [@Eric\_Leung](https://forum.ansible.com/u/Eric_Leung)\
**Post date:** [January 2, 2019, 10:56am UTC](https://forum.ansible.com/t/how-to-pass-range-of-input-with-vars-prompt/29349/2 "2019-01-02T10:56:04Z")

</div>

Hi,

This should be done via using Jinjia2.

This blog should give you some ideas.

[https://codingnetworker.com/2015/09/configuration-generator-with-python-and-jinja2/](https://codingnetworker.com/2015/09/configuration-generator-with-python-and-jinja2/)

Regards,  
Eric.
