napalm-automation / napalm-ansible

Apache License 2.0
245 stars 103 forks source link

conform diff format with ansible format #180

Closed fabrepe closed 4 years ago

fabrepe commented 4 years ago

Ansible allows diff between object before and after module (using --diff flag). Modules, and especially napalm modules can support the ansible's format (see https://blog.networktocode.com/blog/post/generating-diff-with-ansible/#ansible-module-development--how-to-add-diff-support-to-your-module).

It may be pretty easy to implement, by modifying : https://github.com/napalm-automation/napalm-ansible/blob/845723ab6bb1d5c896c5519d08a6dbbcd27b2e4d/napalm_ansible/modules/napalm_install_config.py#L334

to

module.exit_json(changed=changed, msg=diff, diff={"prepared": diff})