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/ Regards, Eric. On Wednesday, January 2, 2019 at 6:48:37 PM UTC+8, srinivas a wrote: > > > 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 > *","*. > > 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. > > prompt: Please enter the port name: 0/1-0/5 > > > Any suggestion on how to pass that. > > - 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}}" > > -- 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 post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/a2233f97-e941-416b-b96b-962e0325e256%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
