O-X-L/ansible-collection-nftables
GitHub: O-X-L/ansible-collection-nftables
通过 Ansible 模块实现对 Linux nftables 防火墙的声明式配置与自动化部署。
Stars: 16 | Forks: 1
# Ansible Collection - oxlorg.nftables
[](https://galaxy.ansible.com/ui/repo/published/oxlorg/nftables)
[](https://github.com/O-X-L/ansible-collection-nftables/actions/workflows/lint.yml)
[](https://github.com/O-X-L/ansible-collection-nftables/actions/workflows/test.yml)
**功能测试**:
* 状态: [](https://github.com/O-X-L/ansible-collection-nftables/blob/latest/scripts/test.sh) |
[](https://github.com/O-X-L/ansible-collection-nftables/actions/workflows/functional_test_result.yml)
* 日志: [API](https://ci.oss.oxl.app/api/job/ansible-test-collection-nftables/logs?token=2b7bba30-9a37-4b57-be8a-99e23016ce70&lines=1000) |
[每日存档](https://github.com/O-X-L/ansible-collection-nftables/actions/workflows/functional_test_result.yml) |
[简略](https://badges.oss.oxl.app/log/collection_oxlorg.nftables_test_short.log) | [完整](https://badges.oss.oxl.app/log/collection_oxlorg.nftables_test.log)
内部 CI: [Tester Role](https://github.com/O-X-L/ansible-role-oxl-cicd) | [Jobs API](https://github.com/O-X-L/github-self-hosted-jobs-systemd)
## 用法
参见: [文档](https://ansible-nftables.oxl.app)
[](https://status.oxl.at/endpoints/1--oxl_nftables-ansible-collection-docs)
[备用链接](https://nftables-ansible.readthedocs.io/)
你需要一个简单的 Ansible GUI 吗?请查看我们的 [Ansible WebUI](https://github.com/O-X-L/ansible-webui)
## 模块
未实现 => 开发中 => [测试中](https://github.com/O-X-L/ansible-collection-nftables/blob/latest/tests) => 不稳定 (_实际测试_) => 稳定
| 功能 | 模块 | 用法 | 状态 |
|:--------------------|:-----------------------------|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:----------------|
| **列表** | oxlorg.nftables.list | [文档](https://ansible-nftables.oxl.app/modules/list.html) | 测试中 |
| **规则** | oxlorg.nftables.rule | [文档](https://ansible-nftables.oxl.app/modules/rule.html), [NFTables 文档](https://wiki.nftables.org/wiki-nftables/index.php/Quick_reference-nftables_in_10_minutes#Rules) | 开发中 |
| **1 对 1 规则** | oxlorg.nftables.rule_raw | [文档](https://ansible-nftables.oxl.app/modules/rule.html), [NFTables 文档](https://wiki.nftables.org/wiki-nftables/index.php/Quick_reference-nftables_in_10_minutes#Rules) | 测试中 |
| **链** | oxlorg.nftables.chain | [文档](https://ansible-nftables.oxl.app/modules/chain.html), [NFTables 文档](https://wiki.nftables.org/wiki-nftables/index.php/Configuring_chains) | 测试中 |
| **表** | oxlorg.nftables.table | [文档](https://ansible-nftables.oxl.app/modules/table.html), [NFTables 文档](https://wiki.nftables.org/wiki-nftables/index.php/Configuring_tables) | 测试中 |
| **变量** | oxlorg.nftables.var | [文档](https://ansible-nftables.oxl.app/modules/var.html), [NFTables 文档](https://wiki.nftables.org/wiki-nftables/index.php/Scripting#Defining_variables) | 未实现 |
| **集合** | oxlorg.nftables.set | [文档](https://ansible-nftables.oxl.app/modules/set.html), [NFTables 文档](https://wiki.nftables.org/wiki-nftables/index.php/Sets) | 未实现 |
| **限制** | oxlorg.nftables.limit | [文档](https://ansible-nftables.oxl.app/modules/limit.html), [NFTables 文档](https://wiki.nftables.org/wiki-nftables/index.php/Limits) | 未实现 |
| **计数器** | oxlorg.nftables.counter | [文档](https://ansible-nftables.oxl.app/modules/counter.html), [NFTables 文档](https://wiki.nftables.org/wiki-nftables/index.php/Counters) | 未实现 |
## 需求
首先 - 安装 nftables!
为了使 python 库正常工作,已安装的 NFTables 版本需要 >= 0.9.3
```
sudo apt install nftables
# 检查已安装的版本
sudo apt policy nftables
```
此 collection 的 ansible-modules 使用 [python3-nftables module](https://ral-arturo.org/2020/11/22/python-nftables-tutorial.html) 与 nftables 进行交互。
你可以在目标系统上使用包管理器安装它(_示例中为 apt_),或者使用 pip(_[OXL 提供的非官方版本](https://github.com/O-X-L/python3-nftables)_)。
```
# 包管理器
sudo apt install python3-nftables
# pip => 确保其为 root 用户安装或使用 virtualenv
sudo pip install oxl-libnftables
```
你可能希望使用 Ansible 安装它:
```
- name: Installing NFTables
ansible.builtin.package:
name: ['nftables'] # or ['nftables', 'python3-nftables']
- name: Installing NFTables python-module
ansible.builtin.pip:
name: 'oxl-libnftables'
- name: Enabling and starting NFTables
ansible.builtin.service:
name: 'nftables.service'
state: started
enabled: true
```
然后 - 安装 collection 本身:(_在 controller 上_)
```
# 不稳定/最新版本:
ansible-galaxy collection install oxlorg.nftables
## 或者
ansible-galaxy collection install git+https://github.com/O-X-L/ansible-collection-nftables.git
# 安装到特定目录以便于开发
cd $PLAYBOOK_DIR
ansible-galaxy collection install git+https://github.com/O-X-L/ansible-collection-nftables.git -p ./collections
```
标签:Ansible, Ansible Collection, Awesome, DNS解析, EC2, IaC, libnftables, Linux防火墙, NFTables, Python, 包过滤, 开源项目, 无后门, 系统提示词, 系统管理, 网络信息收集, 网络安全, 自动化运维, 逆向工具, 隐私保护