weareinteractive.ufw

Ansible weareinteractive.ufw 役割

ビルドステータス Galaxy GitHub タグ GitHub スター

weareinteractive.ufw は、Ansible の役割で、以下を行います:

  • ufwをインストール
  • ufwを設定
  • ufwのルールを設定
  • サービスを設定

インストール

ansible-galaxyを使用する場合:

$ ansible-galaxy install weareinteractive.ufw

requirements.ymlを使用する場合:

- src: weareinteractive.ufw

gitを使用する場合:

$ git clone https://github.com/weareinteractive/ansible-ufw.git weareinteractive.ufw

依存関係

  • Ansible >= 2.10

変数

この役割のデフォルト変数のリストは次の通りで、defaults/main.ymlでも利用可能です。

---
# サービスを開始し、システム起動時に有効にする
ufw_enabled: true

# インストールするパッケージのリスト
ufw_packages: ["ufw"]

# サービス名
ufw_service: ufw

# 適用するルールのリスト
# 詳細は https://docs.ansible.com/ansible/latest/collections/community/general/ufw_module.html を参照
ufw_rules:
  - rule: allow
    to_port: 22

# 設定ファイルの管理
ufw_manage_config: false

# 設定ファイルに渡す設定オブジェクト
ufw_config:
  IPV6: "yes"
  DEFAULT_INPUT_POLICY: DROP
  DEFAULT_OUTPUT_POLICY: ACCEPT
  DEFAULT_FORWARD_POLICY: DROP
  DEFAULT_APPLICATION_POLICY: SKIP
  MANAGE_BUILTINS: "no"
  IPT_SYSCTL: /etc/ufw/sysctl.conf
  IPT_MODULES: ""

# 設定ファイルへのパス
ufw_config_file: /etc/default/ufw

ハンドラー

handlers/main.ymlで定義されたハンドラーは以下の通りです。

---

- name: ufwをリセット
  community.general.ufw:
    state: reset

- name: ufwを再読み込み
  community.general.ufw:
    state: reloaded
  when: ufw_enabled | bool

使用方法

以下は例のプレイブックです:

# @see https://docs.ansible.com/ansible/latest/collections/community/general/ufw_module.html#examples
---

- hosts: all
  become: true
  roles:
    - weareinteractive.ufw
  vars:
    ufw_rules:
      # ロギングを設定
      - logging: "full"
      # OpenSSHを許可
      - rule: allow
        name: OpenSSH
      # OpenSSHルールを削除
      - rule: allow
        name: OpenSSH
        delete: true
      # tcpポート80への全てのアクセスを許可
      - rule: allow
        to_port: '80'
        proto: tcp
    # 設定ファイルを管理
    ufw_manage_config: true
    # 設定ファイルに渡す設定オブジェクト
    ufw_config:
      IPV6: "yes"
      DEFAULT_INPUT_POLICY: DROP
      DEFAULT_OUTPUT_POLICY: ACCEPT
      DEFAULT_FORWARD_POLICY: DROP
      DEFAULT_APPLICATION_POLICY: SKIP
      MANAGE_BUILTINS: "no"
      IPT_SYSCTL: /etc/ufw/sysctl.conf
      IPT_MODULES: ""

テスト

$ git clone https://github.com/weareinteractive/ansible-ufw.git
$ cd ansible-ufw
$ make test

貢献

正式なスタイルガイドはありませんが、既存のコーディングスタイルを維持するようにしてください。新しい機能や変更された機能には単体テストと例を追加してください。

  1. フォークする
  2. 新しい機能ブランチを作成 (git checkout -b my-new-feature)
  3. 変更をコミットする (git commit -am 'Add some feature')
  4. ブランチにプッシュする (git push origin my-new-feature)
  5. 新しいプルリクエストを作成する

注: README.mdファイルを更新するには、ansible-readmeをインストールして実行してください:

$ gem install ansible-readme
$ ansible-readme

ライセンス

Copyright (c) We Are Interactive MITライセンスの下で。

プロジェクトについて

Installs and configures ufw

インストール
ansible-galaxy install weareinteractive.ufw
ライセンス
mit
ダウンロード
240.4k