Skip to content

Instantly share code, notes, and snippets.

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 rohitthakur2590/b0e183b5e3eb4bd76d947b3e495f6920 to your computer and use it in GitHub Desktop.
Save rohitthakur2590/b0e183b5e3eb4bd76d947b3e495f6920 to your computer and use it in GitHub Desktop.
BGP address family inventory builder example
---
- name: convert configured BGP address family resource to structured data
hosts: junos
vars:
inventory_dir: "lab_inventory"
inventory_hostname: "junos"
gather_facts: false
tasks:
- name: Use the bgp_address_family resource module to gather the current config
junipernetworks.junos.junos_bgp_address_family:
state: gathered
register: bgp_address_family
- name: Create inventory directory
file:
path: "{{ inventory_dir }}/host_vars/{{ inventory_hostname }}"
state: directory
- name: Write the BGP Address Family configuration to a file
copy:
content: "{{ {'bgp_address_family': bgp_address_family['gathered']} | to_nice_yaml }}"
dest: "{{ inventory_dir }}/host_vars/{{ inventory_hostname }}/bgp_address_family.yaml"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment