rhythmictech.ansible_thehive
ansible-thehive
描述
部署和配置 TheHive,这是一个优秀的开源事件响应工具。它基于 RPM 安装,并可以选择预先填充 ElasticSearch 索引,从而消除获取 TheHive 运行的一些繁琐手动步骤。
您需要单独安装 ElasticSearch。此角色已使用 Elastic 提供的 ansible 角色 进行测试。文档中包含示例配置。
这应覆盖大多数 TheHive 的用例,但欢迎 PR 和建议改进。
需求
- Ansible 2.0 或更高版本
- CentOS 7
- ElasticSearch 5.x
使用
建议在独立服务器上安装,虽然 ElasticSearch 和 Cortex 可以安全地与 TheHive 一起安装。默认启用可选的 Nginx 代理,支持 Vouch 和 LDAP 身份验证。如果使用委托身份验证,重要的是正确设置一个种子用户,以便您可以登录。
ElasticSearch 必须已经安装并运行。此角色是使用 ansible-elasticsearch 角色进行测试的,该角色可以从 Ansible Galaxy 导入。
推荐设置以下变量:
es_instance_name: "thehive"
es_version: 5.6.14
es_major_version: 5.x
es_data_dirs:
- "/data/es"
es_config:
node.name: "thehive"
cluster.name: "thehive"
node.data: true
node.master: true
script.inline: on
thread_pool.index.queue_size: 100000
thread_pool.search.queue_size: 100000
thread_pool.bulk.queue_size: 100000
es_scripts: true
es_templates: false
es_version_lock: false
es_heap_size: 1g
es_xpack_features: ["alerting","monitoring"]
请注意,TheHive 不支持 ElasticSearch 6.x。目前 ansible-elasticsearch 模块的主分支支持 5.x。
至少必须设置以下变量:
- thehive_url(TheHive 将可访问的域名)
- thehive_crypto_secret(请参见
defaults/main.yml
获取生成说明)
下面是一个示例常见配置,自动填充 TheHive 并使用 LDAP 身份验证和 Cortex:
thehive_url: "thehive.corp"
thehive_seed_initial_username: "admin"
thehive_http_addr: "127.0.0.1"
thehive_crypto_secret: "..."
thehive_auth_ldap:
enabled: true
servers: ["ldapserver.corp:636"]
use_ssl: true
bind_dn: "bind_dn"
bind_pw: "bind_pw"
search_base: "dc=corp"
username_attribute: "sAMAccountName"
}
thehive_cortex_servers:
cortex:
url: "http://127.0.0.1:9001/"
key: "..."
Vouch 身份验证
此角色支持通过 Vouch(前称 Lasso)代理进行身份验证。这允许您通过 Okta 等提供商进行 OAUTH 身份验证。
使用 Vouch 时,必须将 thehive_http_addr
设置为 127.0.0.1。因为 Vouch 使用 cookies 将身份验证信息通信回应用程序,您必须将 Vouch 代理和 TheHive 站点放在同一个域名下(例如,vouch.corp 和 thehive.corp)。
角色变量
# 是否安装 TheHive RPM 仓库。
# 除非您使用自己的 RPM 仓库,通常您会希望这样做。
thehive_install_repo: true
# 锁定和安装的 TheHive 版本
thehive_version: 3.2.1
# 请注意,映射和种子数据依赖于模式版本。
# 如果您安装的 TheHive 版本使用不同的索引名称,
# 映射和数据文件需要更新。
thehive_index: thehive_14
# TheHive URL。
thehive_url: localhost
# 是否应安装 nginx 实例作为代理
thehive_install_nginx: true
# 是否配置 nginx 代理
thehive_configure_nginx: true
# 引用的文件将包含在每个 nginx 服务器配置中
thehive_nginx_includes: []
# 可选地使用 Nginx 进行 SSL
thehive_nginx_ssl:
enabled: false
certificate: ""
key: ""
#cabundle: 如果使用捆绑提供
# TheHive 监听的端口。即使使用
# nginx 代理,仍可以更改此变量。
thehive_http_port: 9000
# TheHive 应绑定的 IP 地址。一般来说,这可以保持不变。不过,
# 当通过代理进行身份验证时,这必须设置为 127.0.0.1
thehive_http_addr: "0.0.0.0"
# 必填项。生成一个密钥,如下所示:
# cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 64 | head -n 1
thehive_secret: ""
# 默认情况下,TheHive 需要手动步骤进行配置。
# 您可以选择加载预配置映射和种子数据,这使得
# TheHive 立即可用。
thehive_load_seed_data: true
# 要创建的初始用户名称。如果您正在使用 Vouch 或 LDAP 进行身份验证,
# 必须将此设置为您的目录中的有效用户名。
# TheHive 不会在首次登录时创建用户。
thehive_seed_initial_username: "admin"
# 可选地使用 Vouch 身份验证(例如,Google 身份验证,Okta 等)
thehive_auth_vouch:
enabled: false
url: ""
logon_header: THEHIVE_USER
# 可选地使用 LDAP 身份验证。
thehive_auth_ldap:
enabled: false
servers: []
use_ssl: ""
bind_dn: ""
bind_pw: ""
search_base: ""
username_attribute: "cn"
# ElasticSearch 配置。如果使用推荐的 ES 配置,此
# 不需要更改。
thehive_es:
index: thehive
cluster: thehive
endpoint: 127.0.0.1:9300
# 与 TheHive 一起安装的包
thehive_packages:
- java-1.8.0-openjdk
- python-pip
- unzip
- git
- thehive-{{ thehive_version }}
# 如果使用 nginx 代理,将安装的软件包。
# libsemanage-python 是 selinux 所必需的。
thehive_nginx_packages:
- nginx
- libsemanage-python