I am currently using Ansible to generate running configuration for the
network devices. Here is the simple scenario I have.
I have defined the interface type (routed, access, trunk) in the variables
file and then created a jinja file that will generate the necessary
configuration based on variables definition.
Below is the sample variable definition and jinja template configuration:
CONFIG:
- { id: Ethernet1/1, type: routed }
- { id: Ethernet1/2, type: access }
- { id: Ethernet1/3, type: trunk }
Jinja:
{% if int.type == 'routed' %}
no switchport
{% elif int.type == 'access' %}
switchport mode access
switchport access vlan 10
spanning-tree portfast
{% elif int.type == 'trunk' %}
switchport mode trunk
{% endif %}
This works perfectly fine when I define the variables, generate the
configuration and push it to the device. So, below is how the interface
config will look like on the device after pushing the config:
interface Ethernet1/1
no switchport
interface Ethernet1/2
switchport mode access
switchport access vlan 10
spanning-tree portfast
interface Ethernet1/3
switchport mode trunk
Now, I want to change Ethernet1/2 to trunk and Ethernet1/3 to access. What
happens is that Ansible pushes "switchport mode trunk" to Ethernet1/2, but
doesn't remove "switchport access vlan 10" and "spanning-tree portfast"
which are not needed anymore. The behavior is consistent for both
ios_config and eos_config. I already tried the diff_against running
option, but it still doesn't seem to work. Any suggestions on how to fix
this would be truly appreciated? If you need more details around this,
please let me know.
--
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/c6d60a00-ca2c-41f9-b578-a2e7134e529d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.