marcstraube/ansible-collection-common

GitHub: marcstraube/ansible-collection-common

一个为多操作系统提供共享 Ansible 角色集合,用于自动化运维与安全加固。

Stars: 0 | Forks: 0

# Ansible 集合:marcstraube.common [![CI](https://static.pigsec.cn/wp-content/uploads/repos/2026/04/b9f2a212da155108.svg)](https://github.com/marcstraube/ansible-collection-common/actions) [![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE) [![Sponsor](https://img.shields.io/badge/sponsor-PayPal-blue.svg)](https://paypal.me/marcstraube) ## 描述 用于多操作系统基础设施管理的共享 Ansible 角色。 37 个角色涵盖基础系统、安全、网络、软件包管理、 用户管理、编辑器等功能。 ## 支持的平台 - Arch Linux(滚动发布) - Debian Trixie(13) - EL 9(Rocky、Alma、RHEL) - EL 10(Rocky、Alma、RHEL) ## 要求 - ansible-core >= 2.17 ## 包含的角色 ### 基础系统 | 角色 | 描述 | | ---------- | ---------------------------------------------- | | **base** | 主机名、时区、语言环境、内核、systemd | | **users** | 用户/组管理并支持 SSH 密钥 | | **sudo** | Sudo 配置 | | **editors**| 文本编辑器(nano、vim、neovim)及用户级配置 | | **utils** | CLI 工具与监控工具 | | **fonts** | 系统字体与 Nerd 字体 | | **energy_management** | 功耗管理(logind、PPD/TLP/tuned) | | **graphics** | 显卡驱动(Intel、NVIDIA、AMD) | ### 软件包管理 | 角色 | 描述 | | --------------- | --------------------------------------- | | **package_management** | pacman、APT、DNF、AUR 助手(paru)、reflector | | **nodejs** | Node.js 与 NVM | | **python** | Python 解释器及相关工具 | | **ansible** | Ansible、Molecule 及代码检查工具 | ### 网络 | 角色 | 描述 | | -------------- | ------------------------ | | **networkmanager** | NetworkManager 配置 | | **firewalld** | 防火墙管理 | | **wireguard** | WireGuard VPN | | **unbound** | 支持 DNSSEC 的 DNS 解析器 | | **avahi** | mDNS/DNS-SD 服务发现 | | **openssh** | OpenSSH 服务器与客户端 | ### 安全 | 角色 | 描述 | | --------------- | ----------------------------------| | **hardening** | 内核与文件系统加固 | | **sysctl** | 内核参数调优 | | **pam_hardening** | PAM 安全(pwquality、faillock) | | **apparmor** | AppArmor 强制访问控制 | | **firejail** | 应用程序沙箱 | | **fail2ban** | 入侵预防 | | **auditd** | Linux 审计守护进程 | | **aide** | 高级入侵检测环境 | | **lynis** | 安全审计 | | **rkhunter** | 根套件检测 | | **clamav** | ClamAV 防病毒 | ### 加密与认证 | 角色 | 描述 | | ----------------- | ------------------------ | | **gnupg** | GnuPG 加密与签名 | | **pki** | PKI 证书管理 | | **hardware_tokens**| Nitrokey/YubiKey 支持 | ### 服务与基础设施 | 角色 | 描述 | | ---------- | ------------------------ | | **chrony** | NTP 时间同步 | | **logrotate** | 日志轮转 | | **podman** | 容器运行时 | | **snmp** | SNMP 监控代理 | | **restic** | 使用 restic 进行备份 | ## 安装 ### 从 Ansible Galaxy ``` ansible-galaxy collection install marcstraube.common ``` ### 从 Git ``` ansible-galaxy collection install git+https://github.com/marcstraube/ansible-collection-common.git,main ``` ### 需求文件 ``` # requirements.yml collections: - name: marcstraube.common version: ">=1.0.0" ``` ## 用法 所有角色均使用 `include_role` 并配合布尔开关: ``` - name: Configure system hosts: all become: true tasks: - name: Include base role ansible.builtin.include_role: name: marcstraube.common.base when: base_enabled | default(true) | bool - name: Include openssh role ansible.builtin.include_role: name: marcstraube.common.openssh when: openssh_enabled | default(true) | bool ``` 每个角色的变量文档位于 `defaults/main.yml` 和 `roles//README.md`。 ## 测试 角色通过 Molecule 使用 Podman 容器在所有支持的平台进行测试。 ``` cd roles/ molecule test ``` ## 许可证 MIT ## 作者 Marc Straube ()
标签:AMD, Ansible, Ansible 角色, Ansible 集合, APT, Arch Linux, Awesome, CI, Debian, dnf, DNF, GitHub Actions, GNU通用公共许可证, GPU, Intel, logind, marcstraube.common, MIT License, Nano, Neovim, Nerd Fonts, Node.js, NVM, OISF, pacman, PayPal, Python, RHEL, Rocky Linux, SEO, Sudo, systemd, TLP, tuned, Vim, yum, 内核, 包管理器, 图形, 基础系统, 基础设施管理, 多操作系统, 字体, 安全, 安全管理, 开源, 开源框架, 持续集成, 文本编辑, 无后门, 日志, 日志管理, 时区管理, 本地化, 权限管理, 模型越狱, 用户管理, 电源管理, 监控, 系统守护, 系统工具, 系统提示词, 系统管理, 统一API, 编辑器, 自动化运维, 自动笔记, 节能, 角色角色, 赞助, 超时处理, 软件仓库, 软件包管理, 软件安装, 软件更新, 驱动