Saturday, November 23, 2019

Using Ansible to save Cisco (IOS, NX-OS, ASA) configs

I know this is only tangentially a networking question, but I figured networkers are more likely to have come up with solutions to the challenge below.

We started using Ansible modules (ios_config, nxos_config, asa_config) to save running config of our network devices to an Ansible server. I have a couple of annoyances:

  1. The playbook runs daily and saves the config to disk regardless of whether there have been any changes.
    • I looked at the documentation and didn't see a way to conditionally backup configs.
    • I'm thinking of using python or bash to do a diff between saved files and delete files that are identical.
  2. The filenames are `<host>_<date>@<time>` by default. I'd rather drop the `<time>` portion but am having a hard time using a variable from a different play to save the configs as `_`. Has anyone come up with a solution to this? I'm thinking of using `sed` to rename files, but that strikes me a clunky.

To end on a more positive note, if anyone has plays they run for their Cisco or F5 LTM gear (not config changes), or clever tricks to massage the data, feel free to share.



No comments:

Post a Comment