# Adding new route to cisco router Jinja2 template

**URL:** <https://forum.ansible.com/t/adding-new-route-to-cisco-router-jinja2-template/24451>\
**Category:** Ansible Project\
**Created:** [May 10, 2017, 5:37pm UTC](https://forum.ansible.com/t/adding-new-route-to-cisco-router-jinja2-template/24451 "2017-05-10T17:37:48Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![naeem\_dhby](https://avatars.discourse-cdn.com/v4/letter/n/b38774/32.png) [@naeem\_dhby](https://forum.ansible.com/u/naeem_dhby)\
**Post date:** [May 10, 2017, 5:37pm UTC](https://forum.ansible.com/t/adding-new-route-to-cisco-router-jinja2-template/24451/1 "2017-05-10T17:37:48Z")

</div>

Hi,

i have configured Cisco router and i want to setup automation to only add new route to router, and do not change any old configuration already exist in router  
is it possible to use Jinja2 template for this case, i’m new in Ansible and also just started working on jinja2 templates, in examples i reviewed look like i need to create Jinja2 template file for each part of configuration and by using “include” i’ll merge all of them in one main file, and by using group\_vars i’ll set variables, and result will be one config file you can import to network device, but i didn’t see any example to just add new line to existing configuration in network device.

i know i can do this by using ios\_command module, but just want to know if it is possible to do this with Jinja2 template.

Thanks

---

<div class="post-metadata">

**Author:** ![Cody\_John](https://avatars.discourse-cdn.com/v4/letter/c/8e7dd6/32.png) [@Cody\_John](https://forum.ansible.com/u/Cody_John)\
**Post date:** [May 19, 2017, 12:26am UTC](https://forum.ansible.com/t/adding-new-route-to-cisco-router-jinja2-template/24451/2 "2017-05-19T00:26:30Z")

</div>

Any reason not to use ios\_config module along with the src parameter pointing to your jinja template?

---

<div class="post-metadata">

**Author:** ![naeem\_dhby](https://avatars.discourse-cdn.com/v4/letter/n/b38774/32.png) [@naeem\_dhby](https://forum.ansible.com/u/naeem_dhby)\
**Post date:** [May 19, 2017, 12:40am UTC](https://forum.ansible.com/t/adding-new-route-to-cisco-router-jinja2-template/24451/3 "2017-05-19T00:40:10Z")

</div>

Thanks Cody for your reply

so you mean i can create my jinja2 template for routing and just use ios\_config with src parameter to merge my template to my router? is that will create new line to my configuration, i know “before” and “after” parameters exist in ios\_config but can i use that parameters with in src parameter and template file?For example i have 3 static route already in my router, can i add only 2 more route to router with ios\_config by using jinja2 template without changing other configs or reuse old config file?

Thanks again.

---

<div class="post-metadata">

**Author:** ![Rodrigo](https://avatars.discourse-cdn.com/v4/letter/r/4af34b/32.png) [@Rodrigo](https://forum.ansible.com/u/Rodrigo)\
**Post date:** [May 19, 2017, 3:42am UTC](https://forum.ansible.com/t/adding-new-route-to-cisco-router-jinja2-template/24451/4 "2017-05-19T03:42:09Z")

</div>

Hello All,

I believe you can use this example to add more routes.

```auto
- name: load new acl into device
  ios_config:
    lines:
      - 10 permit ip host 1.1.1.1 any log
      - 20 permit ip host 2.2.2.2 any log
      - 30 permit ip host 3.3.3.3 any log
      - 40 permit ip host 4.4.4.4 any log
      - 50 permit ip host 5.5.5.5 any log
    parents: ip access-list extended test
    before: no ip access-list extended test
    match: exact

```

```auto
Kind Regards,

```

```auto
Rodrigo

```
