Created
June 17, 2021 11:18
-
-
Save rohitthakur2590/b0e183b5e3eb4bd76d947b3e495f6920 to your computer and use it in GitHub Desktop.
BGP address family inventory builder example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
- 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