Description
SUMMARY
When using the nxos_config module and providing the desired config via a template passed to the src argument, any differences are replaced line by line. Trying to set replace=block throws the following error:
msg: 'replace is block but all of the following are missing: lines'
This can cause issues such as in my use case of managing route-maps. The template generates a route-map configuration. If existing config does not match, I need to first remove the existing configuration, before attempting to apply the new config. Otherwise the net result can be unpredictable as the route-map configs are not atomic.
ISSUE TYPE
- Bug Report
COMPONENT NAME
nxos_config module
ANSIBLE VERSION
config file = /etc/ansible/ansible.cfg
configured module search path = [u'/home/mhorn/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python2.7/dist-packages/ansible
executable location = /usr/bin/ansible
python version = 2.7.15rc1 (default, Apr 15 2018, 21:51:34) [GCC 7.3.0]
CONFIGURATION
OS / ENVIRONMENT
Behavior appears independent of nxos version, have tested against 6.x 7.x and 9.x
STEPS TO REPRODUCE
route-map.j2
route-map test permit 10
description "First Sequence"
route-map test permit 20
description "second sequence"
test.yml
---
- hosts: lab1-n-excsw01
gather_facts: no
tasks:
- name: Apply route-map
nxos_config:
src: route-map.j2
before: "no route-map test"
replace: block
save_when: changed
diff_against: running
EXPECTED RESULTS
If the running config matches, no changes are made. If it does not match, the 'before' parameter of 'no route-map test' is run, and then all lines of the the src template are configured
ACTUAL RESULTS
Run as above, the following error is thrown:
msg: 'replace is block but all of the following are missing: lines'
Run without 'replace=block', results are not consistent. For example, running the above when only the first sequence exists first removes the route-map, but then only applies the missing second sequence. Repeated runs will oscillate between one section of the config or the other being applied, but never the desired config in it's entirety.
root@localhost:/etc/ansible$ ansible-playbook -i inventory/lab test.yml --diff
PLAY [lab1-n-excsw01] ****************************************************************************************************************************************
TASK [Apply route-map] ***************************************************************************************************************************************
--- before
+++ after
@@ -80,8 +80,8 @@
-route-map test permit 10
- description "First Sequence"
+route-map test permit 20
+ description "second sequence"
changed: [lab1-n-excsw01]
PLAY RECAP ***************************************************************************************************************************************************
lab1-n-excsw01 : ok=1 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
root@localhost:/etc/ansible$ ansible-playbook -i inventory/lab test.yml --diff
PLAY [lab1-n-excsw01] ****************************************************************************************************************************************
TASK [Apply route-map] ***************************************************************************************************************************************
--- before
+++ after
@@ -80,8 +80,8 @@
-route-map test permit 20
- description "second sequence"
+route-map test permit 10
+ description "First Sequence"
changed: [lab1-n-excsw01]
PLAY RECAP ***************************************************************************************************************************************************
lab1-n-excsw01 : ok=1 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
root@localhost:/etc/ansible$ ansible-playbook -i inventory/lab test.yml --diff
PLAY [lab1-n-excsw01] ****************************************************************************************************************************************
TASK [Apply route-map] ***************************************************************************************************************************************
--- before
+++ after
@@ -80,8 +80,8 @@
-route-map test permit 10
- description "First Sequence"
+route-map test permit 20
+ description "second sequence"
changed: [lab1-n-excsw01]
PLAY RECAP ***************************************************************************************************************************************************
lab1-n-excsw01 : ok=1 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
Metadata
Metadata
Assignees
Type
Projects
Status
Done
Activity