Skip to content

Instantly share code, notes, and snippets.

@IPvSean
Created April 5, 2021 17:11
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 IPvSean/40bbcd85591352d6fd48e8677571e437 to your computer and use it in GitHub Desktop.
Save IPvSean/40bbcd85591352d6fd48e8677571e437 to your computer and use it in GitHub Desktop.
bgp example
---
- name: convert configured BGP resource to structured data
hosts: junos
vars:
inventory_dir: "lab_inventory"
inventory_hostname: "junos"
gather_facts: false
tasks:
- name: Use the bgp_global resource module to gather the current config
junipernetworks.junos.junos_bgp_global:
state: gathered
register: bgp_global
- name: Create inventory directory
file:
path: "{{ inventory_dir }}/host_vars/{{ inventory_hostname }}"
state: directory
- name: Write the BGP GLOBAL configuration to a file
copy:
content: "{{ {'bgp_global': bgp_global['gathered']} | to_nice_yaml }}"
dest: "{{ inventory_dir }}/host_vars/{{ inventory_hostname }}/bgp_global.yaml"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment