diff options
Diffstat (limited to 'ansible_collections/dellemc/enterprise_sonic/playbooks')
20 files changed, 1141 insertions, 0 deletions
diff --git a/ansible_collections/dellemc/enterprise_sonic/playbooks/bgp_l3_fabric/clos-fabric.yaml b/ansible_collections/dellemc/enterprise_sonic/playbooks/bgp_l3_fabric/clos-fabric.yaml new file mode 100644 index 00000000..27e20c08 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/playbooks/bgp_l3_fabric/clos-fabric.yaml @@ -0,0 +1,43 @@ +--- +- hosts: datacenter + connection: httpapi + gather_facts: no + collections: + - dellemc.enterprise_sonic + tasks: + - name: Create Interfaces + sonic_interfaces: + config: "{{sonic_interfaces}}" + when: sonic_interfaces is defined and sonic_interfaces + + - name: Create L3 Interfaces + sonic_l3_interfaces: + config: "{{sonic_l3_interfaces}}" + when: sonic_l3_interfaces is defined and sonic_l3_interfaces + + - name: "Push configs for clos-fabric usecase" + vars: + ansible_connection: network_cli + sonic_config: + src: clos_fabric_cfg.j2 + register: result + + - name: Create BGP configuration + sonic_bgp: + config: "{{sonic_bgp}}" + when: sonic_bgp is defined and sonic_bgp + + - name: Create BGP AF configuration + sonic_bgp_af: + config: "{{sonic_bgp_af}}" + when: sonic_bgp_af is defined and sonic_bgp_af + + - name: Create BGP Neighbors configuration + sonic_bgp_neighbors: + config: "{{sonic_bgp_neighbors}}" + when: sonic_bgp_neighbors is defined and sonic_bgp_neighbors + + - name: Create BGP Neighbors AF configuration + sonic_bgp_neighbors_af: + config: "{{sonic_bgp_neighbors_af}}" + when: sonic_bgp_neighbors_af is defined and sonic_bgp_neighbors_af diff --git a/ansible_collections/dellemc/enterprise_sonic/playbooks/bgp_l3_fabric/group_vars/all.yaml b/ansible_collections/dellemc/enterprise_sonic/playbooks/bgp_l3_fabric/group_vars/all.yaml new file mode 100644 index 00000000..526f29e2 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/playbooks/bgp_l3_fabric/group_vars/all.yaml @@ -0,0 +1,49 @@ +ansible_user: admin +ansible_password: admin +ansible_network_os: dellemc.enterprise_sonic.sonic + +# Changing the interface name here will be reflected in all places +# Spine to Leaf interface connections +spine_leaf1_inf1: Eth1/1 +spine_leaf2_inf2: Eth1/2 +spine_leaf25_inf3: Eth1/25 +spine_leaf26_inf4: Eth1/26 + +# Leaf to spine interface connections +leaf_spine1_inf1: Eth1/14 +leaf_spine2_inf2: Eth1/15 + +# Logical interface defintions +loopback_inf0: Loopback0 +loopback_inf1: Loopback1 + +host_data: + leaf1: + loopback0_ip: 10.0.2.1/32 + loopback1_ip: 10.10.10.1/32 + bgp_asn: 65001 + leaf2: + loopback0_ip: 10.0.2.2/32 + loopback1_ip: 10.10.10.2/32 + bgp_asn: 65001 + leaf25: + loopback0_ip: 10.0.2.25/32 + loopback1_ip: 10.10.10.25/32 + bgp_asn: 65025 + leaf26: + loopback0_ip: 10.0.2.26/32 + loopback1_ip: 10.10.10.26/32 + bgp_asn: 65025 + spine1: + loopback0_ip: 10.0.1.1/32 + bgp_asn: 65000 + spine2: + loopback0_ip: 10.0.1.2/32 + bgp_asn: 65000 + +ansible_httpapi_use_ssl: true +ansible_httpapi_validate_certs: false + +loopback0_ip: "{{ host_data[inventory_hostname].loopback0_ip }}" +loopback1_ip: "{{host_data[inventory_hostname].loopback1_ip}}" +bgp_asn: "{{ host_data[inventory_hostname].bgp_asn }}" diff --git a/ansible_collections/dellemc/enterprise_sonic/playbooks/bgp_l3_fabric/group_vars/leaf.yaml b/ansible_collections/dellemc/enterprise_sonic/playbooks/bgp_l3_fabric/group_vars/leaf.yaml new file mode 100644 index 00000000..ad524d42 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/playbooks/bgp_l3_fabric/group_vars/leaf.yaml @@ -0,0 +1,103 @@ +sonic_interfaces: + - name: "{{ leaf_spine1_inf1 }}" + description: "{{ leaf_spine1_inf1 }} Spine1" + enabled: true + - name: "{{ leaf_spine2_inf2 }}" + description: "{{ leaf_spine2_inf2 }} Spine2" + enabled: true + - name: "{{ loopback_inf0 }}" + - name: "{{ loopback_inf1 }}" + +sonic_l3_interfaces: + - name: "{{ loopback_inf0 }}" + ipv4: + addresses: + - address: "{{ loopback0_ip }}" + - name: "{{ loopback_inf1 }}" + ipv4: + addresses: + - address: "{{ loopback1_ip }}" + - name: "{{ leaf_spine1_inf1 }}" + ipv6: + enabled: true + - name: "{{ leaf_spine2_inf2 }}" + ipv6: + enabled: true + +sonic_route_maps_cli: + - name: REDISTU + permit: true + seq: 10 + match_ip_prefix_list: UNDERLAY + - name: REDISTL3 + permit: true + seq: 10 + match_ip_prefix_list: L3OVERLAY + +sonic_prefix_list_cli: + - name: UNDERLAY + permit: true + entries: + - ip: 10.0.2.0/24 + condition: ge 32 le 32 + seq: 1 + - ip: 10.10.10.0/24 + condition: ge 32 le 32 + seq: 2 + - name: L3OVERLAY + permit: true + entries: + - ip: 192.168.50.0/24 + seq: 3 + +sonic_bgp: + - bgp_as: "{{ bgp_asn }}" + router_id: "{{ loopback0_ip.split('/')[0] }}" + bestpath: + as_path: + multipath_relax: true + +sonic_bgp_af: + - bgp_as: "{{ bgp_asn }}" + address_family: + afis: + - afi: l2vpn + safi: evpn + advertise_all_vni: true + - afi: ipv4 + safi: unicast + redistribute: + - protocol: connected + route_map: REDISTU + +sonic_bgp_neighbors: + - bgp_as: "{{ bgp_asn }}" + peer_group: + - name: SPINE + remote_as: + peer_type: external + advertisement_interval: 5 + timers: + keepalive: 3 + holdtime: 9 + bfd: + check_failure: true + enabled: true + profile: 'profile 1' + capability: + extended_nexthop: true + address_family: + afis: + - afi: l2vpn + safi: evpn + activate: true + - afi: ipv4 + safi: unicast + activate: true + allowas_in: + value: 2 + neighbors: + - neighbor: "{{ leaf_spine1_inf1 }}" + peer_group: SPINE + - neighbor: "{{ leaf_spine2_inf2 }}" + peer_group: SPINE diff --git a/ansible_collections/dellemc/enterprise_sonic/playbooks/bgp_l3_fabric/group_vars/spine.yaml b/ansible_collections/dellemc/enterprise_sonic/playbooks/bgp_l3_fabric/group_vars/spine.yaml new file mode 100644 index 00000000..e3116407 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/playbooks/bgp_l3_fabric/group_vars/spine.yaml @@ -0,0 +1,87 @@ +loopback_inf0: Loopback0 + +sonic_interfaces: + - name: "{{ spine_leaf1_inf1 }}" + description: "{{ spine_leaf1_inf1 }} Leaf1" + enabled: true + - name: "{{ spine_leaf2_inf2 }}" + description: "{{ spine_leaf2_inf2 }} Leaf2" + enabled: true + - name: "{{ spine_leaf25_inf3 }}" + description: "{{ spine_leaf25_inf3 }} Leaf25" + enabled: true + - name: "{{ spine_leaf26_inf4 }}" + description: "{{ spine_leaf26_inf4 }} Leaf26" + enabled: true + - name: "{{ loopback_inf0 }}" + +sonic_l3_interfaces: + - name: "{{ loopback_inf0 }}" + ipv4: + addresses: + - address: "{{ loopback0_ip }}" + - name: "{{ spine_leaf1_inf1 }}" + ipv6: + enabled: true + - name: "{{ spine_leaf2_inf2 }}" + ipv6: + enabled: true + - name: "{{ spine_leaf25_inf3 }}" + ipv6: + enabled: true + - name: "{{ spine_leaf26_inf4 }}" + ipv6: + enabled: true + +sonic_bgp: + - bgp_as: "{{ bgp_asn }}" + router_id: "{{ loopback0_ip.split('/')[0] }}" + bestpath: + as_path: + multipath_relax: true + +sonic_bgp_af: + - bgp_as: "{{ bgp_asn }}" + address_family: + afis: + - afi: l2vpn + safi: evpn + advertise_all_vni: true + - afi: ipv4 + safi: unicast + redistribute: + - protocol: connected + +sonic_bgp_neighbors: + - bgp_as: "{{ bgp_asn }}" + peer_group: + - name: LEAF + remote_as: + peer_type: external + advertisement_interval: 5 + timers: + keepalive: 3 + holdtime: 9 + bfd: + check_failure: true + enabled: true + profile: 'profile1' + capability: + extended_nexthop: true + address_family: + afis: + - afi: l2vpn + safi: evpn + activate: true + - afi: ipv4 + safi: unicast + activate: true + neighbors: + - neighbor: "{{ spine_leaf1_inf1 }}" + peer_group: LEAF + - neighbor: "{{ spine_leaf2_inf2 }}" + peer_group: LEAF + - neighbor: "{{ spine_leaf25_inf3 }}" + peer_group: LEAF + - neighbor: "{{ spine_leaf26_inf4 }}" + peer_group: LEAF diff --git a/ansible_collections/dellemc/enterprise_sonic/playbooks/bgp_l3_fabric/inventory.yaml b/ansible_collections/dellemc/enterprise_sonic/playbooks/bgp_l3_fabric/inventory.yaml new file mode 100644 index 00000000..26845da3 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/playbooks/bgp_l3_fabric/inventory.yaml @@ -0,0 +1,20 @@ +spine1 ansible_host=100.94.81.19 +spine2 ansible_host=100.10.10.2 +leaf1 ansible_host=100.94.81.17 +leaf2 ansible_host=100.10.10.4 +leaf25 ansible_host=100.10.10.5 +leaf26 ansible_host=100.10.10.6 + +[leaf] +leaf1 +leaf2 +leaf25 +leaf26 + +[spine] +spine1 +spine2 + +[datacenter:children] +leaf +spine diff --git a/ansible_collections/dellemc/enterprise_sonic/playbooks/bgp_l3_fabric/templates/clos_fabric_cfg.j2 b/ansible_collections/dellemc/enterprise_sonic/playbooks/bgp_l3_fabric/templates/clos_fabric_cfg.j2 new file mode 100644 index 00000000..cbb4732f --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/playbooks/bgp_l3_fabric/templates/clos_fabric_cfg.j2 @@ -0,0 +1,25 @@ +#jinja2: trim_blocks: True, lstrip_blocks: True +{####################################### + +#Purpose: +BGP L3 Fabric usecase configuration for SONiC devices + +#######################################} +{# prefix list start #} +{% if sonic_prefix_list_cli is defined and sonic_prefix_list_cli %} + {% for sonic_prefix in sonic_prefix_list_cli %} + {% for prefix_entires in sonic_prefix.entries %} +ip prefix-list {{ sonic_prefix.name }} seq {{ prefix_entires.seq }} {{ 'permit' if sonic_prefix.permit else 'deny' }} {{ prefix_entires.ip }} {{ prefix_entires.condition if prefix_entires.condition is defined else ''}} + {% endfor %} + {% endfor %} +{% endif %} +{# prefix list end #} + +{# Route map configuration start #} +{% if sonic_route_maps_cli is defined and sonic_route_maps_cli %} + {% for sonic_route_map in sonic_route_maps_cli %} +route-map {{ sonic_route_map.name }} {{ 'permit' if sonic_route_map.permit else 'deny' }} {{ sonic_route_map.seq }} + match ip address prefix-list {{ sonic_route_map.match_ip_prefix_list }} + {% endfor %} +{% endif %} +{# Route map configuration start #} diff --git a/ansible_collections/dellemc/enterprise_sonic/playbooks/common_examples/hosts b/ansible_collections/dellemc/enterprise_sonic/playbooks/common_examples/hosts new file mode 100644 index 00000000..b1214247 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/playbooks/common_examples/hosts @@ -0,0 +1,12 @@ +sonic1 ansible_host=100.94.81.17 ansible_user=admin ansible_password=admin +sonic2 ansible_host=100.94.81.19 ansible_user=admin ansible_password=admin + +[datacenter] +sonic1 +sonic2 + +[datacenter:vars] +ansible_network_os=dellemc.enterprise_sonic.sonic +ansible_python_interpreter=/usr/bin/python3 +ansible_httpapi_use_ssl=true +ansible_httpapi_validate_certs=false diff --git a/ansible_collections/dellemc/enterprise_sonic/playbooks/common_examples/interface_naming.yaml b/ansible_collections/dellemc/enterprise_sonic/playbooks/common_examples/interface_naming.yaml new file mode 100644 index 00000000..36901572 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/playbooks/common_examples/interface_naming.yaml @@ -0,0 +1,32 @@ +--- +- hosts: datacenter + connection: network_cli + gather_facts: no + collections: + - dellemc.enterprise_sonic + tasks: + - name: "Configure description for interface in native name" + sonic_config: + commands: + - description Ethernet0 + parents: + - interface Ethernet0 + + # Same prompt and answer for cli "no interface-naming standard" + - name: "Configure cli with prompts on SONiC device" + sonic_config: + commands: + - command: "interface-naming standard" + prompt: "Broadcast message: Interface naming mode has changed. Users running 'sonic-cli' are required to restart your session." + answer: "\n" + + - name: "reset ssh connection" + meta: reset_connection + + - name: "Configure description for interface in standard name" + sonic_config: + commands: + - description Eth1/1 + parents: + - interface Eth1/1 + diff --git a/ansible_collections/dellemc/enterprise_sonic/playbooks/common_examples/patch.txt b/ansible_collections/dellemc/enterprise_sonic/playbooks/common_examples/patch.txt new file mode 100644 index 00000000..94a5a760 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/playbooks/common_examples/patch.txt @@ -0,0 +1,8 @@ +{"openconfig-if-ip:ipv4": { + "addresses": { + "address": [ + { + "ip": "131.1.1.1", + "config": {"ip": "131.1.1.1", "prefix-length": 24} + }]}} + } diff --git a/ansible_collections/dellemc/enterprise_sonic/playbooks/common_examples/sonic_aaa.yaml b/ansible_collections/dellemc/enterprise_sonic/playbooks/common_examples/sonic_aaa.yaml new file mode 100644 index 00000000..7d968b83 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/playbooks/common_examples/sonic_aaa.yaml @@ -0,0 +1,79 @@ +--- +- name: Ansible resource module example for sonic_aaa + hosts: datacenter + gather_facts: False + connection: httpapi + collections: + - dellemc.enterprise_sonic + tasks: + - name: delete all users + sonic_users: + config: + state: deleted + - name: delete all aaa + sonic_aaa: + config: + state: deleted + - name: delete all tacacs servers + sonic_tacacs_server: + config: + state: deleted + - name: delete all radius servers + sonic_radius_server: + config: + state: deleted + - name: Merge users configurations + sonic_users: + config: + - name: sysadmin + role: admin + password: admin + update_password: always + - name: sysoperator + role: operator + password: operator + update_password: always + state: merged + - name: Test SONiC aaa + sonic_aaa: + config: + authentication: + data: + fail_through: true + group: tacacs+ + local: true + state: merged + - name: Merge tacacs configurations + sonic_tacacs_server: + config: + auth_type: pap + key: pap + source_interface: Eth 1/2 + timeout: 10 + servers: + host: + - name: 1.2.3.4 + auth_type: pap + key: 1234 + state: merged + - name: Merge radius configurations + sonic_radius_server: + config: + auth_type: chap + key: chap + nas_ip: 1.2.3.4 + statistics: true + timeout: 10 + retransmit: 3 + servers: + host: + - name: localhost + auth_type: mschapv2 + key: local + priority: 2 + port: 52 + retransmit: 2 + timeout: 20 + source_interface: Eth 1/2 + vrf: mgmt + state: merged diff --git a/ansible_collections/dellemc/enterprise_sonic/playbooks/common_examples/sonic_api.yaml b/ansible_collections/dellemc/enterprise_sonic/playbooks/common_examples/sonic_api.yaml new file mode 100644 index 00000000..4c1c07cf --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/playbooks/common_examples/sonic_api.yaml @@ -0,0 +1,37 @@ +--- +- name: Ansible resource module example + hosts: datacenter + gather_facts: False + connection: httpapi + collections: + - dellemc.enterprise_sonic + tasks: + - name: "Test patch_api" + sonic_api: + url: data/openconfig-interfaces:interfaces/interface=Eth1%2f26/config/description + method: "PATCH" + status_code: 204 + body: {"openconfig-interfaces:description": "hi "} + - name: "Test patch_api" + sonic_api: + url: data/openconfig-interfaces:interfaces/interface=Eth1%2f26/subinterfaces/subinterface=0/openconfig-if-ip:ipv4/ + method: "PATCH" + status_code: 204 + body: "{{ lookup('file','patch.txt') }}" + - name: "Test put_api" + sonic_api: + url: data/openconfig-network-instance:network-instances/network-instance=Vlan100 + method: "PUT" + body: {"openconfig-network-instance:network-instance": [{"name": "Vlan100", "config": {"name": "Vlan100"}}]} + status_code: 204 + - name: "Test get_api" + sonic_api: + url: data/openconfig-interfaces:interfaces/interface=Eth1%2f26 + method: "GET" + status_code: 200 + - name: "Test delete_api" + sonic_api: + url: data/openconfig-interfaces:interfaces/interface=Eth1%2f26/subinterfaces/subinterface=0/openconfig-if-ip:ipv4/addresses/address=131.1.1.1/config/prefix-length + method: "DELETE" + status_code: 204 + diff --git a/ansible_collections/dellemc/enterprise_sonic/playbooks/common_examples/sonic_bgp.yaml b/ansible_collections/dellemc/enterprise_sonic/playbooks/common_examples/sonic_bgp.yaml new file mode 100644 index 00000000..c3784f98 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/playbooks/common_examples/sonic_bgp.yaml @@ -0,0 +1,321 @@ +--- +- name: Ansible Enterprise SONiC BGP resource module example + hosts: datacenter + gather_facts: False + connection: httpapi + collections: + - dellemc.enterprise_sonic + vars: + bgp_as1: 4 + bgp_as2: 10 + bgp_as3: 11 + vrf1: VrfCheck1 + tasks: + - name: "Configure route map configurations" + vars: + ansible_connection: network_cli + sonic_config: + commands: + - route-map aa permit 11 + - route-map bb permit 22 + - ip prefix-list p1 seq 1 permit 1.1.1.0/24 + - ip prefix-list p2 seq 2 permit 2.2.2.128/25 + save: yes + - name: Configure VRFs + sonic_vrfs: + config: + - name: "{{vrf1}}" + - name: "Test sonic_bgp" + sonic_bgp: + config: + - bgp_as: "{{bgp_as1}}" + router_id: 10.2.2.4 + log_neighbor_changes: False + bestpath: + as_path: + confed: True + ignore: True + multipath_relax: False + multipath_relax_as_set: True + compare_routerid: True + med: + confed: True + missing_as_worst: True + max_med: + on_startup: + timer: 667 + med_val: 7878 + - bgp_as: "{{bgp_as2}}" + log_neighbor_changes: True + vrf_name: "{{vrf1}}" + bestpath: + as_path: + confed: False + ignore: True + multipath_relax_as_set: True + compare_routerid: True + med: + confed: True + missing_as_worst: True + max_med: + on_startup: + timer: 332 + med_val: 9987 + state: merged + - name: "Test sonic_bgp_af merge 01" + sonic_bgp_af: + config: + - bgp_as: "{{bgp_as1}}" + address_family: + afis: + - afi: ipv4 + safi: unicast + advertise_all_vni: false + redistribute: + - metric: "20" + protocol: connected + route_map: aa + - metric: "26" + protocol: ospf + route_map: bb + - metric: "25" + protocol: static + route_map: aa + - afi: ipv6 + safi: unicast + advertise_all_vni: true + redistribute: + - metric: "21" + protocol: connected + route_map: bb + - metric: "27" + protocol: ospf + route_map: aa + - metric: "28" + protocol: static + route_map: aa + - afi: l2vpn + safi: evpn + advertise_all_vni: True + advertise_default_gw: True + route_advertise_list: + - advertise_afi: ipv4 + route_map: aa + - advertise_afi: ipv6 + route_map: bb + - bgp_as: "{{bgp_as2}}" + vrf_name: "{{vrf1}}" + address_family: + afis: + - afi: ipv4 + safi: unicast + redistribute: + - metric: "20" + protocol: connected + route_map: aa + - metric: "26" + protocol: ospf + route_map: bb + - metric: "25" + protocol: static + route_map: aa + - afi: ipv6 + safi: unicast + redistribute: + - metric: "21" + protocol: connected + route_map: bb + - metric: "27" + protocol: ospf + route_map: aa + - metric: "28" + protocol: static + route_map: aa + - afi: l2vpn + safi: evpn + advertise_default_gw: True + route_advertise_list: + - advertise_afi: ipv4 + route_map: aa + - advertise_afi: ipv6 + route_map: bb + state: merged + - name: "Test sonic_bgp_neighbors merged state" + sonic_bgp_neighbors: + config: + - bgp_as: "{{bgp_as1}}" + peer_group: + - name: SPINE + remote_as: + peer_type: internal + bfd: + check_failure: true + enabled: true + profile: 'profile 1' + advertisement_interval: 15 + timers: + keepalive: 50 + holdtime: 40 + capability: + dynamic: true + extended_nexthop: true + address_family: + afis: + - afi: ipv4 + safi: unicast + ip_afi: + default_policy_name: aa + send_default_route: false + prefix_limit: + max_prefixes: 200 + prevent_teardown: false + warning_threshold: 88 + restart_timer: 5 + prefix_list_in: p2 + prefix_list_out: p1 + - name: SPINE2 + neighbors: + - neighbor: Eth1/1 + remote_as: + peer_type: internal + peer_group: SPINE + advertisement_interval: 10 + timers: + keepalive: 40 + holdtime: 50 + bfd: + enabled: false + capability: + dynamic: true + extended_nexthop: true + - neighbor: 192.168.1.4 + - neighbor: Eth1/2 + remote_as: + peer_as: 3 + peer_group: SPINE2 + advertisement_interval: 20 + timers: + keepalive: 30 + holdtime: 20 + capability: + dynamic: true + - bgp_as: "{{bgp_as2}}" + vrf_name: "{{vrf1}}" + peer_group: + - name: SPINE3 + remote_as: + peer_type: internal + bfd: + check_failure: false + enabled: true + profile: 'profile 3' + advertisement_interval: 15 + timers: + keepalive: 50 + holdtime: 40 + capability: + dynamic: true + extended_nexthop: true + neighbors: + - neighbor: Eth1/11 + peer_group: SPINE3 + - neighbor: Eth1/12 + state: merged + - name: "Test sonic_bgp_neighbors_af merge 01" + sonic_bgp_neighbors_af: + config: + - bgp_as: "{{bgp_as1}}" + neighbors: + - neighbor: Eth1/1 + address_family: + - afi: ipv4 + safi: unicast + activate: true + allowas_in: + value: 6 + route_map: + - name: aa + direction: out + - name: bb + direction: in + route_reflector_client: false + route_server_client: true + - neighbor: Eth1/2 + address_family: + - afi: ipv4 + safi: unicast + activate: true + allowas_in: + origin: true + route_map: + - name: aa + direction: out + - name: bb + direction: in + route_reflector_client: true + route_server_client: true + ip_afi: + default_policy_name: bb + send_default_route: true + prefix_limit: + max_prefixes: 100 + prevent_teardown: true + warning_threshold: 80 + prefix_list_in: p1 + prefix_list_out: p2 + - bgp_as: "{{bgp_as2}}" + vrf_name: "{{vrf1}}" + neighbors: + - neighbor: Eth1/11 + address_family: + - afi: ipv4 + safi: unicast + activate: true + allowas_in: + value: 6 + route_map: + - name: aa + direction: out + - name: bb + direction: in + route_reflector_client: false + route_server_client: true + - afi: ipv6 + safi: unicast + activate: true + allowas_in: + value: 6 + route_map: + - name: aa + direction: out + - name: bb + direction: in + route_reflector_client: false + route_server_client: true + - neighbor: Eth1/12 + address_family: + - afi: ipv4 + safi: unicast + activate: true + allowas_in: + origin: true + route_map: + - name: aa + direction: out + - name: bb + direction: in + route_reflector_client: true + route_server_client: true + - afi: ipv6 + safi: unicast + activate: true + allowas_in: + value: 2 + route_map: + - name: aa + direction: out + - name: bb + direction: in + route_reflector_client: true + route_server_client: true + state: merged diff --git a/ansible_collections/dellemc/enterprise_sonic/playbooks/common_examples/sonic_bgp_communities.yaml b/ansible_collections/dellemc/enterprise_sonic/playbooks/common_examples/sonic_bgp_communities.yaml new file mode 100644 index 00000000..1cc31e75 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/playbooks/common_examples/sonic_bgp_communities.yaml @@ -0,0 +1,66 @@ +--- +- name: "Test Enterprise SONiC BGP Community configurations" + hosts: datacenter + gather_facts: no + connection: httpapi + collections: + - dellemc.enterprise_sonic + tasks: + - name: Add as_path_list configuration + sonic_bgp_as_paths: + config: + - name: test + members: + - "11" + - "22" + - "33" + permit: true + - name: test_1 + members: + - "101.101" + - "201.201" + - "301.301" + permit: false + state: merged + - name: Add bgp_community configuration + sonic_bgp_communities: + config: + - name: test + type: expanded + permit: true + members: + regex: + - "11" + - "22" + - "33" + - name: test_1 + type: expanded + permit: true + members: + regex: + - "101.101" + - "201.201" + - "301.301" + state: merged + - name: Add bgp_extcommunity configuration + sonic_bgp_ext_communities: + config: + - name: exp1 + type: expanded + permit: true + members: + regex: + - "11" + - "22" + - "33" + - name: std1 + type: standard + permit: true + members: + route_target: + - "101.101" + - "201.201" + route_origin: + - "301.301" + - "401.401" + state: merged diff --git a/ansible_collections/dellemc/enterprise_sonic/playbooks/common_examples/sonic_command.yaml b/ansible_collections/dellemc/enterprise_sonic/playbooks/common_examples/sonic_command.yaml new file mode 100644 index 00000000..ca637ca9 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/playbooks/common_examples/sonic_command.yaml @@ -0,0 +1,58 @@ +--- + +- name: "Test SONiC CLI" + hosts: datacenter + gather_facts: no + connection: network_cli + collections: + - dellemc.enterprise_sonic + tasks: + + - name: Test SONiC single command + sonic_command: + commands: 'show interface status' + register: cmd_op + - name: Test SONiC single command with wait_for + sonic_command: + commands: 'show version' + wait_for: + - result[0] contains Del + register: cmd_op + - name: Test SONiC multiple command with wait_for + sonic_command: + commands: + - 'show version' + - 'show system' + wait_for: + - result[0] contains Dell + - result[1] contains Hostname + register: cmd_op + - name: Test SONiC commands with wait_for negative case + sonic_command: + commands: + - 'show version' + - 'show system' + wait_for: + - result[0] contains Fel + - result[1] contains Hostname + register: cmd_op + ignore_errors: yes + - name: Test SONiC commands with wait_for and match=any + sonic_command: + commands: + - 'show version' + - 'show system' + wait_for: + - result[0] contains Fel + - result[1] contains Hostname + match: any + retries: 3 + interval: 2 + register: cmd_op + - name: Test SONiC command with prompt handling + sonic_command: + commands: + - command: 'image remove all' + prompt: '\[y/N\]:$' + answer: 'N' + register: cmd_op diff --git a/ansible_collections/dellemc/enterprise_sonic/playbooks/common_examples/sonic_config.yaml b/ansible_collections/dellemc/enterprise_sonic/playbooks/common_examples/sonic_config.yaml new file mode 100644 index 00000000..a368e0b6 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/playbooks/common_examples/sonic_config.yaml @@ -0,0 +1,42 @@ +--- +- hosts: datacenter + connection: network_cli + gather_facts: no + collections: + - dellemc.enterprise_sonic + tasks: + - name: "Configure SNMP community for SONiC device along with 'save'" + sonic_config: + commands: ['snmp-server community public group ro'] + save: yes + + - name: "Configure interface description using 'parents' option on SONiC device" + sonic_config: + lines: + - description hi + parents: ['interface Eth1/3'] + + - name: "Configure bgp using multiple level 'parents' on SONiC device" + sonic_config: + lines: + - maximum-paths 4 + parents: ['router bgp 4', 'address-family ipv4 unicast'] + + - name: "Configure ip access-list using 'before' and 'after' option on SONiC device" + sonic_config: + lines: + - seq 1 permit tcp any any ack + parents: ['ip access-list test'] + before: ['no ip access-list test'] + after: ['no ip access-list test'] + + - name: "Configure cli using source file" + sonic_config: + src: src.txt + + - name: "Configure cli with prompts on SONiC device" + sonic_config: + commands: + - command: 'do image remove all' + prompt: '\[y/N\]:$' + answer: 'N' diff --git a/ansible_collections/dellemc/enterprise_sonic/playbooks/common_examples/sonic_facts.yaml b/ansible_collections/dellemc/enterprise_sonic/playbooks/common_examples/sonic_facts.yaml new file mode 100644 index 00000000..57f91103 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/playbooks/common_examples/sonic_facts.yaml @@ -0,0 +1,22 @@ +--- +- name: Ansible resource module facts example + hosts: datacenter + gather_facts: True + connection: httpapi + collections: + - dellemc.enterprise_sonic + tasks: + - name: "Gather facts" + sonic_facts: + gather_subset: min + gather_network_resources: + - interfaces + - l3_interfaces + - lag_interfaces + - vlans + - bgp + register: result + + - name: "debug facts" + debug: + msg: "{{ result.ansible_facts.ansible_network_resources }}" diff --git a/ansible_collections/dellemc/enterprise_sonic/playbooks/common_examples/sonic_interfaces_config.yaml b/ansible_collections/dellemc/enterprise_sonic/playbooks/common_examples/sonic_interfaces_config.yaml new file mode 100644 index 00000000..9debc1fb --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/playbooks/common_examples/sonic_interfaces_config.yaml @@ -0,0 +1,77 @@ +--- +- name: Ansible resource module example + hosts: datacenter + gather_facts: False + connection: httpapi + collections: + - dellemc.enterprise_sonic + tasks: + - name: sonic_interfaces configuration + sonic_interfaces: + config: + - name: Loopback91 + - name: Eth1/12 + description: "hi test" + enabled: False + - name: Eth1/13 + description: "hi ans" + enabled: False + - name: Add VLANs + sonic_vlans: + config: + - vlan_id: 11 + - vlan_id: 12 + - vlan_id: 13 + state: merged + - name: sonic_l2_interfaces configuration + sonic_l2_interfaces: + config: + - name: Eth1/12 + access: + vlan: 12 + - name: Eth1/13 + access: + vlan: 11 + trunk: + allowed_vlans: + - vlan: 12 + - vlan: 13 + state: merged + - name: sonic_lag_interfaces configuration + sonic_lag_interfaces: + config: + - name: PortChannel12 + members: + interfaces: + - member: Eth1/20 + - member: Eth1/21 + - name: PortChannel1 + members: + interfaces: + - member: Eth1/22 + - name: PortChannel2 + state: merged + - name: sonic_l3_interfaces configuration + sonic_l3_interfaces: + config: + - name: Loopback100 + ipv4: + addresses: + - address: 101.1.1.1/32 + - name: vlan 11 + ipv6: + addresses: + - address: 150::1/16 + - name: po 12 + ipv4: + addresses: + - address: 180.1.1.1/16 + - name: Eth1/24 + ipv6: + enabled: true + - name: Merge port breakout configurations + sonic_port_breakout: + config: + - name: 1/11 + mode: 1x100G + state: merged diff --git a/ansible_collections/dellemc/enterprise_sonic/playbooks/common_examples/sonic_system.yaml b/ansible_collections/dellemc/enterprise_sonic/playbooks/common_examples/sonic_system.yaml new file mode 100644 index 00000000..8ca5601c --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/playbooks/common_examples/sonic_system.yaml @@ -0,0 +1,18 @@ +--- +- name: Ansible resource module example for sonic_system + hosts: datacenter + gather_facts: False + connection: httpapi + collections: + - dellemc.enterprise_sonic + tasks: + - name: Test SONiC system + sonic_system: + config: + hostname: SONIC-test + interface_naming: standard + anycast_address: + ipv4: true + ipv6: true + mac_address: 00:09:5B:EC:EE:F2 + state: merged diff --git a/ansible_collections/dellemc/enterprise_sonic/playbooks/common_examples/sonic_vxlans_config.yaml b/ansible_collections/dellemc/enterprise_sonic/playbooks/common_examples/sonic_vxlans_config.yaml new file mode 100644 index 00000000..f978578c --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/playbooks/common_examples/sonic_vxlans_config.yaml @@ -0,0 +1,38 @@ +--- +- name: Ansible resource module example + hosts: datacenter + gather_facts: False + connection: httpapi + collections: + - dellemc.enterprise_sonic + tasks: + - name: Add VLANs configuration + sonic_vlans: + config: + - vlan_id: 11 + - vlan_id: 12 + - vlan_id: 13 + state: merged + - name: configure VRFs + sonic_vrfs: + config: + - name: Vrfcheck1 + - name: Vrfcheck2 + - name: "sonic_vxlans configuration" + sonic_vxlans: + config: + - name: vteptest1 + source_ip: 1.1.1.1 + primary_ip: 2.2.2.2 + evpn_nvo: nvo6 + vlan_map: + - vni: 101 + vlan: 11 + - vni: 102 + vlan: 12 + vrf_map: + - vni: 101 + vrf: Vrfcheck1 + - vni: 102 + vrf: Vrfcheck2 + register: merged03_output diff --git a/ansible_collections/dellemc/enterprise_sonic/playbooks/common_examples/src.txt b/ansible_collections/dellemc/enterprise_sonic/playbooks/common_examples/src.txt new file mode 100644 index 00000000..47636d04 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/playbooks/common_examples/src.txt @@ -0,0 +1,4 @@ +interface Eth1/10 + description hello + mtu 1800 + |