Hi all,
I have created a template file, which touches multiple sections, among others includes physical interfaces as well as other protocols like BGP.
I tried to apply this via 'src:', but it seems to replace the entire config only. I tried a few other things, e.g. the use of 'match' without success.
The goal is to build a configuration template for creating a service and deploy this via Ansible on multiple devices.
Is there any way to make multiple config changes via template file?
At the moment, it seems to be a bit cumbersome to do this via 'lines'.
Playbook:
---
- hosts: CE1
connection: local
vars_files:
- ASR9k-1_var_service_create.yaml
vars:
cli:
host: "{{ inventory_hostname }}"
username:
password:
transport: cli
tasks:
- name: Apply service configuration at ASR9k
register: command_out
iosxr_config:
src: ASR9k_service_creation.j2
provider: "{{ cli }}"
...
Excerpt of the template file:
!
interface {{ INTERFACE }}.{{ VLAN_ID }} l2transport
encapsulation dot1q {{ VLAN_ID }}
rewrite ingress tag pop 1 symmetric
!
interface BVI{{ VLAN_ID }}
vrf {{ VRF_NAME }}
ipv4 address {{ IP_ADDRESS }} {{ SUBNET_MASK }}
no shutdown
!
router bgp 2222
vrf {{ VRF_NAME }}
rd auto
address-family ipv4 unicast
!
neighbor {{ PE_IP_ADDRESS }}
remote-as 1111
address-family ipv4 unicast
route-policy PASS_ALL in
route-policy EBGP_MED_OUT out
!
!
neighbor {{ CE_IP_ADDRESS }}
remote-as 2222
address-family ipv4 unicast
next-hop-self
!
!
!
!
ansible 2.3.2.0
config file =
configured module search path = Default w/o overrides
python version = 2.7.6 (default, Oct 26 2016, 20:30:19) [GCC 4.8.4]
Regards,
Tim
P.S. I am aware that the documentation of this module says 'configuration sections'. I gave it a shot anyway.