Manages BGP Global configuration on devices running Juniper JUNOS.
Version added: 1.3.0
- This module manages global bgp configuration on devices running Juniper JUNOS.
The below requirements are needed on the host that executes this module.
- ncclient (>=v0.6.4)
- xmltodict (>=0.12.0)
Note
- This module requires the netconf system service be enabled on the device being managed.
- This module works with connection
netconf
. See the Junos OS Platform Options. - Tested against JunOS v18.4R1
# Using merged
#
# Before state:
# -------------
#
# vsrx# show bgp summary
# BGP is not running
# vsrx# show routing-options autonomous-system
- name: Merge provided bgp config with device configuration
junipernetworks.junos.junos_bgp_global:
config:
as_number: "65534"
loops: 3
asdot_notation: true
accept_remote_nexthop: true
add_path_display_ipv4_address: true
advertise_from_main_vpn_tables: true
advertise_inactive: true
authentication_algorithm: "md5"
bgp_error_tolerance:
malformed_route_limit: 20000000
bmp:
monitor: true
damping: true
description: "This is configured with Junos_bgp resource module"
egress_te_sid_stats: true
hold_time: 5
holddown_all_stale_labels: true
include_mp_next_hop: true
log_updown: true
no_advertise_peer_as: true
no_aggregator_id: true
no_client_reflect: true
out_delay: 10
precision_timers: true
preference: 2
state: merged
# Task Output:
# ------------
# before: {}
#
# commands:
# - <nc:protocols xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0"><nc:bgp><nc:accept-remote-nexthop/>
# <nc:add-path-display-ipv4-address/><nc:advertise-from-main-vpn-tables/><nc:advertise->
# - <nc:routing-options xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">
# <nc:autonomous-system>65534<nc:loops>3</nc:loops><nc:asdot-notation/></nc:autonomous-system></nc:routing-options>
#
# after:
# accept_remote_nexthop: true
# add_path_display_ipv4_address: true
# advertise_from_main_vpn_tables: true
# advertise_inactive: true
# as_number: '65534'
# asdot_notation: true
# authentication_algorithm: md5
# bgp_error_tolerance:
# malformed_route_limit: 20000000
# bmp:
# monitor: true
# damping: true
# description: This is configured with Junos_bgp resource module
# egress_te_sid_stats: true
# hold_time: 5
# holddown_all_stale_labels: true
# include_mp_next_hop: true
# log_updown: true
# loops: 3
# no_advertise_peer_as: true
# no_aggregator_id: true
# no_client_reflect: true
# out_delay: 10
# precision_timers: true
# preference: '2'
# After state:
# ------------
#
# vsrx# show routing-options autonomous-system
# 65534 loops 3 asdot-notation;
# vsrx# show protocols bgp
# precision-timers;
# advertise-from-main-vpn-tables;
# holddown-all-stale-labels;
# description "This is configured with Junos_bgp resource module";
# accept-remote-nexthop;
# preference 2;
# hold-time 5;
# advertise-inactive;
# no-advertise-peer-as;
# no-aggregator-id;
# out-delay 10;
# log-updown;
# damping;
# bgp-error-tolerance {
# malformed-route-limit 20000000;
# }
# authentication-algorithm md5;
# no-client-reflect;
# include-mp-next-hop;
# bmp {
# monitor enable;
# }
# add-path-display-ipv4-address;
# egress-te-sid-stats;
# Using replaced
#
# Before state:
# -------------
#
# vsrx# show routing-options autonomous-system
# [edit]
# vsrx# show protocols bgp
# precision-timers;
# advertise-from-main-vpn-tables;
# holddown-all-stale-labels;
# description "This is configured with Junos_bgp resource module";
# accept-remote-nexthop;
# preference 2;
# hold-time 5;
# advertise-inactive;
# no-advertise-peer-as;
# no-aggregator-id;
# out-delay 10;
# log-updown;
# damping;
# bgp-error-tolerance {
# malformed-route-limit 20000000;
# }
# authentication-algorithm md5;
# no-client-reflect;
# include-mp-next-hop;
# bmp {
# monitor enable;
# }
# add-path-display-ipv4-address;
# egress-te-sid-stats;
- name: Replace running config with provided config
junipernetworks.junos.junos_bgp_global:
config:
advertise_inactive: true
authentication_algorithm: "md5"
bfd_liveness_detection:
minimum_receive_interval: 8
multiplier: 30
no_adaptation: true
transmit_interval:
minimum_interval: 4
version: "automatic"
bgp_error_tolerance:
malformed_route_limit: 40000000
description: "Replace running bgp config"
egress_te_sid_stats: true
hold_time: 5
out_delay: 10
preference: "2"
state: replaced
# Task Output:
# ------------
#
# before:
# accept_remote_nexthop: true
# add_path_display_ipv4_address: true
# advertise_from_main_vpn_tables: true
# advertise_inactive: true
# as_number: '65534'
# asdot_notation: true
# authentication_algorithm: md5
# bgp_error_tolerance:
# malformed_route_limit: 20000000
# bmp:
# monitor: true
# damping: true
# description: This is configured with Junos_bgp resource module
# egress_te_sid_stats: true
# hold_time: 5
# holddown_all_stale_labels: true
# include_mp_next_hop: true
# log_updown: true
# loops: 3
# no_advertise_peer_as: true
# no_aggregator_id: true
# no_client_reflect: true
# out_delay: 10
# precision_timers: true
# preference: '2'
# commands:
# - <nc:protocols xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0"><nc:bgp>
# <nc:accept-remote-nexthop delete="delete"/><nc:add-path-display-ipv4-address delete="delete"/><nc:advertise-bgp-t
# delete="delete"/><nc:include-mp-next-hop delete="delete"/><nc:ipsec-sa delete="delete"/><nc:keep delete="delete"/>
# <nc:local-address delete="delete"/><nc:local-interface delete="delete"/t
# delete="delete"/></nc:bgp><nc:bgp><nc:advertise-inactive/><nc:egress-te-sid-stats/>
# <nc:authentication-algorithm>md5</nc:authentication-algorithm><nc:description>Replace running bgp conf>
# - <nc:routing-options xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0"><nc:autonomous-system delete="delete"/></nc:routing-options>
#
# after:
# advertise_inactive: true
# authentication_algorithm: md5
# bfd_liveness_detection:
# minimum_receive_interval: 8
# multiplier: 30
# no_adaptation: true
# transmit_interval:
# minimum_interval: 4
# version: automatic
# bgp_error_tolerance:
# malformed_route_limit: 40000000
# description: Replace running bgp config
# egress_te_sid_stats: true
# hold_time: 5
# out_delay: 10
# preference: '2'
# After state:
# ------------
#
# varx# show protocols bgp
# description "Replace running bgp config";
# preference 2;
# hold-time 5;
# advertise-inactive;
# out-delay 10;
# bgp-error-tolerance {
# malformed-route-limit 40000000;
# }
# authentication-algorithm md5;
# bfd-liveness-detection {
# version automatic;
# minimum-receive-interval 8;
# multiplier 30;
# no-adaptation;
# transmit-interval {
# minimum-interval 4;
# }
# }
# egress-te-sid-stats;
# vsrx# show routing-options autonomous-system
# Using overridden
# "(NOTE: This will work same as replaced operation)"
#
# Before state:
# -------------
#
# vsrx# show routing-options autonomous-system
# [edit]
# vsrx# show protocols bgp
# precision-timers;
# advertise-from-main-vpn-tables;
# holddown-all-stale-labels;
# description "This is configured with Junos_bgp resource module";
# accept-remote-nexthop;
# preference 2;
# hold-time 5;
# advertise-inactive;
# no-advertise-peer-as;
# no-aggregator-id;
# out-delay 10;
# log-updown;
# damping;
# bgp-error-tolerance {
# malformed-route-limit 20000000;
# }
# authentication-algorithm md5;
# no-client-reflect;
# include-mp-next-hop;
# bmp {
# monitor enable;
# }
# add-path-display-ipv4-address;
# egress-te-sid-stats;
- name: Override running config with provided config
junipernetworks.junos.junos_bgp_global:
config:
advertise_inactive: true
authentication_algorithm: "md5"
bfd_liveness_detection:
minimum_receive_interval: 8
multiplier: 30
no_adaptation: true
transmit_interval:
minimum_interval: 4
version: "automatic"
bgp_error_tolerance:
malformed_route_limit: 40000000
description: "Replace running bgp config"
egress_te_sid_stats: true
hold_time: 5
out_delay: 10
preference: "2"
state: overridden
# Task Output:
# ------------
#
# before:
# accept_remote_nexthop: true
# add_path_display_ipv4_address: true
# advertise_from_main_vpn_tables: true
# advertise_inactive: true
# as_number: '65534'
# asdot_notation: true
# authentication_algorithm: md5
# bgp_error_tolerance:
# malformed_route_limit: 20000000
# bmp:
# monitor: true
# damping: true
# description: This is configured with Junos_bgp resource module
# egress_te_sid_stats: true
# hold_time: 5
# holddown_all_stale_labels: true
# include_mp_next_hop: true
# log_updown: true
# loops: 3
# no_advertise_peer_as: true
# no_aggregator_id: true
# no_client_reflect: true
# out_delay: 10
# precision_timers: true
# preference: '2'
# commands:
# - <nc:protocols xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0"><nc:bgp>
# <nc:accept-remote-nexthop delete="delete"/><nc:add-path-display-ipv4-address delete="delete"/><nc:advertise-bgp-t
# delete="delete"/><nc:include-mp-next-hop delete="delete"/><nc:ipsec-sa delete="delete"/><nc:keep delete="delete"/>
# <nc:local-address delete="delete"/><nc:local-interface delete="delete"/t
# delete="delete"/></nc:bgp><nc:bgp><nc:advertise-inactive/><nc:egress-te-sid-stats/>
# <nc:authentication-algorithm>md5</nc:authentication-algorithm><nc:description>Replace running bgp conf>
# - <nc:routing-options xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0"><nc:autonomous-system delete="delete"/></nc:routing-options>
#
# after:
# advertise_inactive: true
# authentication_algorithm: md5
# bfd_liveness_detection:
# minimum_receive_interval: 8
# multiplier: 30
# no_adaptation: true
# transmit_interval:
# minimum_interval: 4
# version: automatic
# bgp_error_tolerance:
# malformed_route_limit: 40000000
# description: Replace running bgp config
# egress_te_sid_stats: true
# hold_time: 5
# out_delay: 10
# preference: '2'
# After state:
# ------------
#
# varx# show protocols bgp
# description "Replace running bgp config";
# preference 2;
# hold-time 5;
# advertise-inactive;
# out-delay 10;
# bgp-error-tolerance {
# malformed-route-limit 40000000;
# }
# authentication-algorithm md5;
# bfd-liveness-detection {
# version automatic;
# minimum-receive-interval 8;
# multiplier 30;
# no-adaptation;
# transmit-interval {
# minimum-interval 4;
# }
# }
# egress-te-sid-stats;
# vsrx# show routing-options autonomous-system
# Using deleted
# "(NOTE: This WILL delete the bgp global attributes)"
# Before state
# ------------
#
# vsrx# show protocols bgp
# description "Replace running bgp config";
# preference 2;
# hold-time 5;
# advertise-inactive;
# out-delay 10;
# bgp-error-tolerance {
# malformed-route-limit 40000000;
# }
# authentication-algorithm md5;
# bfd-liveness-detection {
# version automatic;
# minimum-receive-interval 8;
# multiplier 30;
# no-adaptation;
# transmit-interval {
# minimum-interval 4;
# }
# }
# egress-te-sid-stats;
- name: Delete bgp section of running config
junipernetworks.junos.junos_bgp_global:
config:
state: deleted
# Task Output:
# ------------
# before:
# advertise_inactive: true
# authentication_algorithm: md5
# bfd_liveness_detection:
# minimum_receive_interval: 8
# multiplier: 30
# no_adaptation: true
# transmit_interval:
# minimum_interval: 4
# version: automatic
# bgp_error_tolerance:
# malformed_route_limit: 40000000
# description: Replace running bgp config
# egress_te_sid_stats: true
# hold_time: 5
# out_delay: 10
# preference: '2'
# commands:
# - <nc:protocols xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0"><nc:bgp><nc:accept-remote-nexthop delete="delete"/>
# <nc:add-path-display-ipv4-address delete="delete"/><nc:advertise-bgp-t
# delete="delete"/><nc:include-mp-next-hop delete="delete"/><nc:ipsec-sa delete="delete"/><nc:keep delete="delete"/>
# <nc:local-address delete="delete"/><nc:local-interface delete="delete"/t
# delete="delete"/></nc:bgp></nc:protocols>
# - <nc:routing-options xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0"/>
# after: {}
# After state:
# ------------
# vsrx# show protocols bgp
# vsrx# show routing-options autonomous-system
# Using gathered
#
# Before state:
# -------------
#
# vsrx# show protocols bgp
# precision-timers;
# advertise-from-main-vpn-tables;
# holddown-all-stale-labels;
# description "This is configured with Junos_bgp resource module";
# accept-remote-nexthop;
# preference 2;
# hold-time 5;
# advertise-inactive;
# no-advertise-peer-as;
# no-aggregator-id;
# out-delay 10;
# log-updown;
# damping;
# bgp-error-tolerance {
# malformed-route-limit 20000000;
# }
# authentication-algorithm md5;
# no-client-reflect;
# include-mp-next-hop;
# bmp {
# monitor enable;
# }
# add-path-display-ipv4-address;
# egress-te-sid-stats;
- name: Gather BGP facts from running config
junipernetworks.junos.junos_bgp_global:
config:
state: gathered
# Task Output:
# ------------
# gathered:
# accept_remote_nexthop: true
# add_path_display_ipv4_address: true
# advertise_from_main_vpn_tables: true
# advertise_inactive: true
# as_number: '65534'
# asdot_notation: true
# authentication_algorithm: md5
# bgp_error_tolerance:
# malformed_route_limit: 20000000
# bmp:
# monitor: true
# damping: true
# description: This is configured with Junos_bgp resource module
# egress_te_sid_stats: true
# hold_time: 5
# holddown_all_stale_labels: true
# include_mp_next_hop: true
# log_updown: true
# loops: 3
# no_advertise_peer_as: true
# no_aggregator_id: true
# no_client_reflect: true
# out_delay: 10
# precision_timers: true
# preference: '2'
# Using purged
# "(NOTE: This WILL delete the configured global BGP, and BGP address family config)"
# Before state:
# -------------
#
# vsrx# show protocols bgp
# precision-timers;
# advertise-from-main-vpn-tables;
# holddown-all-stale-labels;
# description "This is configured with Junos_bgp resource module";
# accept-remote-nexthop;
# preference 2;
# hold-time 5;
# advertise-inactive;
# no-advertise-peer-as;
# no-aggregator-id;
# out-delay 10;
# log-updown;
# damping;
# bgp-error-tolerance {
# malformed-route-limit 20000000;
# }
# authentication-algorithm md5;
# no-client-reflect;
# include-mp-next-hop;
# bmp {
# monitor enable;
# }
# add-path-display-ipv4-address;
# egress-te-sid-stats;
- name: Purge BGP config from running config
junipernetworks.junos.junos_bgp_global:
config:
state: purged
# Task Output:
# ------------
# before:
# accept_remote_nexthop: true
# add_path_display_ipv4_address: true
# advertise_from_main_vpn_tables: true
# advertise_inactive: true
# as_number: '65534'
# asdot_notation: true
# authentication_algorithm: md5
# bgp_error_tolerance:
# malformed_route_limit: 20000000
# bmp:
# monitor: true
# damping: true
# description: This is configured with Junos_bgp resource module
# egress_te_sid_stats: true
# hold_time: 5
# holddown_all_stale_labels: true
# include_mp_next_hop: true
# log_updown: true
# loops: 3
# no_advertise_peer_as: true
# no_aggregator_id: true
# no_client_reflect: true
# out_delay: 10
# precision_timers: true
# preference: '2'
# commands:
# - <nc:protocols xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0"><nc:bgp delete="delete"/></nc:protocols>
# - <nc:routing-options xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">
# <nc:autonomous-system delete="delete"/></nc:routing-options>
# after: {}
# After state:
# ------------
# vsrx# show protocols bgp
# vsrx# show routing-options autonomous-system
# Using rendered
- name: Render the commands for provided configuration
junipernetworks.junos.junos_bgp_global:
config:
as_number: "65534"
loops: 3
asdot_notation: true
accept_remote_nexthop: true
add_path_display_ipv4_address: true
advertise_from_main_vpn_tables: true
advertise_inactive: true
authentication_algorithm: "md5"
bgp_error_tolerance:
malformed_route_limit: 20000000
bmp:
monitor: true
damping: true
description: "This is configured with Junos_bgp resource module"
egress_te_sid_stats: true
hold_time: 5
holddown_all_stale_labels: true
include_mp_next_hop: true
log_updown: true
no_advertise_peer_as: true
no_aggregator_id: true
no_client_reflect: true
out_delay: 10
precision_timers: true
preference: 2
state: rendered
# Task Output:
# ------------
# rendered:
# <nc:protocols xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">
# <nc:bgp><nc:accept-remote-nexthop/><nc:add-path-display-ipv4-address/>
# <nc:advertise-from-main-vpn-tables/><nc:ad>
#
# Using parsed
# parsed.cfg
# ------------
# <?xml version="1.0" encoding="UTF-8"?>
# <rpc-reply message-id="urn:uuid:0cadb4e8-5bba-47f4-986e-72906227007f">
# <configuration changed-seconds="1590139550" changed-localtime="2020-05-22 09:25:50 UTC">
# <version>18.4R1-S2.4</version>
# <protocols>
# <bgp>
# <precision-timers />
# <advertise-from-main-vpn-tables />
# <holddown-all-stale-labels />
# <description>This is configured with Junos_bgp resource module</description>
# <accept-remote-nexthop />
# <preference>2</preference>
# <hold-time>5</hold-time>
# <advertise-inactive />
# <no-advertise-peer-as />
# <no-aggregator-id />
# <out-delay>10</out-delay>
# <log-updown />
# <damping />
# <bgp-error-tolerance>
# <malformed-route-limit>20000000</malformed-route-limit>
# </bgp-error-tolerance>
# <authentication-algorithm>md5</authentication-algorithm>
# <remove-private />
# <no-client-reflect />
# <include-mp-next-hop />
# <bmp>
# <monitor>disable</monitor>
# <route-monitoring>
# <none />
# </route-monitoring>
# </bmp>
# <advertise-bgp-static>
# <policy>static-to-bgp</policy>
# </advertise-bgp-static>
# <add-path-display-ipv4-address />
# <bfd-liveness-detection>
# <version>automatic</version>
# <minimum-receive-interval>4</minimum-receive-interval>
# <multiplier>10</multiplier>
# <no-adaptation />
# <transmit-interval>
# <minimum-interval>2</minimum-interval>
# </transmit-interval>
# <detection-time>
# <threshold>300000</threshold>
# </detection-time>
# </bfd-liveness-detection>
# <egress-te-sid-stats />
# <group>
# <name>internal</name>
# <out-delay>8</out-delay>
# </group>
# <group>
# <name>external</name>
# <out-delay>9</out-delay>
# </group>
# <group>
# <name>inboun</name>
# <type>internal</type>
# </group>
# <group>
# <name>ibgp</name>
# <type>internal</type>
# <local-address>10.2.2.2</local-address>
# <export>static-to-bgp</export>
# <neighbor>
# <name>10.1.1.1</name>
# </neighbor>
# </group>
# </bgp>
# <ospf3>
# <area>
# <name>0.0.0.100</name>
# <stub>
# <default-metric>200</default-metric>
# </stub>
# <interface>
# <name>so-0/0/0.0</name>
# <metric>5</metric>
# <priority>3</priority>
# </interface>
# </area>
# </ospf3>
# </protocols>
# <routing-options>
# <static>
# <route>
# <name>172.16.17.0/24</name>
# <discard />
# </route>
# </static>
# <router-id>10.200.16.75</router-id>
# <autonomous-system>
# <as-number>65432</as-number>
# </autonomous-system>
# </routing-options>
# </configuration>
# </rpc-reply>
- name: Parsed the device configuration to get ansible facts
junipernetworks.junos.junos_bgp_global:
running_config: "{{ lookup('file', './parsed.cfg') }}"
state: parsed
# Task Output:
# ------------
# parsed:
# accept_remote_nexthop: true
# add_path_display_ipv4_address: true
# advertise_bgp_static:
# policy: static-to-bgp
# advertise_from_main_vpn_tables: true
# advertise_inactive: true
# as_number: '65432'
# authentication_algorithm: md5
# bfd_liveness_detection:
# detection_time:
# threshold: 300000
# minimum_receive_interval: 4
# multiplier: 10
# no_adaptation: true
# transmit_interval:
# minimum_interval: 2
# version: automatic
# bgp_error_tolerance:
# malformed_route_limit: 20000000
# bmp:
# monitor: false
# route_monitoring:
# none: true
# damping: true
# description: This is configured with Junos_bgp resource module
# egress_te_sid_stats: true
# groups:
# - name: internal
# out_delay: 8
# - name: external
# out_delay: 9
# - name: inboun
# type: internal
# - export: static-to-bgp
# local_address: 10.2.2.2
# name: ibgp
# neighbors:
# - neighbor_address: 10.1.1.1
# type: internal
# hold_time: 5
# holddown_all_stale_labels: true
# include_mp_next_hop: true
# log_updown: true
# no_advertise_peer_as: true
# no_aggregator_id: true
# no_client_reflect: true
# out_delay: 10
# precision_timers: true
# preference: '2'
# remove_private:
# set: true
Common return values are documented here, the following are the fields unique to this module:
- Rohit Thakur (@rohitthakur2590)