Skip to content

Commit fc95f0f

Browse files
maggiemsftlguohan
authored andcommitted
[testbed] fanout add rootfanout connect when deploying fanout switch (#368)
1 parent 38ae9fb commit fc95f0f

File tree

6 files changed

+67
-39
lines changed

6 files changed

+67
-39
lines changed

ansible/fanout_connect.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,6 @@
2222

2323
- set_fact: userid={{ calling_username.stdout }}
2424

25-
- include: roles/fanout/tasks/rootfanout_connect.yml
26-
25+
- set_fact: connect_leaf=false
2726

27+
- include: roles/fanout/tasks/rootfanout_connect.yml
Lines changed: 34 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,54 @@
11
##############################################################################################
22
### playbook to deploy the fanout swtich
3-
### Use this playbook to deploy the VLAN configurations of fanout leaf switch in SONiC testbed
3+
### Use this playbook to deploy the VLAN configurations of fanout switch in SONiC testbed
44
### This playbook will run based on hardware flatform. Each fanout switch hardware type has its
55
### own unique feature and configuration command or format. Unless you use the hardware swtich
66
### specified in this playbook, you would need to come up with your own fanout switch deployment
77
### playbook
88
################################################################################################
9-
# Gather minigraph facts
9+
# Deploy fanout switch
1010
- name: Gathering lab graph facts about the device
1111
conn_graph_facts: host={{ inventory_hostname }}
1212
connection: local
13-
tags: always
13+
14+
- set_fact: sw_type="{{ device_info['Type'] }}"
1415

1516
- name: prepare fanout switch admin login info
1617
set_fact: ansible_ssh_user={{ fanout_admin_user }} ansible_ssh_pass={{ fanout_admin_password }}
1718

18-
- block:
19-
- name: build fanout startup config for Arista Fanout leaf
20-
template: src=arista_7260_deploy.j2
21-
dest=/mnt/flash/startup-config
22-
notify:
23-
- Restart the box
19+
- name: create persistent shell login
20+
file: path=/mnt/flash/rc.eos state=touch
21+
become: yes
22+
23+
- name: save persistent shell login
24+
template: src=rc.eos.j2
25+
dest=/mnt/flash/rc.eos
26+
become: yes
27+
28+
- name: build fanout startup config for Arista fanout leaf
29+
template: src=arista_7260_deploy.j2
30+
dest=/mnt/flash/startup-config
2431
when: device_info.HwSku == "Arista-7260QX-64"
32+
become: yes
2533

34+
- name: build fanout startup config for 7060
35+
template: src=arista_7060_deploy.j2
36+
dest=/mnt/flash/startup-config
37+
when: device_info.HwSku == "Arista-7060CX-32S"
38+
become: yes
2639

27-
- name: build fanout startup config
28-
action: apswitch template=force10_s6100_deploy.j2
29-
connection: switch
30-
args:
31-
login: "{{ switch_login['Force10'] }}"
32-
when: device_info.HwSku == "Force10-S6100"
40+
- name: reboot
41+
shell: sleep 2 && shutdown -r now "Reboot"
42+
async: 1
43+
poll: 0
44+
ignore_errors: true
45+
become: yes
3346

3447
- block:
35-
- name: build fanout startup config
36-
template: src=arista_7060_deploy.j2
37-
dest=/mnt/flash/startup-config
38-
notify:
39-
- Restart the box
40-
when: device_info.HwSku == "Arista-7060CX-32S"
48+
- set_fact:
49+
leaf_name: "{{ inventory_hostname }}"
50+
leaf: "{{ ansible_host }}"
4151

52+
- include: rootfanout_connect.yml
53+
deploy_leaf=true
54+
when: sw_type == 'FanoutLeaf'

ansible/roles/fanout/tasks/rootfanout_connect.yml

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
1-
# This playbook is trying to change root fanout switch one port to the DUT vlan range based on which server which port and DUT name
2-
# This playbook is called from fanout_connect.yml
3-
# Gather graph facts
4-
- name: Gathering connection facts about the DUT device
1+
# This playbook is trying to change root fanout switch port vlans when deploy leaf fanout or connect server to SONiC DUT
2+
# This playbook is called from fanout_connect.yml or fanout.yml
3+
4+
- set_fact: deploy_leaf=false
5+
when: deploy_leaf is not defined
6+
7+
- set_fact: dut="{{ leaf_name }}"
8+
when: deploy_leaf
9+
10+
- name: Gathering connection facts about the DUT or leaffanout device
511
conn_graph_facts: host={{ dut }}
612
connection: local
713
tags: always
8-
register: dutinfo
14+
register: devinfo
915

1016
- name: Gathering connection facts about the lab
1117
conn_graph_facts:
@@ -14,7 +20,7 @@
1420
register: lab
1521

1622
- set_fact:
17-
dut_vlans: "{{ dutinfo.ansible_facts.device_vlan_range }}"
23+
dev_vlans: "{{ devinfo.ansible_facts.device_vlan_range }}"
1824
lab_devices: "{{ lab.ansible_facts.device_info }}"
1925

2026
- name: Find the root fanout switch
@@ -31,4 +37,4 @@
3137
action: apswitch template=roles/fanout/templates/arista_7260_connect.j2
3238
connection: switch
3339
args:
34-
login: "{{ switch_login['Arista'] }}"
40+
login: "{{ switch_login['Arista'] }}"

ansible/roles/fanout/templates/arista_7060_deploy.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ vlan {{ device_vlan_range | list | join(',') }}
2929
vrf definition management
3030
rd 1:1
3131
!
32-
{% for i in range(1,32) %}
32+
{% for i in range(1,33) %}
3333
{% set intf = 'Ethernet' + i|string + '/1' %}
3434
interface {{ intf }}
3535
{% if intf in device_port_vlans and device_port_vlans[intf]['mode'] != "Trunk" %}

ansible/roles/fanout/templates/arista_7260_connect.j2

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,27 @@ config
55
{% if intf in root_conn %}
66
{% set peer_dev = root_conn[intf]['peerdevice'] %}
77
{% set peer_port = root_conn[intf]['peerport'] %}
8-
{% if 'Fanout' not in lab_devices[peer_dev]['Type'] %}
9-
interface {{ intf }}
8+
{% if 'Fanout' not in lab_devices[peer_dev]['Type'] and not deploy_leaf %}
9+
interface {{ intf }}
10+
switchport trunk allowed vlan remove {{ dev_vlans | list | join(',') }}
11+
{% if peer_dev == server and peer_port == server_port %}
1012
switchport mode trunk
11-
switchport trunk allowed vlan remove {{ dut_vlans | list | join(',') }}
13+
switchport trunk allowed vlan add {{ dev_vlans | list | join(',') }}
14+
no shutdown
15+
{% endif %}
16+
{% endif %}
17+
{% if 'Fanout' in lab_devices[peer_dev]['Type'] and deploy_leaf %}
18+
interface {{ intf }}
19+
switchport trunk allowed vlan remove {{ dev_vlans | list | join(',') }}
20+
{% if peer_dev == leaf_name %}
21+
description {{ peer_dev }}-{{ peer_port }}
22+
switchport mode trunk
23+
switchport trunk allowed vlan add {{ dev_vlans | list | join(',') }}
1224
no shutdown
13-
{% if peer_dev == server and peer_port == server_port %}
14-
switchport trunk allowed vlan add {{ dut_vlans | list | join(',') }}
1525
{% endif %}
1626
{% endif %}
1727
{% endif %}
1828
{% endfor %}
1929
!
2030
copy running-config startup-config
2131
end
22-
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/sh
2-
useradd -d /persist/local/{{ sonicadmin_user }} -G eosadmin {{ sonicadmin_user }}
3-
echo {{ sonicadmin_password }} | sudo passwd --stdin {{ sonicadmin_user }}
2+
useradd -d /persist/local/{{ fanout_admin_user }} -G eosadmin {{ fanout_admin_user }}
3+
echo {{ fanout_admin_password }} | sudo passwd --stdin {{ fanout_admin_user }}
44

55

0 commit comments

Comments
 (0)