You may need to generate a lot of config (like interface config) where only some parts change. How to do this quickly? with Ansible. Let’s create a simple playbook file confgenerator.yml:
---
- name: Generate config
hosts: myhost ##this is not important because we will not be connecting to anything
connection: local
gather_facts: false
tasks:
- name: Generate config
template: src=configtemplate.j2 dest=config.txt
delegate_to: localhost
run_once: true
Now we create the template:
{% set intno = 1 | int % }
{% set baseip = 11 | int % }
{% for i in range(50) %}
{% set intno = intno + i %}
{% set baseip = baseip + i %}
int fa0/{{intno}}
ip addr 192.168.0.{{baseip}}
no shut
{% endfor %}
Finally we execute the playbook and voila we have config for 50 interfaces ready to paste into a Cisco device.