LoginSignup
2
1

More than 5 years have passed since last update.

ansibleでBIG-IPを制御してみよう③

Posted at

はじめに

"ansibleでBIG-IPを制御してみよう①"
"ansibleでBIG-IPを制御してみよう②"
でバーチャルサーバを作成しましたが、今回は、BIG-IPの運用中に、サーバメンテナンスの為に、アクセスを片系に寄せたり、サービスを止めたいとかあると思うので、そのあたりを試してみた。

検証環境

VMWare ESXi 5.5
 CentOS Linux release 7.4.1708 (Core)
  ansible 2.4.0.0
 BIG-IP VE trial 12.1.2 Build 0.0.249

playbookのディレクトリ、ファイルは、前回の記事を引き継ぐ。
 ansible2.4用python環境 : /opt/ansible2.4
 playbookの格納先 : /opt/playbook
 ansibleの実行ユーザ : ansibleuser

ノードの閉塞

サーバ(ノード)へのアクセスを止めてみる。
利用シーンとしては、サーバのメンテナンス・再起動等で、対象のサーバへのアクセスを止める等。

Playbookの作成

今回は、Forced offlineでノードを止めてみます。

$ vi node_offline.yml

- hosts: localhost
  become: no
  gather_facts: no

  tasks:
# The BIG-IP GUI doesn't map directly to the API calls for "Node ->
# General Properties -> State". The following states map to API monitor
# and session states.
#
# Enabled (all traffic allowed):
# monitor_state=enabled, session_state=enabled
# Disabled (only persistent or active connections allowed):
# monitor_state=enabled, session_state=disabled
# Forced offline (only active connections allowed):
# monitor_state=disabled, session_state=disabled
#
# See https://devcentral.f5.com/questions/icontrol-equivalent-call-for-b-node-down

  - name: Force node offline
    bigip_node:
      session_state: "disabled"
      monitor_state: "disabled"
      partition: "Common"
      name: "webserver1"
      server:         "{{ bigip_ip }}"
      user:           "{{ bigip_user }}"
      password:       "{{ bigip_passwd }}"
      validate_certs: "no"
      state: "present"

※session_state,monitor_stateの組み合わせで、Enabled,Disabledもできる。

Playbookの実行

$ ansible-playbook -i hosts node_offline.yml

pool memberの閉塞

pool memberへのアクセスを止めてみる。
利用シーンとしては、サービスのメンテナンス・再起動等で、対象のサービスへのアクセスを止める等。
ノードの停止との違いは、1台のサーバで複数のサービス(例えばHTTPとFTPとか)を使っていると、ノードを止めてしまうと、全サービスへのアクセスが止まってしまうが、poolであればそのサービスのみ止められる。

Playbookの作成

今回は、Forced offlineでpool memberを止めてみます。

$ vi poolmember_offline.yml

- hosts: localhost
  become: no
  gather_facts: no

  tasks:
# The BIG-IP GUI doesn't map directly to the API calls for "Pool ->
# Members -> State". The following states map to API monitor
# and session states.
#
# Enabled (all traffic allowed):
# monitor_state=enabled, session_state=enabled
# Disabled (only persistent or active connections allowed):
# monitor_state=enabled, session_state=disabled
# Forced offline (only active connections allowed):
# monitor_state=disabled, session_state=disabled
#
# See https://devcentral.f5.com/questions/icontrol-equivalent-call-for-b-node-down

  - name: Force pool member offline
    bigip_pool_member:
      session_state: "disabled"
      monitor_state: "disabled"
      pool: "webserver-pool"
      partition: "Common"
      host: "webserver1"
      port: 80
      server:         "{{ bigip_ip }}"
      user:           "{{ bigip_user }}"
      password:       "{{ bigip_passwd }}"
      validate_certs: "no"
      state: "present"

※session_state,monitor_stateの組み合わせで、Enabled,Disabledもできる。

Playbookの実行

$ ansible-playbook -i hosts poolmember_offline.yml

VirtualServerの停止

VirtualServerを止めるシーンとして、ノードへのアクセスを全部止めてのメンテナンスとか考えたので、メンテナンスページに飛ばすとかを考えていたけれど、どのようは方式がよいか整理しきれなかったので、バーチャルサーバをただ止めるだけのサンプルにしました。

ちなみに考えていた、メンテナンスページへ飛ばす方法(未検証なので出来ないかもしれません)
- iRULEでメンテナンスページを表示するサーバにリダイレクト
- メンテナンスページを表示するサーバと、そこに飛ばすpoolを事前に作成しておいて、poolを切り替える
- BIG-IPでpool又はnodeが停止した時に、別ページに飛ばす(ProfileのFallback Hostとか、PoolのPriority Groupとか)

Playbookの作成

今回は、disabledでVirtualServerを止めてみます。

$ vi virtualserver_disabled.yml

- hosts: localhost
  become: no
  gather_facts: no

  tasks:
  - name: Delete virtual server
    bigip_virtual_server:
      partition: Common
      name: virtual-webserver
      server:         "{{ bigip_ip }}"
      user:           "{{ bigip_user }}"
      password:       "{{ bigip_passwd }}"
      validate_certs: "no"
      state: "disabled"

※stateをenabled起動。

Playbookの実行

$ ansible-playbook -i hosts virtualserver_disabled.yml

最後に

次は何を試そうか。bigip_qkview、bigip_ssl_certificate、bigip_ucsあたりかな。
今のところ決めていないので、次があるとしても少し間隔があいてしまうかと思います。

この記事に関して

この記事が提供している情報に関しては、合法性、正確性、安全性等、いかなる保証もされません。この記事を利用することによって生ずるいかなる損害に対しても一切責任を負いません。

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1