Skip to content

Latest commit

 

History

History
377 lines (304 loc) · 16.1 KB

File metadata and controls

377 lines (304 loc) · 16.1 KB

演習 1.2 - データポートのenableとルーティングの設定

目次

本演習の目的

本演習では、acos_commandモジュールを利用してvThunderのデータポートを利用可能にする(enableする)設定と、a10_ip_route_ribモジュールを利用してvThunderのスタティックルートの設定を行います。 データポートをenableにすることで、クライアントとVE 10、WebサーバーとVE 20との間でネットワークの疎通確認をすることができます。

データポートがenableになっていないことを確認するには、vThunderで以下のCLIコマンドを実行します。

vThunder#show interfaces brief
Port    Link  Dupl  Speed  Trunk Vlan MAC             IP Address          IPs  Name
------------------------------------------------------------------------------------
mgmt    Up    Full  1000   N/A   N/A  2cc2.6064.4ec4  192.168.0.1/24        1
1       Disb  None  None   none  10   2cc2.603c.b0de  0.0.0.0/0             0
2       Disb  None  None   none  20   2cc2.6044.0a45  0.0.0.0/0             0
ve10    Down  N/A   N/A    N/A   10   2cc2.603c.b0de  10.0.1.1/24           1
ve20    Down  N/A   N/A    N/A   20   2cc2.6044.0a45  10.0.2.1/24           1

Global Throughput:0 bits/sec (0 bytes/sec)
Throughput:0 bits/sec (0 bytes/sec)

Port 1も2もDisb(disable)になっており、ve10もve20もDownしていることが確認できます。

データポートをenableするPlaybookの作成

vThunderのデータポートを利用可能にするために、Ansible実行用サーバーのplaybookディレクトリで、a10_interfaces_ethernet_enable.yamlという名前でPlaybookを作成します。 この操作がaXAPIでPUTを利用するコマンドに相当することから、aXPIをベースとするモジュールではこの操作がサポートされていません(2020年6月現在)。 そのため、このPlaybookではSSHでvThunderに接続してCLIでコマンドを実行するacos_commandを利用します。 CLIを利用するモジュールで利用する変数が異なることから、新たなインベントリファイルをhosts_cliとして作成します。

[root@ansible playbook]# vi hosts_cli

hosts_cliに以下の内容を記述し保存します。

[vThunder]
192.168.0.1

[vThunder:vars]
ansible_connection=network_cli
ansible_user=admin
ansible_password=a10
ansible_network_os=acos
ansible_become_password=""

[vThunder:vars]にSSHを利用するモジュールでのPlaybook全般で利用する以下の変数を記述しています。

  • ansible_connection: vThunderへのアクセスの仕方(SSH)を指定します。Ansibleでネットワーク機器を操作する際に共通で利用されるnetwork_cliを利用します。
  • ansible_user: vThunderにSSHでアクセスするためのユーザー名
  • ansible_password: vThunderにSSHでアクセスするためのパスワード
  • ansible_network_os: Ansibleでどのネットワーク機器を操作するかを指定します。A10の機器はACOSというOSを利用しているのでacosを指定します。
  • ansible_become_password: vThunderでConfigモードに入る際のパスワードを指定します。本演習ではパスワードを設定していないので空文字にしています。

[vThunder]にはPlaybookで操作対象にするThunder(本演習では1台のみ)のIPアドレスを記述しています。

次に、a10_interfaces_ethernet_enable.yamlという名前でacos_commandを利用するPlaybookを作成します。

[root@ansible playbook]# vi a10_interfaces_ethernet_enable.yaml

vThunderの持つ2つのデータポートを連続してenableし、設定を保存にするようにPlaybookを記述します。

---
- hosts: 192.168.0.1
  connection: local
  gather_facts: no
  become: True
  collections:
    - a10.acos_cli

  tasks:
    - name: Enable Interface Ethernet
      acos_command:
        commands:
          - command: "configure"
          - command: "interface ethernet 1"
          - command: "enable"
          - command: "exit"
          - command: "interface ethernet 2"
          - command: "enable"
          - command: "exit"
          - command: "write memory all-partitions"
  • commands:は、モジュールのパラメーターで、command:で設定するCLIコマンドを上から順番に実施します。

ここまで記述したところで、Playbookを保存しコマンドラインに戻ります。

データポートをenableするPlaybookの実行

このPlaybookを実行すると、以下のようになります。hosts_cliをインベントリファイルとして利用することにご注意ください。 (注:このPlaybookが動作するにはAnsibleサーバー上にvThunderの公開鍵が保存されている必要があります。もし動作しない場合はAnsibleサーバーから一度vThunderにSSHでログインしてください)

[root@ansible playbook]# ansible-playbook -i hosts_cli a10_interfaces_ethernet_enable.yaml

PLAY [192.168.0.1] ********************************************************************************************************************************

TASK [Enable Interface Ethernet] *****************************************************************************************************************
changed: [192.168.0.1]

PLAY RECAP ****************************************************************************************************************************************
192.168.0.1                : ok=1    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0

タスクが実行され、ethernet 1と2がenableになり、write memoryで変更した構成が起動用の設定として保存されたことがわかります。

vThunderの設定を確認してみましょう。

vThunder#show running-config
!Current configuration: 385 bytes
!Configuration last updated at 14:44:38 IST Thu Sep 12 2019
!Configuration last saved at 14:44:41 IST Thu Sep 12 2019
!64-bit Advanced Core OS (ACOS) version 4.1.4-GR1, build 78 (Jan-18-2019,16:02)
!
multi-config enable
!
terminal idle-timeout 0
!
vlan 10
  untagged ethernet 1
  router-interface ve 10
!
vlan 20
  untagged ethernet 2
  router-interface ve 20
!
interface management
  ip address 192.168.0.1 255.255.255.0
!
interface ethernet 1
  enable
!
interface ethernet 2
  enable
!
interface ve 10
  ip address 10.0.1.1 255.255.255.0
!
interface ve 20
  ip address 10.0.2.1 255.255.255.0
!
!
end
!Current config commit point for partition 0 is 0 & config mode is classical-mode

interface ethernet 1と2がenableになっています。

ここで、CLIコマンドshow interfaces briefをvThunderで実行します。

vThunder#show interfaces brief
Port    Link  Dupl  Speed  Trunk Vlan MAC             IP Address          IPs  Name
------------------------------------------------------------------------------------
mgmt    Up    Full  1000   N/A   N/A  2cc2.6064.4ec4  192.168.0.1/16        1
1       Up    Full  10000  none  10   2cc2.603c.b0de  0.0.0.0/0             0
2       Up    Full  10000  none  20   2cc2.6044.0a45  0.0.0.0/0             0
ve10    Up    N/A   N/A    N/A   10   2cc2.603c.b0de  10.0.1.1/24           1
ve20    Up    N/A   N/A    N/A   20   2cc2.6044.0a45  10.0.2.1/24           1

Global Throughput:0 bits/sec (0 bytes/sec)
Throughput:0 bits/sec (0 bytes/sec)

ethernet 1と2がUpになり、ve10とve20もUpになっていることが確認できます。

再度同じPlaybookを実行してみます。

[root@ansible playbook]# ansible-playbook -i hosts_cli a10_interfaces_ethernet_enable.yaml

PLAY [192.168.0.1] ********************************************************************************************************************************

TASK [Enable Interface Ethernet] ******************************************************************************************************************
ok: [192.168.0.1]

PLAY RECAP ****************************************************************************************************************************************
192.168.0.1                : ok=1    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0

冪等性が保たれていることがわかります。

スタティックルートを設定するPlaybookの作成

実習の環境では、クライアントとvThunderとの間にルーターがあるため、クライアント側に通信を戻す場合にはルーターに対するスタティックルートを設定しないとクライアントに通信が正しく戻りません。 このスタティックルートを設定にするために、Ansible実行用サーバーのplaybookディレクトリで、a10_ip_route_rib_create.yamlという名前でPlaybookを作成します。

[root@ansible playbook]# vi a10_ip_route_rib_create.yaml

スタティックルートを設定して設定を保存するようにPlaybookを記述します。

---
- hosts: 192.168.0.1
  connection: local
  gather_facts: no
  collections:
    - a10.acos_axapi

  vars:
    ansible_host: "192.168.0.1"
  tasks:
  - name: Configure Static Route
    a10_ip_route_rib:
      ansible_host: "{{ ansible_host }}"
      ansible_port: "{{ ansible_port }}"
      ansible_username: "{{ ansible_username }}"
      ansible_password: "{{ ansible_password }}"
      ip_dest_addr: "0.0.0.0"
      ip_mask: "/0"
      ip_nexthop_ipv4:
        - ip_next_hop: "10.0.1.254"
      state: present

  - name: Write memory
    a10_write_memory:
      ansible_host: "{{ ansible_host }}"
      ansible_port: "{{ ansible_port }}"
      ansible_username: "{{ ansible_username }}"
      ansible_password: "{{ ansible_password }}"
      state: present
      partition: all
  • ip_dest_addr: "0.0.0.0"は、宛先アドレス帯を指定するパラメーターで、"0.0.0.0"は全ての宛先アドレス帯を指します。
  • ip_mask:は、宛先アドレス帯のサブネットマスクを指定するパラメーターで、"/0"で全てのサブネットマスクを指します。
  • ip_nexthop_ipv4:は、リスト形式のパラメーターで、ip_next_hop:で宛先のルーターを指定します。ここでは、"10.0.1.254"として、クライアントとvThunderの間にあるルーターを指すようにしています。

上記の設定により、Webサーバー側(10.0.2.0/24)以外への通信は全て10.0.1.254に転送されるようになります。 ここまで記述したところで、Playbookを保存しコマンドラインに戻ります。

スタティックルートを設定するPlaybookの実行

このPlaybookを実行すると、以下のようになります。ここではhostsをインベントリファイルとして利用することにご注意ください。

[root@ansible playbook]# ansible-playbook -i hosts a10_ip_route_rib_create.yaml

PLAY [192.168.0.1] ********************************************************************************************************************************

TASK [Configure Static Route] *********************************************************************************************************************
changed: [192.168.0.1]

TASK [Write memory] *******************************************************************************************************************************
changed: [192.168.0.1]

PLAY RECAP ****************************************************************************************************************************************
192.168.0.1                : ok=2    changed=2    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0

タスクが実行され、スタティックルートが設定されて、write memoryで変更した構成が起動用の設定として保存されたことがわかります。

vThunderの設定を確認してみましょう。

vThunder#show running-config
!Current configuration: 385 bytes
!Configuration last updated at 14:44:38 IST Thu Sep 12 2019
!Configuration last saved at 14:44:41 IST Thu Sep 12 2019
!64-bit Advanced Core OS (ACOS) version 4.1.4-GR1, build 78 (Jan-18-2019,16:02)
!
multi-config enable
!
terminal idle-timeout 0
!
vlan 10
  untagged ethernet 1
  router-interface ve 10
!
vlan 20
  untagged ethernet 2
  router-interface ve 20
!
interface management
  ip address 192.168.0.1 255.255.255.0
!
interface ethernet 1
  enable
!
interface ethernet 2
  enable
!
interface ve 10
  ip address 10.0.1.1 255.255.255.0
!
interface ve 20
  ip address 10.0.2.1 255.255.255.0
!
!
ip route 0.0.0.0 /0 10.0.1.254
!
!
end
!Current config commit point for partition 0 is 0 & config mode is classical-mode

スタティックルートの部分が設定されていることがわかります。 (注: このモジュールは2020年6月現在冪等性が保たれていません)

クライアントとWebサーバーからのvThunderへの疎通確認

データポートが利用可能になったので、クライアントからvThunderへの疎通確認を行うことができます。 CentOSクライアントからvThunderのve10(10.0.1.1)に対してターミナルからpingを実行すると応答が返ってくるので、疎通を確認できます。 疎通が確認できたら、[Ctrl]+[C]でPingを停止してください。

-bash-4.2$ ping 10.0.1.1
PING 10.0.1.1 (10.0.1.1) 56(84) bytes of data.
64 bytes from 10.0.1.1: icmp_seq=1 ttl=63 time=20.1 ms
64 bytes from 10.0.1.1: icmp_seq=2 ttl=63 time=11.8 ms
64 bytes from 10.0.1.1: icmp_seq=3 ttl=63 time=18.1 ms
64 bytes from 10.0.1.1: icmp_seq=4 ttl=63 time=17.7 ms
64 bytes from 10.0.1.1: icmp_seq=5 ttl=63 time=16.5 ms
64 bytes from 10.0.1.1: icmp_seq=6 ttl=63 time=17.1 ms
64 bytes from 10.0.1.1: icmp_seq=7 ttl=63 time=16.6 ms
64 bytes from 10.0.1.1: icmp_seq=8 ttl=63 time=18.8 ms
64 bytes from 10.0.1.1: icmp_seq=9 ttl=63 time=15.2 ms
^C
--- 10.0.1.1 ping statistics ---
9 packets transmitted, 9 received, 0% packet loss, time 8005ms
rtt min/avg/max/mdev = 11.894/16.949/20.156/2.235 ms

同様に、Webサーバー(実体は別のvThunder)にログインし、vThunderのve20(10.0.2.1)に対してpingを実行すると応答が返ってくるので、疎通を確認できます。

vThunder#ping 10.0.2.1
PING 10.0.2.1 (10.0.2.1) 56(84) bytes of data.
64 bytes from 10.0.2.1: icmp_seq=1 ttl=64 time=29.9 ms
64 bytes from 10.0.2.1: icmp_seq=2 ttl=64 time=28.5 ms
64 bytes from 10.0.2.1: icmp_seq=3 ttl=64 time=26.7 ms
64 bytes from 10.0.2.1: icmp_seq=4 ttl=64 time=25.0 ms
64 bytes from 10.0.2.1: icmp_seq=5 ttl=64 time=31.8 ms

--- 10.0.2.1 ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4006ms
rtt min/avg/max/mdev = 25.076/28.435/31.872/2.387 ms

vThunderからもpingを実行すると応答が返ってくるので、疎通を確認できます。

vThunder#ping 10.0.2.11
PING 10.0.2.11 (10.0.2.11) 56(84) bytes of data.
64 bytes from 10.0.2.11: icmp_seq=1 ttl=64 time=15.5 ms
64 bytes from 10.0.2.11: icmp_seq=2 ttl=64 time=21.9 ms
64 bytes from 10.0.2.11: icmp_seq=3 ttl=64 time=12.9 ms
64 bytes from 10.0.2.11: icmp_seq=4 ttl=64 time=15.6 ms
64 bytes from 10.0.2.11: icmp_seq=5 ttl=64 time=17.7 ms

--- 10.0.2.11 ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4005ms
rtt min/avg/max/mdev = 12.916/16.758/21.935/3.009 ms

これで、データポートのenableが完了しました。 次の演習では、サーバー負荷分散のためのServerの設定を行います。

本演習は以上となります。 トレーニングガイドに戻る