charliemaiors.shinobi

忍者

构建状态

忍者角色将部署 Shinobi CCTV 系统在 Ubuntu、CentOS 或 Archlinux 系统上。使用变量可以部署 CE(社区版)或 Pro(专业版)版本。

要求

该角色的要求是 Nodejs 和 npm 以及 FFMPEG;另外还需要一个运行中的 Mariadb/Postgres 实例,并提前创建好 shinobi 数据库和架构,或可使用 shinobi-db 角色 部署。

角色变量

这个角色需要三个主要变量(除非是子节点,见集群):

db_host: "localhost"
shinobi_pass: "test"
shinobi_port: "8080"

db_host 变量是 shinobi 数据库的地址,角色假设数据库已创建并配置;如果地址错误,角色不会失败,但 Shinobi 将无法工作。shinobi_pass 变量是连接数据库所需的 shinobi 后端服务密码。shinobi_port 变量是端口。

默认变量为:

random_key: "{{ lookup('password', '/dev/null length=15 chars=ascii_letters') }}"
ce_version: "https://gitlab.com/Shinobi-Systems/ShinobiCE.git"
pro_version: "https://gitlab.com/Shinobi-Systems/Shinobi.git"
ce: true
pro: false
lts: true
startup: true
shinobi_user: "shinobi"
shinobi_version: "HEAD"
dbhash: "md5"

random_key 变量用于随机密码生成。ce/pro_version 是社区版和专业版 Shinobi 代码库的引用。ce/pro 标志定义下载哪个版本。lts 标志表示安装哪个版本的 Node,以避免安装 sqlite 依赖(对于 Node.js v8,sqlite 从 npm 安装会失败)。shinobi_user 是用于数据库的默认 shinobi 用户,dbhash 是用于密码存储的哈希算法(见 依赖部分)。shinobi_version 是需要从 shinobi 仓库克隆的提交哈希或分支。

集群

随着 子节点 的引入,可以定义两个额外变量:

cluster: true  false
cluster_role: "child"  "master"

如果 cluster_role 设置为 child,则还必须提供 master_keymaster_ip

依赖关系

该角色与 nodejs 和 ffmpeg 角色有直接依赖关系,并与 Mysql/Mariadb 和 shinobi 架构有间接依赖。直接依赖列表为:

  • charliemaiors.nodejs (lts 标志同样适用于 nodejs 角色以确定安装的版本)
  • charliemaiors.ffmpeg

间接依赖是与 charliemaiors.shinobi-db 的依赖,使用 shinobi_usershinobi_pass 作为公共变量,db_host 变量可以通过数据库主机地址(或在同一机器上的情况下为 localhost)来确定。

示例剧本

这是一个在单台主机上安装的示例:

  - name: 在单台主机上部署 Shinobi
  hosts: shinobi-all-in-one
  vars:
    shinobi_pass: "shinobi-test-machine"
    db_host: "localhost"
    shinobi_port: "8080"
    user_pass: "shinobi-test"
    user_mail: "[email protected]"
    dbhash: "sha256"
    startup: true
    ce: false
    pro: true
    lts: true
  roles:
    - charliemaiors.nodejs
    - charliemaiors.ffmpeg
    - charliemaiors.shinobi-db
    - charliemaiors.shinobi

这是一个在不同机器上部署数据库的示例:

-- name: 部署 shinobi 数据库
  hosts: shinobi-db
  roles:
    - { role: charliemaiors.shinobi-db, shinobi_pass: "shinobi-test-machine", user_pass: "shinobi-test", user_mail: "[email protected]"}

- name: 部署 shinobi 前端
  hosts: shinobi-fe
  roles:
    - charliemaiors.nodejs
    - charliemaiors.ffmpeg
    - { role: charliemaiors.shinobi,  db_host: "{{ hostvars[groups['shinobi-db'][0]].ansible_host }}", shinobi_port: "8080", user_pass: "shinobi-test", user_mail: "[email protected]", shinobi_pass: "shinobi-test-machine", startup: true, ce: false, pro: true }

这是一个在不同机器上部署数据库并拥有子节点的示例:

- name: 部署 shinobi 数据库
  hosts: shinobi-db
  roles:
    - { role: charliemaiors.shinobi-db, shinobi_pass: "shinobi-test-machine", user_pass: "shinobi-test", user_mail: "[email protected]"}

- name: 部署 shinobi 主节点
  hosts: shinobi-master
  roles:
    - charliemaiors.nodejs
    - charliemaiors.ffmpeg
    - { role: charliemaiors.shinobi,  db_host: "{{ hostvars[groups['shinobi-db'][0]].ansible_host }}", shinobi_port: "8080", user_pass: "shinobi-test", user_mail: "[email protected]", shinobi_pass: "shinobi-test-machine", startup: true, ce: false, pro: true, cluster: true, cluster_role: "master", master_key: "test" }

- name: 部署 shinobi 子节点
  hosts: shinobi-childs
  roles:
    - charliemaiors.nodejs
    - charliemaiors.ffmpeg
    - { role: charliemaiors.shinobi,  master_ip: "{{ hostvars[groups['shinobi-master'][0]].ansible_host }}", cluster: true, cluster_role: "child", master_key: "test" }

许可证

GNU GPL

作者信息

该角色由 Carlo Maiorano 于 2018 年创建,作为阿尔玛·马特尔·斯图迪奥姆的计算机科学与工程系的开发者,由小组负责人 Paolo Bellavista 领导和监督。

关于项目

Shinobi CCTV deployment

安装
ansible-galaxy install charliemaiors.shinobi
许可证
Unknown
下载
644