Skip to content

Instantly share code, notes, and snippets.

@dpflick
Created October 2, 2019 01:38
Show Gist options
  • Save dpflick/471ab493e4ef3234e15ea56df7f05aba to your computer and use it in GitHub Desktop.
Save dpflick/471ab493e4ef3234e15ea56df7f05aba to your computer and use it in GitHub Desktop.
The idea was to write code generic enough to be able to handle multiple variable sets so that I could run the same code and generate a different VPN depending on the particular host variable. Here is some concept code:
host_vars at inventory level
file: myasa.yml
contents:
---
vpnpeername: 'VPNPEER1'
...
Top level group_vars would have all possible VPN connections
sample group_vars at playbook level
VPNPEER1:
services_legacy_network_description: 'Skippy Data Center Network'
services_legacy_network_ip: '10.10.1.0'
services_legacy_network_mask: '255.255.255.0'
VPNPEER2:
services_legacy_network_description: 'Jiff Data Center Network'
services_legacy_network_ip: '10.11.1.0'
services_legacy_network_mask: '255.255.255.0'
VPNPEER3:
services_legacy_network_description: 'Smuckers Data Center Network'
services_legacy_network_ip: '10.11.1.0'
services_legacy_network_mask: '255.255.255.0'
And in the role, reference these variables like this but the problem is that I have no idea how to make the variable that could be generic enough to use the same code for any input.
- name: configure network object-group for L2L VPN
asa_og:
name: '{{ vpnpeername }}'_SERVICES
group_type: network-object
state: present
description: '{{ vpnpeer1.services_legacy_network_description }}' <--I know this wont' work
ip_mask:
- '{{ vpnpeer1.services_legacy_network_ip }}' '{{ vpnpeer1.services_legacy_network_mask }}' <--I know this wont' work
I don't think it is possible to do something like this:
description: '{{ {{ vpnpeername }}.services_legacy_network_description }}'
ip_mask:
- '{{ {{ vpnpeername }}.services_legacy_network_ip }}' '{{ {{ vpnpeername }}.services_legacy_network_mask }}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment