Skip to content

Instantly share code, notes, and snippets.

View nleiva's full-sized avatar
☠️
Working from somewhere

Nicolas Leiva nleiva

☠️
Working from somewhere
View GitHub Profile
@nleiva
nleiva / create_vn.yml
Last active August 2, 2023 19:16
Creating a VNET on Azure
- name: Create Virtual Network "VNET NAME"
azure.azcollection.azure_rm_virtualnetwork:
name: "VNET NAME"
resource_group: "RESOURCE GROUP NAME"
address_prefixes_cidr:
- "172.16.0.0/16"
tags:
Environment: "OPTIONAL"
@nleiva
nleiva / native_parser_asa_loop.yml
Created June 16, 2023 18:13
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
@nleiva
nleiva / native_parser_asa_object.yml
Created June 16, 2023 18:03
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+)'
@nleiva
nleiva / ntc_asa_loop.yml
Created June 16, 2023 17:47
Parsing Cisco ASA with a NTC template
- name: Parse config with ntc_templates
ansible.utils.cli_parse:
text: "{{ lookup('file', config) }}"
parser:
name: ansible.netcommon.ntc_templates
os: cisco_asa
command: "show running-config {{ ( item ) | replace('_',' ') }}"
set_fact: "{{ item | replace('-','_') }}"
loop:
- ipsec
@nleiva
nleiva / resource_module_asa_acl.yml
Created June 16, 2023 17:37
Parsing ACLs with a Network Resource Module
- name: Parse ACLs for provided configuration
cisco.asa.asa_acls:
running_config: "{{ lookup('file', config) }}"
state: parsed
ignore_errors: true
register: asa_acls
vars:
ansible_connection: ansible.netcommon.network_cli
ansible_network_os: cisco.asa.asa
- name: Delete SSH Key Pair for instance
amazon.aws.ec2_key:
name: "{{ ec2_resource_prefix }}-key"
region: "{{ ec2_region }}"
state: absent
- name: Delete AWS VPC
amazon.aws.ec2_vpc_net:
name: "{{ ec2_resource_prefix }}-vpc"
cidr_block: "{{ ec2_cidr_block }}"
region: "{{ ec2_region }}"
state: absent
- name: Delete Route Table
community.aws.ec2_vpc_route_table:
region: "{{ ec2_region }}"
vpc_id: "{{ all_vpcs.vpcs[0].vpc_id }}"
tags:
Environment: "{{ ec2_environment }}"
Name: "{{ ec2_resource_prefix }}-route-table"
state: absent
- name: Delete internet gateway in Environment {{ ec2_environment }}
community.aws.ec2_vpc_igw:
region: "{{ ec2_region }}"
vpc_id: "{{ item.vpc_id }}"
state: absent
loop: '{{ all_vpcs.vpcs }}'
- name: Delete Subnet
amazon.aws.ec2_vpc_subnet:
region: "{{ ec2_region }}"
vpc_id: "{{ all_vpcs.vpcs[0].vpc_id }}"
cidr: "{{ ec2_subnet }}"
state: absent