Adding new route to cisco router Jinja2 template

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

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

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.

Hello All,

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

- 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
Kind Regards,
Rodrigo