diff --git a/ansible/group_vars/sonic_latest/package_versions.yml b/ansible/group_vars/sonic_latest/package_versions.yml index 0db689807eb..d384cf28a5c 100644 --- a/ansible/group_vars/sonic_latest/package_versions.yml +++ b/ansible/group_vars/sonic_latest/package_versions.yml @@ -22,3 +22,4 @@ image_id_orchagent_cavm: docker-orchagent-cavm:latest image_id_fpm: docker-fpm:latest image_id_snmp_sv2: docker-snmp-sv2:latest image_id_lldp_sv2: docker-lldp-sv2:latest +image_id_teamd: docker-teamd:latest diff --git a/ansible/inventory b/ansible/inventory index 57a50a925ae..4bf3dbef276 100644 --- a/ansible/inventory +++ b/ansible/inventory @@ -1,6 +1,7 @@ [sonic_latest] switch1 ansible_host=10.0.0.100 sonic_version=v2 sonic_hwsku=ACS-S6000 switch2 ansible_host=10.0.0.101 sonic_version=v2 sonic_hwsku=ACS-MSN2700 +switch3 ansible_host=10.0.0.102 sonic_version=v2 sonic_hwsku=ACS-S6000 # LAG topo: 8 LAGs x 2 members/lag to spines; 16 ports to Tors [sonic:children] sonic_latest diff --git a/ansible/library/minigraph_facts.py b/ansible/library/minigraph_facts.py index 135d55531db..7dc7e0ef214 100644 --- a/ansible/library/minigraph_facts.py +++ b/ansible/library/minigraph_facts.py @@ -179,7 +179,7 @@ def parse_dpg(dpg, hname): pcintfname = pcintf.find(str(QName(ns, "Name"))).text pcintfmbr = pcintf.find(str(QName(ns, "AttachTo"))).text mbr_list = pcintfmbr.split(';', 1) - pc_intfs.append({'name': pcintfname.lower(), 'members': mbr_list}) + pc_intfs.append({'name': pcintfname, 'members': mbr_list}) lointfs = child.find(str(QName(ns, "LoopbackIPInterfaces"))) lo_intfs = [] @@ -369,6 +369,11 @@ def parse_xml(filename, hostname): elif child.tag == str(QName(ns, "UngDec")): (u_neighbors, u_devices, _, _, _, _) = parse_png(child, hostname) + # Replace port with alias in port channel interfaces members + for pc in pc_intfs: + for i,member in enumerate(pc['members']): + pc['members'][i] = port_alias_map[member] + Tree = lambda: defaultdict(Tree) results = Tree() @@ -399,7 +404,6 @@ def parse_xml(filename, hostname): port_alias_map = {} - def main(): module = AnsibleModule( argument_spec=dict( @@ -441,13 +445,9 @@ def main(): def print_parse_xml(hostname): filename = '../minigraph/' + hostname + '.xml' results = parse_xml(filename, hostname) - import json print(json.dumps(results, indent=3, cls=minigraph_encoder)) - from ansible.module_utils.basic import * if __name__ == "__main__": main() - #debug_main() - diff --git a/ansible/minigraph/switch3.xml b/ansible/minigraph/switch3.xml new file mode 100644 index 00000000000..e1025643513 --- /dev/null +++ b/ansible/minigraph/switch3.xml @@ -0,0 +1,916 @@ + + + + + + ARISTA01T0 + 10.0.0.33 + switch3 + 10.0.0.32 + 1 + 180 + 60 + + + switch3 + 10.0.0.0 + ARISTA01T2 + 10.0.0.1 + 1 + 180 + 60 + + + ARISTA02T0 + 10.0.0.35 + switch3 + 10.0.0.34 + 1 + 180 + 60 + + + ARISTA03T0 + 10.0.0.37 + switch3 + 10.0.0.36 + 1 + 180 + 60 + + + switch3 + 10.0.0.4 + ARISTA03T2 + 10.0.0.5 + 1 + 180 + 60 + + + ARISTA04T0 + 10.0.0.39 + switch3 + 10.0.0.38 + 1 + 180 + 60 + + + ARISTA05T0 + 10.0.0.41 + switch3 + 10.0.0.40 + 1 + 180 + 60 + + + switch3 + 10.0.0.8 + ARISTA05T2 + 10.0.0.9 + 1 + 180 + 60 + + + ARISTA06T0 + 10.0.0.43 + switch3 + 10.0.0.42 + 1 + 180 + 60 + + + ARISTA07T0 + 10.0.0.45 + switch3 + 10.0.0.44 + 1 + 180 + 60 + + + switch3 + 10.0.0.12 + ARISTA07T2 + 10.0.0.13 + 1 + 180 + 60 + + + ARISTA08T0 + 10.0.0.47 + switch3 + 10.0.0.46 + 1 + 180 + 60 + + + ARISTA09T0 + 10.0.0.49 + switch3 + 10.0.0.48 + 1 + 180 + 60 + + + switch3 + 10.0.0.16 + ARISTA09T2 + 10.0.0.17 + 1 + 180 + 60 + + + ARISTA10T0 + 10.0.0.51 + switch3 + 10.0.0.50 + 1 + 180 + 60 + + + ARISTA11T0 + 10.0.0.53 + switch3 + 10.0.0.52 + 1 + 180 + 60 + + + switch3 + 10.0.0.20 + ARISTA11T2 + 10.0.0.21 + 1 + 180 + 60 + + + ARISTA12T0 + 10.0.0.55 + switch3 + 10.0.0.54 + 1 + 180 + 60 + + + ARISTA13T0 + 10.0.0.57 + switch3 + 10.0.0.56 + 1 + 180 + 60 + + + switch3 + 10.0.0.24 + ARISTA13T2 + 10.0.0.25 + 1 + 180 + 60 + + + ARISTA14T0 + 10.0.0.59 + switch3 + 10.0.0.58 + 1 + 180 + 60 + + + ARISTA15T0 + 10.0.0.61 + switch3 + 10.0.0.60 + 1 + 180 + 60 + + + switch3 + 10.0.0.28 + ARISTA15T2 + 10.0.0.29 + 1 + 180 + 60 + + + ARISTA16T0 + 10.0.0.63 + switch3 + 10.0.0.62 + 1 + 180 + 60 + + + + + 65100 + switch3 + + +
10.0.0.33
+ + +
+ +
10.0.0.1
+ + +
+ +
10.0.0.35
+ + +
+ +
10.0.0.37
+ + +
+ +
10.0.0.5
+ + +
+ +
10.0.0.39
+ + +
+ +
10.0.0.41
+ + +
+ +
10.0.0.9
+ + +
+ +
10.0.0.43
+ + +
+ +
10.0.0.45
+ + +
+ +
10.0.0.13
+ + +
+ +
10.0.0.47
+ + +
+ +
10.0.0.49
+ + +
+ +
10.0.0.17
+ + +
+ +
10.0.0.51
+ + +
+ +
10.0.0.53
+ + +
+ +
10.0.0.21
+ + +
+ +
10.0.0.55
+ + +
+ +
10.0.0.57
+ + +
+ +
10.0.0.25
+ + +
+ +
10.0.0.59
+ + +
+ +
10.0.0.61
+ + +
+ +
10.0.0.29
+ + +
+ +
10.0.0.63
+ + +
+
+ +
+ + 64001 + ARISTA01T0 + + + + 65200 + ARISTA01T2 + + + + 64002 + ARISTA02T0 + + + + 64003 + ARISTA03T0 + + + + 65200 + ARISTA03T2 + + + + 64004 + ARISTA04T0 + + + + 64005 + ARISTA05T0 + + + + 65200 + ARISTA05T2 + + + + 64006 + ARISTA06T0 + + + + 64007 + ARISTA07T0 + + + + 65200 + ARISTA07T2 + + + + 64008 + ARISTA08T0 + + + + 64009 + ARISTA09T0 + + + + 65200 + ARISTA09T2 + + + + 64010 + ARISTA10T0 + + + + 64011 + ARISTA11T0 + + + + 65200 + ARISTA11T2 + + + + 64012 + ARISTA12T0 + + + + 64013 + ARISTA13T0 + + + + 65200 + ARISTA13T2 + + + + 64014 + ARISTA14T0 + + + + 64015 + ARISTA15T0 + + + + 65200 + ARISTA15T2 + + + + 64016 + ARISTA16T0 + + +
+
+ + + + + + HostIP + Loopback0 + + 10.1.0.32/32 + + 10.1.0.32/32 + + + + + HostIP + eth0 + + 10.0.0.102/24 + + 10.0.0.102/24 + + + + + + switch3 + + + PortChannelInterface + PortChannel0 + fortyGigE0/0;fortyGigE0/4 + + + + PortChannelInterface + PortChannel8 + fortyGigE0/8;fortyGigE0/12 + + + + PortChannelInterface + PortChannel16 + fortyGigE0/16;fortyGigE0/20 + + + + PortChannelInterface + PortChannel24 + fortyGigE0/24;fortyGigE0/28 + + + + PortChannelInterface + PortChannel32 + fortyGigE0/32;fortyGigE0/36 + + + + PortChannelInterface + PortChannel40 + fortyGigE0/40;fortyGigE0/44 + + + + PortChannelInterface + PortChannel48 + fortyGigE0/48;fortyGigE0/52 + + + + PortChannelInterface + PortChannel56 + fortyGigE0/56;fortyGigE0/60 + + + + + + + IPInterface + + PortChannel0 + 10.0.0.0/31 + + + IPInterface + + PortChannel8 + 10.0.0.4/31 + + + IPInterface + + PortChannel16 + 10.0.0.8/31 + + + IPInterface + + PortChannel24 + 10.0.0.12/31 + + + IPInterface + + PortChannel32 + 10.0.0.16/31 + + + IPInterface + + PortChannel40 + 10.0.0.20/31 + + + IPInterface + + PortChannel48 + 10.0.0.24/31 + + + IPInterface + + PortChannel56 + 10.0.0.28/31 + + + + fortyGigE0/64 + 10.0.0.32/31 + + + + fortyGigE0/68 + 10.0.0.34/31 + + + + fortyGigE0/72 + 10.0.0.36/31 + + + + fortyGigE0/76 + 10.0.0.38/31 + + + + fortyGigE0/80 + 10.0.0.40/31 + + + + fortyGigE0/84 + 10.0.0.42/31 + + + + fortyGigE0/88 + 10.0.0.44/31 + + + + fortyGigE0/92 + 10.0.0.46/31 + + + + fortyGigE0/96 + 10.0.0.48/31 + + + + fortyGigE0/100 + 10.0.0.50/31 + + + + fortyGigE0/104 + 10.0.0.52/31 + + + + fortyGigE0/108 + 10.0.0.54/31 + + + + fortyGigE0/112 + 10.0.0.56/31 + + + + fortyGigE0/116 + 10.0.0.58/31 + + + + fortyGigE0/120 + 10.0.0.60/31 + + + + fortyGigE0/124 + 10.0.0.62/31 + + + + + + + + + + + + DeviceInterfaceLink + switch3 + fortyGigE0/0 + ARISTA01T2 + Ethernet1 + + + DeviceInterfaceLink + switch3 + fortyGigE0/4 + ARISTA01T2 + Ethernet2 + + + DeviceInterfaceLink + switch3 + fortyGigE0/8 + ARISTA03T2 + Ethernet1 + + + DeviceInterfaceLink + switch3 + fortyGigE0/12 + ARISTA03T2 + Ethernet2 + + + DeviceInterfaceLink + switch3 + fortyGigE0/16 + ARISTA05T2 + Ethernet1 + + + DeviceInterfaceLink + switch3 + fortyGigE0/20 + ARISTA05T2 + Ethernet2 + + + DeviceInterfaceLink + switch3 + fortyGigE0/24 + ARISTA07T2 + Ethernet1 + + + DeviceInterfaceLink + switch3 + fortyGigE0/28 + ARISTA07T2 + Ethernet2 + + + DeviceInterfaceLink + switch3 + fortyGigE0/32 + ARISTA09T2 + Ethernet1 + + + DeviceInterfaceLink + switch3 + fortyGigE0/36 + ARISTA09T2 + Ethernet2 + + + DeviceInterfaceLink + switch3 + fortyGigE0/40 + ARISTA11T2 + Ethernet1 + + + DeviceInterfaceLink + switch3 + fortyGigE0/44 + ARISTA11T2 + Ethernet2 + + + DeviceInterfaceLink + switch3 + fortyGigE0/48 + ARISTA13T2 + Ethernet1 + + + DeviceInterfaceLink + switch3 + fortyGigE0/52 + ARISTA13T2 + Ethernet2 + + + DeviceInterfaceLink + switch3 + fortyGigE0/56 + ARISTA15T2 + Ethernet1 + + + DeviceInterfaceLink + switch3 + fortyGigE0/60 + ARISTA15T2 + Ethernet2 + + + DeviceInterfaceLink + switch3 + fortyGigE0/64 + ARISTA01T0 + Ethernet1 + + + DeviceInterfaceLink + switch3 + fortyGigE0/68 + ARISTA02T0 + Ethernet1 + + + DeviceInterfaceLink + switch3 + fortyGigE0/72 + ARISTA03T0 + Ethernet1 + + + DeviceInterfaceLink + switch3 + fortyGigE0/76 + ARISTA04T0 + Ethernet1 + + + DeviceInterfaceLink + switch3 + fortyGigE0/80 + ARISTA05T0 + Ethernet1 + + + DeviceInterfaceLink + switch3 + fortyGigE0/84 + ARISTA06T0 + Ethernet1 + + + DeviceInterfaceLink + switch3 + fortyGigE0/88 + ARISTA07T0 + Ethernet1 + + + DeviceInterfaceLink + switch3 + fortyGigE0/92 + ARISTA08T0 + Ethernet1 + + + DeviceInterfaceLink + switch3 + fortyGigE0/96 + ARISTA09T0 + Ethernet1 + + + DeviceInterfaceLink + switch3 + fortyGigE0/100 + ARISTA10T0 + Ethernet1 + + + DeviceInterfaceLink + switch3 + fortyGigE0/104 + ARISTA11T0 + Ethernet1 + + + DeviceInterfaceLink + switch3 + fortyGigE0/108 + ARISTA12T0 + Ethernet1 + + + DeviceInterfaceLink + switch3 + fortyGigE0/112 + ARISTA13T0 + Ethernet1 + + + DeviceInterfaceLink + switch3 + fortyGigE0/116 + ARISTA14T0 + Ethernet1 + + + DeviceInterfaceLink + switch3 + fortyGigE0/120 + ARISTA15T0 + Ethernet1 + + + DeviceInterfaceLink + switch3 + fortyGigE0/124 + ARISTA16T0 + Ethernet1 + + + + switch3 + Force10-S6000 +
diff --git a/ansible/roles/sonicv2/tasks/main.yml b/ansible/roles/sonicv2/tasks/main.yml index 98e9fae3d57..88a3d0707ab 100644 --- a/ansible/roles/sonicv2/tasks/main.yml +++ b/ansible/roles/sonicv2/tasks/main.yml @@ -8,7 +8,17 @@ mode=0644 register: if_copy tags: network,unsafe - when: sonic_version == "v2" + +# Setup LAG Interfaces +- name: Copy LAG Interfaces File + become: true + template: src=lag_interfaces.j2 + dest=/etc/network/interfaces.d/lag_interfaces + owner=root + group=root + mode=0644 + register: if_copy + tags: network,unsafe # SSW - name: Copy SSW files. @@ -21,7 +31,6 @@ mode=0644 tags: ssw - # SONiC - include: sonic-brcm.yml when: sonic_asic_type == 'broadcom' @@ -33,3 +42,6 @@ - include: quagga.yml tags: quagga,unsafe + +- include: teamd.yml + tags: teamd,unsafe diff --git a/ansible/roles/sonicv2/tasks/teamd.yml b/ansible/roles/sonicv2/tasks/teamd.yml new file mode 100644 index 00000000000..5473551eb9f --- /dev/null +++ b/ansible/roles/sonicv2/tasks/teamd.yml @@ -0,0 +1,10 @@ +- name: Start the teamd docker container + include: sonicdocker.yml + vars: + docker_container: teamd + docker_image: "{{ image_id_teamd }}" + docker_privileged: yes + docker_state: reloaded + +- include: teamd_interface.yml + with_items: "{{ minigraph_portchannel_interfaces }}" diff --git a/ansible/roles/sonicv2/tasks/teamd_interface.yml b/ansible/roles/sonicv2/tasks/teamd_interface.yml new file mode 100644 index 00000000000..feeda01322a --- /dev/null +++ b/ansible/roles/sonicv2/tasks/teamd_interface.yml @@ -0,0 +1,19 @@ +- block: + - name: Ensure /etc/teamd folder exists + become: true + file: path=/etc/teamd + state=directory + + - debug: msg={{ item }} + + - name: Copy teamd configuration file + become: true + template: src=teamd.j2 + dest=/etc/teamd/{{ item['name'] }}.conf + owner=root + group=root + mode=644 + + vars: + ansible_shell_type: docker + ansible_python_interpreter: docker exec -i teamd python diff --git a/ansible/roles/sonicv2/templates/etc/systemd/system/teamd.j2 b/ansible/roles/sonicv2/templates/etc/systemd/system/teamd.j2 new file mode 100644 index 00000000000..6ccdb46708a --- /dev/null +++ b/ansible/roles/sonicv2/templates/etc/systemd/system/teamd.j2 @@ -0,0 +1,12 @@ +[Unit] +Description=TEAMD container +Requires=database.service +After=database.service + +[Service] +User={{ sonicadmin_user }} +ExecStart=/usr/bin/docker start -a teamd +ExecStop=/usr/bin/docker stop teamd + +[Install] +WantedBy=multi-user.target diff --git a/ansible/roles/sonicv2/templates/lag_interfaces.j2 b/ansible/roles/sonicv2/templates/lag_interfaces.j2 new file mode 100644 index 00000000000..5f6600a6cf0 --- /dev/null +++ b/ansible/roles/sonicv2/templates/lag_interfaces.j2 @@ -0,0 +1,20 @@ +# +{% block banner %} +# =========== Managed by Ansible DO NOT EDIT! ======================== +# generated by templates/lag_interfaces.j2 using minigraph_facts.py +# file: lag_interfaces +{% endblock %} +# +{% block lag_interface %} +# The switch LAG interfaces +{% for interface in minigraph_interfaces %} +{% if 'PortChannel' in interface['alias'] %} +auto {{ interface['name'] }} +iface {{ interface['name'] }} {{ 'inet' if interface['addr'] | ipv4 else 'inet6' }} static + address {{ interface['addr'] }} + netmask {{ interface['mask'] }} +{% endif %} +{% endfor %} +{% endblock lag_interface %} +# + diff --git a/ansible/roles/sonicv2/templates/teamd.j2 b/ansible/roles/sonicv2/templates/teamd.j2 new file mode 100644 index 00000000000..2aff63bc4db --- /dev/null +++ b/ansible/roles/sonicv2/templates/teamd.j2 @@ -0,0 +1,19 @@ +{ + "device": "{{item['name']}}", + "runner": { + "name": "lacp", + "active": true, + "min_ports": 2, + "tx_hash": ["eth", "ipv4", "ipv6"] + }, + "link_watch": { + "name": "ethtool" + }, + "ports": { + {% for member in item['members'] %} + "{{member}}": {}{% if not loop.last %}, + {% endif %} + {% endfor %} + } +} +