feat: Introduce and deploy the Insight Workbench application with a dedicated Ansible role and Caddy routing.
This commit is contained in:
parent
06d7270c97
commit
140cd1e8ff
@ -43,6 +43,8 @@
|
||||
- { role: infra ,tags: infra } # setup infra components
|
||||
# node-monitor
|
||||
- { role: node_monitor ,tags: monitor } # init node exporter & vector
|
||||
# insight
|
||||
- { role: insight ,tags: insight } # setup insight workbench
|
||||
|
||||
|
||||
#--------------------------------------------------------------#
|
||||
|
||||
@ -23,6 +23,13 @@
|
||||
reverse_proxy 127.0.0.1:4318
|
||||
}
|
||||
|
||||
# -------------------------
|
||||
# Insight Workbench
|
||||
# -------------------------
|
||||
handle_path /insight/* {
|
||||
reverse_proxy 127.0.0.1:{{ workbench_port | default('8080') }}
|
||||
}
|
||||
|
||||
# -------------------------
|
||||
# Grafana: /ui/ 与 /ui/api/live/
|
||||
# -------------------------
|
||||
@ -127,8 +134,11 @@
|
||||
root * /www
|
||||
file_server browse
|
||||
|
||||
@home path /
|
||||
redir @home /insight 301
|
||||
|
||||
@zh path /zh
|
||||
rewrite @zh /zh.html
|
||||
redir @zh /insight 301
|
||||
|
||||
@pev path /pev
|
||||
rewrite @pev /pev.html
|
||||
|
||||
17
roles/insight/defaults/main.yml
Normal file
17
roles/insight/defaults/main.yml
Normal file
@ -0,0 +1,17 @@
|
||||
---
|
||||
#-----------------------------------------------------------------
|
||||
# INSIGHT - Observability Workbench
|
||||
#-----------------------------------------------------------------
|
||||
insight_enabled: true # enable insight workbench?
|
||||
workbench_port: 8080 # workbench listen port
|
||||
workbench_dir: /data/workbench # workbench deployment directory
|
||||
workbench_user: "{{ node_user | default('root') }}"
|
||||
workbench_group: "{{ node_user | default('root') }}"
|
||||
|
||||
# nodejs version and registry
|
||||
nodejs_version: 20
|
||||
nodejs_registry: https://registry.npmmirror.com
|
||||
|
||||
# build options
|
||||
workbench_clean: false # clean workbench directory before deployment?
|
||||
workbench_build: true # run npm install & build during setup?
|
||||
81
roles/insight/tasks/main.yml
Normal file
81
roles/insight/tasks/main.yml
Normal file
@ -0,0 +1,81 @@
|
||||
---
|
||||
#--------------------------------------------------------------#
|
||||
# INSIGHT - Observability Workbench Deployment
|
||||
#--------------------------------------------------------------#
|
||||
|
||||
- name: install nodejs and build tools
|
||||
tags: insight_pkg
|
||||
package:
|
||||
name:
|
||||
- nodejs
|
||||
- npm
|
||||
- gcc-c++
|
||||
- make
|
||||
state: present
|
||||
|
||||
- name: create workbench directory
|
||||
tags: insight_dir
|
||||
file:
|
||||
path: "{{ workbench_dir }}"
|
||||
state: directory
|
||||
owner: "{{ workbench_user }}"
|
||||
group: "{{ workbench_group }}"
|
||||
mode: '0755'
|
||||
|
||||
- name: sync workbench source code
|
||||
tags: insight_sync
|
||||
synchronize:
|
||||
src: "{{ playbook_dir }}/workbench/"
|
||||
dest: "{{ workbench_dir }}/"
|
||||
delete: yes
|
||||
recursive: yes
|
||||
rsync_opts:
|
||||
- "--exclude=.next"
|
||||
- "--exclude=node_modules"
|
||||
- "--exclude=.git"
|
||||
|
||||
- name: install npm dependencies
|
||||
tags: insight_build
|
||||
when: workbench_build|bool
|
||||
npm:
|
||||
path: "{{ workbench_dir }}"
|
||||
registry: "{{ nodejs_registry }}"
|
||||
environment: "{{ proxy_env | default({}) }}"
|
||||
|
||||
- name: build nextjs workbench
|
||||
tags: insight_build
|
||||
when: workbench_build|bool
|
||||
shell: npm run build
|
||||
args:
|
||||
chdir: "{{ workbench_dir }}"
|
||||
executable: /bin/bash
|
||||
environment:
|
||||
PATH: "/usr/local/bin:/usr/bin:/bin"
|
||||
NODE_ENV: production
|
||||
|
||||
- name: render insight systemd service
|
||||
tags: insight_config
|
||||
template:
|
||||
src: insight.service.j2
|
||||
dest: /etc/systemd/system/insight.service
|
||||
owner: root
|
||||
group: root
|
||||
mode: '0644'
|
||||
|
||||
- name: launch insight service
|
||||
tags: insight_launch
|
||||
systemd:
|
||||
name: insight
|
||||
state: restarted
|
||||
enabled: yes
|
||||
daemon_reload: yes
|
||||
|
||||
- name: wait for insight workbench
|
||||
tags: insight_launch
|
||||
wait_for:
|
||||
host: 127.0.0.1
|
||||
port: "{{ workbench_port }}"
|
||||
state: started
|
||||
timeout: 60
|
||||
|
||||
...
|
||||
17
roles/insight/templates/insight.service.j2
Normal file
17
roles/insight/templates/insight.service.j2
Normal file
@ -0,0 +1,17 @@
|
||||
[Unit]
|
||||
Description=Insight Workbench Service
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User={{ workbench_user }}
|
||||
Group={{ workbench_group }}
|
||||
WorkingDirectory={{ workbench_dir }}
|
||||
Environment=PORT={{ workbench_port }}
|
||||
Environment=NODE_ENV=production
|
||||
ExecStart=/usr/bin/npm start
|
||||
Restart=always
|
||||
RestartSec=10
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
@ -11,6 +11,7 @@ const nextConfig = {
|
||||
// ===============================
|
||||
output: "standalone", // 让 Next.js 生成可独立运行的最小产物(大幅减小 Docker 镜像)
|
||||
compress: true, // Gzip 压缩输出(确保小体积网络传输)
|
||||
basePath: "/insight", // 👈 所有的路由都会带有 /insight 前缀
|
||||
|
||||
// 配置允许的外部图片域名
|
||||
images: {
|
||||
|
||||
@ -1,12 +0,0 @@
|
||||
import { notFound } from 'next/navigation'
|
||||
|
||||
import InsightWorkbench from './InsightWorkbench'
|
||||
import { isFeatureEnabled } from '@lib/featureToggles'
|
||||
|
||||
export default function InsightPage() {
|
||||
if (!isFeatureEnabled('appModules', '/insight')) {
|
||||
notFound()
|
||||
}
|
||||
|
||||
return <InsightWorkbench />
|
||||
}
|
||||
@ -1,7 +0,0 @@
|
||||
"use client";
|
||||
|
||||
import InsightWorkbench from "@/components/insight/InsightWorkbench";
|
||||
|
||||
export default function InsightPage() {
|
||||
return <InsightWorkbench />;
|
||||
}
|
||||
@ -1,5 +1,7 @@
|
||||
import { redirect } from "next/navigation";
|
||||
"use client";
|
||||
|
||||
import InsightWorkbench from "@/components/insight/InsightWorkbench";
|
||||
|
||||
export default function Home() {
|
||||
redirect("/insight");
|
||||
return <InsightWorkbench />;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user