Created
June 16, 2023 18:13
-
-
Save nleiva/955e163f8b9ccb54b7d4798a5f85efd5 to your computer and use it in GitHub Desktop.
Parsing Cisco ASA with a Ansible native parser
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- 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