StackStorm.stackstorm

Ansible-st2

Ansible 角色和剧本,用于部署 StackStorm

StackStorm 是一个基于事件的自动化平台,使用 Python 编写。它提供了超过 50 个集成,如 GitHub、Docker、Nagios、NewRelic、AWS 和 Ansible,使您能够将现有基础设施连接成复杂的工作流,支持自动修复等功能。可以理解为运维的 IFTTT 协同。

E2E 测试 软件包仓库 deb/rpm 加入我们的社区 Slack

支持的平台

  • Ubuntu Focal (20.04)
  • RHEL 7 和 CentOS 7
  • RHEL 8 和 Rocky Linux 8

如果您使用提供的 Vagrantfile,请注意,它默认使用 Focal。

为了访问 StackStorm Web UI,请确保防火墙允许 http 和 https 端口的访问。

要求

支持的 Ansible 版本及其依赖项。 需要至少 2 GB 的内存和 3.5 GB 的磁盘空间,因为 StackStorm 包含 RabbitMQ、Mongo、Redis 和 nginx。

安装

# 部署 StackStorm
ansible-playbook stackstorm.yml

变量

以下是可以在剧本或清单中重新定义的变量列表,以自定义 StackStorm 的部署:

变量 默认值 描述
st2repo
st2repo_name stable 要安装的 StackStorm PackageCloud 仓库。stableunstablestaging-stablestaging-unstable
st2
st2_version latest 要安装的 StackStorm 版本。present 安装可用的软件包,latest 获取自动更新,或固定为数字版本如 2.2.0 或带修订号如 2.2.0-1
st2_config {} 用于在 st2.conf ini 文件中设置的 StackStorm 配置选项。
st2_system_user stanley 执行本地/远程 shell 操作的系统用户。
st2_system_user_in_sudoers yes st2_system_user 添加到 sudoers(建议为大多数 st2 功能正常工作)。
st2_ssh_key_file /home/{{st2_system_user}}/.ssh/{{st2_system_user}}_rsa st2_system_user SSH 私钥的路径。默认会自动生成。
st2_auth_enable yes 启用 StackStorm 独立认证。
st2_auth_username testu StackStorm 独立认证使用的用户名。
st2_auth_password testp StackStorm 独立认证使用的密码。
st2_save_credentials yes 将凭据保存至 /root/.st2/config 文件。
st2_rbac_enable no 启用 RBAC。
st2_rbac 查看角色默认值中的 st2_rbac 变量 RBAC 角色和分配。这是一个字典,包含三个键 rolesassignmentsmappings(基于 LDAP 群组成员资格)。rolesassignmentsmappings 为数组。每个数组元素遵循 StackStorm 文档中定义的 角色分配 的确切 YAML 结构。mappingshttps://docs.stackstorm.com/rbac.html#automatically-granting-roles-based-on-ldap-group-membership)略有不同,使用 namemapping 键,示例见 ./roles/StackStorm.st2/defaults/main.yml
st2_ldap_enable no 启用 LDAP 身份验证后端。
st2_ldap 查看角色默认值中的 st2_ldap 变量 LDAP 身份验证后端的设置。st2_ldap 是一个字典,包含一项 backend_kwargsbackend_kwargs 应按照 StackStorm 文档中的 LDAP 配置 列出的要求提供。
st2_packs [ st2 ] 要安装的软件包列表。此标志不适用于仅适用于 --python3 的软件包。
st2_python_packages [ ] 要安装到 /opt/stackstorm/st2 虚拟环境中的 Python 软件包列表。这在部署需要 Python 模块以使其正常工作的替代身份验证或协调后端时是必要的。
st2web
st2web_version latest 要安装的 st2web 版本。present 安装可用的软件包,latest 获取自动更新,或固定为数字版本如 2.2.0 或带修订号如 2.2.0-1
st2web_ssl_certificate null 自定义 SSL 证书字符串(.crt)。如果未提供,将生成自签名证书。
st2web_ssl_certificate_key null 自定义 SSL 证书私钥字符串(.key)。如果未提供,将生成自签名证书。
st2web_nginx_config null 自定义 nginx 配置文件字符串(st2.conf)。如果未提供,将使用默认的 st2.conf。
st2chatops
nodejs_major_version 14 默认适用于 st2chatops 版本 >= 3.5.0。
st2chatops_version latest 要安装的 st2chatops 版本。present 安装可用的软件包,latest 获取自动更新,或固定为数字版本如 2.2.0 或带修订号如 2.2.0-1
st2chatops_st2_api_key 使用 "st2 apikey create -k" 更新 st2chatops.env 的 st2 API 密钥。
st2chatops_hubot_adapter 用于 st2chatops 的 Hubot 适配器。默认是 shell,应该更改为 支持的适配器. [必需]
st2chatops_config { } 基于 st2chatops_hubot_adapter 的适配器提供适配器设置的哈希,用于更新 st2chatops.env。例如,对于 Slack hubot 适配器: st2chatops_config: HUBOT_SLACK_TOKEN: xoxb-CHANGE-ME-PLEASE
st2chatops_version latest 要安装的 st2chatops 版本。使用 latest 获取自动更新或固定为数字版本如 2.2.0

示例

在本地机器上安装最新的 stable StackStorm 及其所有组件:

ansible-playbook --inventory localhost, --connection local stackstorm.yml

在名为 stackstorm.example.com 的远程机器上安装 StackStorm,创建并引用一个清单:

echo "stackstorm.example.com" > inventory
ansible-playbook --inventory inventory stackstorm.yml

保持使用 latest 版本有助于通过重新运行剧本更新 StackStorm,因为当有新版本可用时将重新安装(升级)st2。

这是默认行为。如果您不想要更新,可以考虑固定特定的版本和修订号。

安装一个特定版本的 st2,指定修订号:

ansible-playbook stackstorm.yml --extra-vars "st2_version=2.2.0 st2_revision=8"

在代理后安装

如果您在代理后安装,可以在剧本中使用环境变量 http_proxyhttps_proxyno_proxy。对于 st2smoketests,您需要为 localhost 禁用代理。

environment:
  http_proxy: http://proxy.example.net:3128
  https_proxy: http://proxy.example.net:3128
  no_proxy: 127.0.0.1,localhost

开发

ansible-st2 开发时需满足一些要求。

我们必须支持的平台(必须通过端到端测试):

  • Ubuntu Focal (20.04)
  • CentOS 7
  • Rocky Linux 8
  • RHEL 7(通过 AWS)
  • RHEL 8(通过 AWS)

剧本和角色必须支持 Ansible 的幂等性。 也就是说,重新运行 stackstorm.yml 剧本的结果必须是 changed=0.*failed=0(假设版本和修订号已固定)。

对于本地开发,提供了一个 Vagrantfile。 默认情况下,以下命令将设置一个 ubuntu20 box (ubuntu/focal64):

vagrant up

其他受支持的发行版:

vagrant up ubuntu20
vagrant up centos7
vagrant up rockylinux8

其他安装方法

您可能会对其他部署 StackStorm 的方法感兴趣:

获取帮助

如果您遇到任何问题,我们的社区随时乐意提供帮助,欢迎您:

欢迎您提出问题、评论和贡献,非常感谢!

关于项目

Install StackStorm (IFTTT for Ops) with all the components like Web UI, ChatOps and dependant services including RabbitMQ, MongoDB, nginx.

安装
ansible-galaxy install StackStorm.stackstorm
许可证
apache-2.0
下载
624.6k
拥有者
Event-driven automation. Used by Netflix & many more....