Ubuntu CIS Hardening Ansible Role 使用教程
ubuntu2004_cisUbuntu CIS Hardening Ansible Role项目地址:https://gitcode.com/gh_mirrors/ub/ubuntu2004_cis
1. 项目的目录结构及介绍
ubuntu2004_cis/
├── defaults
│ └── main.yml
├── handlers
│ └── main.yml
├── meta
│ └── main.yml
├── tasks
│ ├── main.yml
│ ├── 1_initial_setup.yml
│ ├── 2_services.yml
│ ├── 3_network.yml
│ ├── 4_logging_and_auditing.yml
│ ├── 5_access_control.yml
│ ├── 6_system_maintenance.yml
│ └── 7_additional_hardening.yml
├── templates
│ └── etc
│ └── audit
│ └── audit.rules.j2
├── tests
│ ├── inventory
│ └── test.yml
└── vars
└── main.yml
defaults/main.yml
: 默认配置文件,包含所有可配置的变量及其默认值。handlers/main.yml
: 处理程序文件,定义在任务执行后需要触发的操作。meta/main.yml
: 元数据文件,包含角色依赖等信息。tasks/
: 任务目录,包含多个任务文件,分别对应不同的安全加固步骤。templates/
: 模板目录,包含需要动态生成的配置文件模板。tests/
: 测试目录,包含测试用的 inventory 文件和测试 playbook。vars/main.yml
: 变量文件,包含角色使用的变量。
2. 项目的启动文件介绍
项目的启动文件主要是 tasks/main.yml
,它负责调用其他子任务文件,按照顺序执行安全加固步骤。
---
- name: Include initial setup tasks
import_tasks: 1_initial_setup.yml
- name: Include services tasks
import_tasks: 2_services.yml
- name: Include network tasks
import_tasks: 3_network.yml
- name: Include logging and auditing tasks
import_tasks: 4_logging_and_auditing.yml
- name: Include access control tasks
import_tasks: 5_access_control.yml
- name: Include system maintenance tasks
import_tasks: 6_system_maintenance.yml
- name: Include additional hardening tasks
import_tasks: 7_additional_hardening.yml
3. 项目的配置文件介绍
项目的配置文件主要是 defaults/main.yml
,它定义了所有可配置的变量及其默认值。以下是部分配置示例:
---
# 是否需要 OpenLDAP 客户端
ubuntu2004cis_openldap_clients_required: false
# 是否需要 Telnet
ubuntu2004cis_telnet_required: false
# 是否需要 Talk
ubuntu2004cis_talk_required: false
# 是否需要 RSH
ubuntu2004cis_rsh_required: false
# 是否需要 YPBind
ubuntu2004cis_ypbind_required: false
# 是否需要 RPC
ubuntu2004cis_rpc_required: false
# 时间同步工具
ubuntu2004cis_time_synchronization: chrony
# 时间同步服务器
ubuntu2004cis_time_synchronization_servers:
- uri: "0.pool.ntp.org"
config: "minpoll 8"
- uri: "1.pool.ntp.org"
config: "minpoll 8"
- uri: "2.pool.ntp.org"
config: "minpoll 8"
- uri: "3.pool.ntp.org"
config: "minpoll 8"
通过修改这些变量,可以定制化加固过程,满足不同的安全需求。
ubuntu2004_cisUbuntu CIS Hardening Ansible Role项目地址:https://gitcode.com/gh_mirrors/ub/ubuntu2004_cis