ansible-collections / arista.eos

Ansible Network Collection for Arista EOS
GNU General Public License v3.0
81 stars 64 forks source link

diff_against parameter in eos_config module does not use "rollback clean-config" #501

Open philippebureau opened 7 months ago

philippebureau commented 7 months ago
SUMMARY

When using parameter "diff_against = validate_config", the configuration session does not run "rollback clean-config" This causes the returned "after" value to merge the running-config "before" and provided "intended_config"

The outcome of a diff between "before" and "after" returned value show added lines but not lines that would be removed by a config replace.

This is due to line 592 in "arista.eos/plugins/modules/eos_config.py"

replace = module.params["replace"] == "config"

I believe this should be set to line

ISSUE TYPE
COMPONENT NAME

module: eos_config parameter: diff_against

ANSIBLE VERSION
ansible [core 2.14.6]
  config file = /home/phil/Documents/GitHub/AVD-CI-Demo/ansible.cfg
  configured module search path = ['/home/phil/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/phil/.local/lib/python3.10/site-packages/ansible
  ansible collection location = /home/phil/Documents/GitHub/ansible-cvp:/home/phil/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/phil/.local/bin/ansible
  python version = 3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0] (/usr/bin/python3)
  jinja version = 3.1.2
  libyaml = True
COLLECTION VERSION
Collection Version
---------- -------
arista.eos 6.2.2  
CONFIGURATION
Irrelevant
OS / ENVIRONMENT

Ubuntu 22.04

STEPS TO REPRODUCE
    - name: diff the running config against designated config
      arista.eos.eos_config:
        diff_against: validate_config
        intended_config: "{{ lookup('file', playbook_dir + '/../inventory/intended/configs/' + inventory_hostname + '.cfg') }}"
      register: config_diff

    - name: Show the difference
      ansible.utils.fact_diff:
        before: "{{ config_diff['diff']['before'] }}"
        after: "{{ config_diff['diff']['after'] }}"
EXPECTED RESULTS

see added and removed lines if a config replace would be executed

--- before
+++ after
@@ -1,18 +1,12 @@
-! Command: show running-config
+! Command: show session-configuration named ansible_170137009236
 ! device: dc1-leaf1 (vEOS-lab, EOS-4.30.2F)
 !
 ! boot system flash:/CloudEOS.swi
 !
 no aaa root
 !
-username ec2-user shell /bin/bash nopassword
-username ec2-user ssh-key ssh-rsa ssh-rsa <removed>
-username service shell /bin/bash secret sha512 <removed>
-!
-agent KernelFib environment KERNELFIB_PROGRAM_ALL_ECMP='true'
+username test_user privilege 15 role network-admin secret sha512 <removed>
 daemon TerminAttr
    exec /usr/bin/TerminAttr -cvaddr=192.168.0.5:9910 -cvauth=token,/tmp/token -smashexcludes=ale,flexCounter,hardware,kni,pulse,strata -ingestexclude=/Sysdb/cell/1/agent,/Sysdb/cell/2/agent -taillogs

image

ACTUAL RESULTS

only new lines are showed

--- before
+++ after
@@ -1,4 +1,4 @@
-! Command: show running-config
+! Command: show session-configuration named ansible_170137049678
 ! device: dc1-leaf1 (vEOS-lab, EOS-4.30.2F)
 !
 ! boot system flash:/CloudEOS.swi
@@ -11,6 +11,7 @@
 username ec2-user shell /bin/bash nopassword
 username ec2-user ssh-key ssh-rsa ssh-rsa <removed>
 username service shell /bin/bash secret sha512 <removed>
+username test_user privilege 15 role network-admin secret sha512 <removed>
 !
 agent KernelFib environment KERNELFIB_PROGRAM_ALL_ECMP='true'
 !

image