LoginSignup
7
10

More than 5 years have passed since last update.

Ansible モジュール firewalld

Last updated at Posted at 2016-02-04

firewalld

firewalldに関する任意のポートやサービスを管理する
バージョン1.4で追加。

概要

常駐又は非常駐するfirewalldに対し、サービスやtcp/udpのポートの追加/削除の設定を行う。

前提条件

firewalldのバージョンが0.2.11以上。

オプション

引数 必須 デフォルト 備考
immediate
(1.9で追加)
no 即時に反映される。(firewalld-cmdの--permanentを指定しない場合と同様)
permanent yes リブート後も持続する。
permanent=true immediate=yesにするとfirewalld-cmdの--permanentを付けた場合+つけてない場合を同時に実行してくれて便利。
port no 追加/削除するポート番号/ポート範囲。形式はポート番号の場合、PORT/PROTOCOL。ポート範囲の場合、PORT-PORT/PROTOCOL。
rich_rule no 追加/削除するリッチな設定(firewall-cmdのadd-rich-rule/remove-rich-rule指定)
service no 追加/削除するサービス。 /usr/lib/firewalld/services/と/etc/firewalld/servicesにあるサービスを設定
source
(2.0で追加)
no True 追加/削除するソース/ネットワーク。
state yes ・enabled
・disabled
ポート接続の許可/拒否。
timeout no 非常駐時においての設定有効期間。
zone no システムデフォルト(public) ・work
・drop
・internal
・external
・trusted
・home
・dmz
・public
追加/削除するfirewalldのゾーンを指定する。(publicがデフォルト)ここに挙げたものは初期設定されているゾーンであり自分で作成したZoneを指定も可能。但しその場合Firewalldモジュールではなく先にゾーンを追加しといてね)

使用例

- firewalld: service=https permanent=true state=enabled
- firewalld: port=8081/tcp permanent=true state=disabled
- firewalld: port=161-162/udp permanent=true state=enabled
- firewalld: zone=dmz service=http permanent=true state=enabled
- firewalld: rich_rule='rule service name="ftp" audit limit value="1/m" accept' permanent=true state=enabled
- firewalld: source='192.168.1.0/24' zone=internal state=enabled

注意点

  • Debianベースのシステムでは未検証である。
  • Pythonのバージョンが3に変更された場合でもPython2のfirewalldのbindingを必要とする。

Ansible特別(extra)モジュール

このモジュールは現在Ansibleと一緒にリリースされるが、将来的に分離するかもしれない。コミュニティーによりメンテナンスされます。

7
10
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
7
10