Skip to content

Instantly share code, notes, and snippets.

@nleiva
Created June 16, 2023 18:03
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/354589d18a73f7202ca9aaece89a6b4a to your computer and use it in GitHub Desktop.
Save nleiva/354589d18a73f7202ca9aaece89a6b4a to your computer and use it in GitHub Desktop.
Ansible native parser template
- example: "object-group network TEST-NETWORK"
getval: 'object-group\s(?P<type>\S+)\s(?P<name>\S+)'
result:
"{{ name }}":
name: "{{ name }}"
type: "{{ type }}"
shared: True
- example: " network-object host 100.64.0.1"
getval: '\snetwork-object\shost\s(?P<host>\S+)'
result:
"{{ name }}":
{host: ["{{ host }}"]}
- example: "service-object tcp destination eq ftp"
getval: '\sservice-object\stcp\sdestination\seq\s(?P<port>\S+)'
result:
"{{ name }}":
{tcp: ["{{ port }}"]}
- example: "service-object object NAME"
getval: '\s*service-object\sobject\s(?P<object>\S+)'
result:
"{{ name }}":
{object : ["{{ object }}"] }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment