Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add sonic fanout support #485

Merged
merged 2 commits into from
Mar 1, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions ansible/group_vars/fanout/secrets.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
ansible_ssh_user: user
ansible_ssh_pass: password
fanout_sonic_user: admin
fanout_sonic_password: password
1 change: 1 addition & 0 deletions ansible/lab
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ fanout
[fanout]
str-7260-10 ansible_host=10.251.0.13
str-7260-11 ansible_host=10.251.0.234
str-msn2700-02 ansible_host=10.251.0.235 os=sonic
30 changes: 30 additions & 0 deletions ansible/roles/fanout/tasks/fanout_eos.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
- name: prepare fanout switch admin login info
set_fact: ansible_ssh_user={{ fanout_admin_user }} ansible_ssh_pass={{ fanout_admin_password }}

- name: create persistent shell login
file: path=/mnt/flash/rc.eos state=touch
become: yes

- name: save persistent shell login
template: src=rc.eos.j2
dest=/mnt/flash/rc.eos
become: yes

- name: build fanout startup config for Arista fanout leaf
template: src=arista_7260_deploy.j2
dest=/mnt/flash/startup-config
when: device_info.HwSku == "Arista-7260QX-64"
become: yes

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

- name: reboot
shell: sleep 2 && shutdown -r now "Reboot"
async: 1
poll: 0
ignore_errors: true
become: yes
41 changes: 41 additions & 0 deletions ansible/roles/fanout/tasks/fanout_sonic.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
- debug: msg="{{ device_info }}"

- name: prepare fanout switch admin login info
set_fact: ansible_user={{ fanout_sonic_user }} ansible_password={{ fanout_sonic_password }}

- name: build fanout vlan config
template: src=sonic_deploy.j2
dest=/etc/sonic/vlan.json
become: yes

- name: disable all copp rules
copy: content='[]'
dest=/etc/swss/config.d/00-copp.config.json
become: yes
vars:
ansible_shell_type: docker
ansible_python_interpreter: docker exec -i swss python

- name: generate config_db.json
shell: sonic-cfggen -j /etc/sonic/vlan.json -j /etc/sonic/init_cfg.json --print-data > /etc/sonic/config_db.json
become: yes

- name: reload config_db.json
shell: config reload -y
become: yes

- name: stop and disable lldp service
service: name=lldp state=stopped enabled=no
become: yes

- name: stop and disable dhcp_relay service
service: name=dhcp_relay state=stopped enabled=no
become: yes

- name: stop and disable bgp service
service: name=bgp state=stopped enabled=no
become: yes

- name: stop and disable teamd service
service: name=teamd state=stopped enabled=no
become: yes
34 changes: 6 additions & 28 deletions ansible/roles/fanout/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,36 +13,14 @@

- set_fact: sw_type="{{ device_info['Type'] }}"

- name: prepare fanout switch admin login info
set_fact: ansible_ssh_user={{ fanout_admin_user }} ansible_ssh_pass={{ fanout_admin_password }}
- set_fact: os='eos'
when: os is not defined

- name: create persistent shell login
file: path=/mnt/flash/rc.eos state=touch
become: yes
- include: fanout_eos.yml
when: os == 'eos'

- name: save persistent shell login
template: src=rc.eos.j2
dest=/mnt/flash/rc.eos
become: yes

- name: build fanout startup config for Arista fanout leaf
template: src=arista_7260_deploy.j2
dest=/mnt/flash/startup-config
when: device_info.HwSku == "Arista-7260QX-64"
become: yes

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

- name: reboot
shell: sleep 2 && shutdown -r now "Reboot"
async: 1
poll: 0
ignore_errors: true
become: yes
- include: fanout_sonic.yml
when: os == 'sonic'

- block:
- set_fact:
Expand Down
45 changes: 45 additions & 0 deletions ansible/roles/fanout/templates/sonic_deploy.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{

"DEVICE_METADATA": {
"localhost": {
"hwsku": "{{ device_info["HwSku"] }}",
"hostname": "{{ inventory_hostname }}"
}
},

"VLAN": {
{% for vlanid in device_vlan_list | unique %}
"Vlan{{ vlanid }}": {
"vlanid": "{{ vlanid }}"
}{% if not loop.last %},{% endif %}
{% endfor %}
},

{% set ns = {'firstPrinted': False} %}
"VLAN_MEMBER": {
{% for port in device_port_vlans %}
{% if device_port_vlans[port]['mode'] == 'Access' %}
{% if ns.firstPrinted %},{% endif %}
"Vlan{{ device_port_vlans[port]['vlanids'] }}|{{ port }}": {
"tagging_mode" : "untagged"
}
{% if ns.update({'firstPrinted': True}) %} {% endif %}
{% elif device_port_vlans[port]['mode'] == 'Trunk' %}
{% for vlanid in device_port_vlans[port]['vlanlist'] %}
{% if ns.firstPrinted %},{% endif %}
"Vlan{{ vlanid }}|{{ port }}": {
"tagging_mode" : "tagged"
}
{% if ns.update({'firstPrinted': True}) %} {% endif %}
{% endfor %}
{% endif %}
{% endfor %}
},

"MGMT_INTERFACE": {
"eth0|{{ device_info["ManagementIp"] }}": {
"gwaddr": "{{ device_info["ManagementGw"] }}"
}
}

}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is the last curly parentheses needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes