Skip to content

Instantly share code, notes, and snippets.

@nleiva
Created June 16, 2023 18:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nleiva/955e163f8b9ccb54b7d4798a5f85efd5 to your computer and use it in GitHub Desktop.
Save nleiva/955e163f8b9ccb54b7d4798a5f85efd5 to your computer and use it in GitHub Desktop.
Parsing Cisco ASA with a Ansible native parser
- name: Parse config with native parser
ansible.utils.cli_parse:
text: "{{ lookup('file', config) }}"
parser:
name: ansible.netcommon.native
os: cisco_asa
command: "{{ ( item ) | replace('_',' ') }}"
set_fact: "{{ item | replace('-','_') }}"
loop:
- object
- object_group
- name: Save configs parsed with native parser
ansible.builtin.copy:
content: "{{ item.content | ansible.builtin.to_nice_yaml }}"
dest: "/output/asa_{{ item.name }}.cfg"
loop:
- name: object
content: "{{ object.values() | list }}"
- name: object_group
content: "{{ object_group.values() | list }}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment