Skip to content

Instantly share code, notes, and snippets.

@upa
Created February 28, 2019 12:27
Show Gist options
  • Save upa/4fcfe3e7d5c2844b5d549671aeecc1ae to your computer and use it in GitHub Desktop.
Save upa/4fcfe3e7d5c2844b5d549671aeecc1ae to your computer and use it in GitHub Desktop.
deploying lagopus router from scratch by a single ansible playbook
- hosts: localhost
vars:
GOPATH : "{{ lookup('env', 'HOME') }}/go"
VSWCONF: /usr/local/etc/vsw.conf
environment:
GOPATH: "{{ GOPATH }}"
PATH: "{{ lookup('env', 'PATH') }}:{{ GOPATH }}/bin"
LD_LIBRARY_PATH: /usr/src/dpdk-stable-17.11.1/build/lib
tasks:
# install required software
- name: install required packages
become: yes
apt:
name: [ "libnuma-dev", "libelf-dev", "golang", "go-dep" ]
- name: install dpdk
become: yes
dpdk_install: build_shared_lib=true jobs=6
# install lagopus-router and related software
- name: go get openconfigd
command: "{{ item }}"
with_items:
- go get github.com/coreswitch/openconfigd/openconfigd
- go get github.com/coreswitch/openconfigd/cli_command
- name: configure, make, make install cli
become: yes
command: "{{ item }}"
with_items:
- ./configure
- make
- make install
- cp ../bash_completion.d/cli /etc/bash_completion.d/
args:
chdir: "{{ GOPATH }}/src/github.com/coreswitch/openconfigd/cli"
- name: create vsw src directroy
file: path={{ GOPATH }}/src/github.com/lagopus state=directory
- name: download vsw
git:
repo: https://github.com/lagopus/vsw.git
dest: "{{ GOPATH }}/src/github.com/lagopus/vsw"
- name: install vsw
command: "{{ item }}"
with_items:
- dep ensure
- go install
args:
chdir: "{{ GOPATH }}/src/github.com/lagopus/vsw"
- name: install lagopus-router
git:
repo: https://github.com/lagopus/lagopus-router.git
dest: "{{ GOPATH }}/src/github.com/lagopus/lagopus-router"
# setup, spawn, and configure vsw
- name: spawn openconfid
spawn:
args: openconfigd -y modules:modules/policy:modules/bgp:modules/interfaces:modules/local-routing:modules/vlan:modules/rib:modules/network-instance:modules/types lagopus-router.yang
cwd: "{{ GOPATH }}/src/github.com/lagopus/lagopus-router/yang"
pidfile: /tmp/openconfid.pid
stderr: /tmp/openconfigd-stderr
stdout: /tmp/openconfigd-stdout
respawn: true
async: 10
poll: 1
- name: set hugepages
become: yes
hugepages: nr_pages=1024
- name: bind device to dpdk driver
become: yes
devbind: device=000:01:00.0 driver=igb_uio
- name: put vsw.conf
become: yes
copy: src=provisioning/vsw.conf dest={{ VSWCONF }}
- name: spawn vsw
become: yes
spawn:
args: vsw -v -f {{ VSWCONF }}
pidfile: /tmp/vsw.pid
stderr: /tmp/vsw-stderr
stdout: /tmp/vsw-stdout
respawn: true
async: 10
poll: 1
- name: configure vsw
vswconfig: config={{ item }}
with_items:
- set network-instances network-instance vsi3 config type L2VSI
- set network-instances network-instance vsi3 config enabled true
- commit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment