Upgrade to Pro — share decks privately, control downloads, hide ads and more …

ホワイトボックススイッチをAnsibleで操る話

 ホワイトボックススイッチをAnsibleで操る話

Ansible Night in Tokyo 2019.07のLTで発表した資料になります。
主に下記について解説します。
・ホワイトボックススイッチとは何か?
・その上で動くOSには何があるか?
・Ansible対応状況は?

Avatar for Masaru OKI

Masaru OKI

July 30, 2019
Tweet

More Decks by Masaru OKI

Other Decks in Technology

Transcript

  1. 自己紹介 • 名前 沖 勝 • Twitter @masaru0714 • 経歴 沖電気系ソフトウェア開発会社→IIJ

    • がっつりプログラマーやってましたが最近はインフラエンジニア的お仕事 2
  2. ホワイトボックススイッチ用OS • 商用、OSSいろいろ存在する • Linuxをベースにスイッチチップ制御やCLI、APIを付加したものが多い • 商用 ◦ Cumulus Linux

    ◦ PicOS ◦ OcNOS ◦ 他いろいろ • OSS ◦ SONiC ◦ OpenSwitch (OPXとも呼ばれる) ◦ Open Network Linux ◦ 他いくつか 5
  3. Cumulus LinuxをAnsibleで設定する • NCLUモジュールが用意されているので、それを使い設定できる。 参考記事 https://cumulusnetworks.com/blog/automating-cumulus-linux-ansible/ • taskの例(記事より引用) - name:

    Enable OSPF nclu: commands: - add ospf router-id {{ rid }} - add ospf network {{ item.prefix }} area {{ item.area }} atomic: true description: "Enable OSPF" loop: - { prefix: 192.168.0.0/16, area: 0.0.0.0 } 7
  4. OpenSwitchをAnsibleで設定する • サンプルRoleが公式より提供されている https://github.com/open-switch/ansible-opx-examples/tree/master/roles/open-switch.ansible-role-opx-system • taskの例(サンプルより一部抜粋) - name: Add new

    ip v4 route with nexthops command: "ip route add {{ outer_item.ip_and_mask }} {{ nexthop_res }}" when: - outer_item.state is undefined or outer_item.state != "absent" - outer_item.ip_and_mask - outer_item.nexthop_ip is defined and outer_item.nexthop_ip - name: Add new ip v4 route with interface command: "ip route add {{ outer_item.ip_and_mask }} dev {{ outer_item.interface }}" when: - outer_item.state is undefined or outer_item.state != "absent" - outer_item.ip_and_mask - outer_item.interface is defined and outer_item.interface - outer_item.nexthop_ip is undefined or not outer_item.nexthop_ip 8
  5. SONiCをAnsibleで設定する • Roleが公式より提供されている https://github.com/Azure/sonic-mgmt/tree/master/ansible が、旧バージョン対応で古く、最新のSONiCでは不適合な部分があるようだ • 自作する場合、設定用にconfigコマンドが用意されているのでそれを呼ぶ • taskの例 -

    name: add ip address command: "config interface ip add {{ interface }} {{ ip_addr }}" • /etc/sonic/config_db.jsonに設定を書いてconfig reloadで反映する方法もある config_db.jsonのテンプレートを用意し埋めることもできる 9