作業環境
■ Ansible 側
- CentOS 8.0
- Python 3.7.7
- Ansible 2.9.6
■ FortiGate 側
- 型番:FortiGate 60E
- バージョン:v6.0.6 build0272 (GA)
fortios_system_global モジュール
fortios_system_global モジュールを使用することで FortiGate のコンフィグにおける config system global の各項目を設定することができます。
- アイドルタイムアウトの設定
- 機器ホスト名の設定
- GUI 言語の設定
- タイムゾーンの設定
などに利用できます。
主なパラメータ
パラメータ | 必須 | 選択肢/デフォルト | 説明 |
host | 対象機器のIPアドレス | ||
username | SSH用のユーザ | ||
password | ・”” ← | SSH用のパスワード | |
vdom | ・root ← | 対象機器のバーチャルドメイン | |
https | ・no ・yes ← | HTTPSを使用するかどうか | |
ssl_verify | ・no ・yes ← | 対象機器の証明書を検証するかどうか | |
system_global | config system global の設定項目を 子要素として指定する | ||
– admintimeout | 5 – 480 | アイドルタイムアウト時間(分) | |
– hostname | 機器ホスト名 | ||
– language | GUIの言語設定 | ||
– timezone | タイムゾーン |
備考
- Ansible 2.8 から追加されたモジュール
- Legacy モードでの実行のためには fortiosapi が必要
- httpapi での実行が可能
- system_global の子要素としては FortiGate の config system global の各設定項目に対応するものが指定可能と思われる(指定可能要素のリストは公式ドキュメント参照)
- system_global の各子要素で指定可能な値は FortiGate の仕様に準じていると思われる
使用例
httpapi を使用してモジュールを実行する例です。
■ インベントリ:hosts
[forti]
10.1.10.100
[forti:vars]
ansible_user=admin
ansible_password=password
ansible_network_os=fortios
ansible_connection=httpapi
ansible_httpapi_use_ssl=yes
ansible_httpapi_validate_certs=no
10.1.10.100 は操作対象の FortiGate のIPアドレスです。
httpapi で使用する変数をグループ変数として定義しています。
■ Playbook:systemGlobal.yml
- hosts: all
gather_facts: no
tasks:
- name: system_global test
fortios_system_global:
system_global:
language: "japanese"
hostname: "FGTAnsible"
admintimeout: "60"
timezone: "60"
■ Playbook 実行
# ansible-playbook -i hosts systemGlobal.yml
PLAY [all] **********************************************************************************************************
TASK [system_global test] *******************************************************************************************
changed: [10.1.10.100]
PLAY RECAP **********************************************************************************************************
10.1.10.100 : ok=1 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
■ 実行前の FortiGate のコンフィグ
FGT # show system global
config system global
set admintimeout 10
set alias "FGT*************"
set hostname "FGT"
set switch-controller enable
set timezone 04
end
※ language は english(デフォルト値)
■ 実行後の FortiGate のコンフィグ
FGTAnsible # show system global
config system global
set admintimeout 60
set alias "FGT*************"
set hostname "FGTAnsible"
set language japanese
set switch-controller enable
set timezone 60
end
Playbook で指定した通り設定値が変更されました。
―――――――――――――