- Updated user addition tasks across multiple playbooks (mcp_switchboard, mcpo, neo4j, neo4j_mcp, openwebui, postgresql, rabbitmq, searxng, smtp4dev) to replace references to ansible_user and remote_user with keeper_user. - Modified PostgreSQL deployment to create directories and manage files under keeper_user's home. - Enhanced documentation to clarify account taxonomy and usage of keeper_user in playbooks. - Introduced new deployment for Agent S, including environment setup, desktop environment installation, XRDP configuration, and accessibility support. - Added staging playbook for preparing release tarballs from local repositories. - Created templates for XRDP configuration and environment activation scripts. - Removed obsolete sunwait documentation.
277 lines
8.0 KiB
YAML
277 lines
8.0 KiB
YAML
---
|
|
- name: Deploy AnythingLLM (Native Node.js)
|
|
hosts: ubuntu
|
|
become: true
|
|
vars:
|
|
nodejs_version: "22"
|
|
ansible_common_remote_group: "{{ anythingllm_group }}"
|
|
allow_world_readable_tmpfiles: true
|
|
tasks:
|
|
- name: Check if host has anythingllm service
|
|
ansible.builtin.set_fact:
|
|
has_anythingllm_service: "{{'anythingllm' in services}}"
|
|
|
|
- name: Skip hosts without anythingllm service
|
|
ansible.builtin.meta: end_host
|
|
when: not has_anythingllm_service
|
|
|
|
- name: Install build dependencies
|
|
ansible.builtin.apt:
|
|
name:
|
|
- curl
|
|
- tar
|
|
- build-essential
|
|
- python3
|
|
- libpq-dev
|
|
state: present
|
|
update_cache: true
|
|
|
|
- name: Add NodeSource GPG key
|
|
ansible.builtin.apt_key:
|
|
url: https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key
|
|
state: present
|
|
|
|
- name: Add NodeSource repository
|
|
ansible.builtin.apt_repository:
|
|
repo: "deb https://deb.nodesource.com/node_{{ nodejs_version }}.x nodistro main"
|
|
state: present
|
|
filename: nodesource
|
|
|
|
- name: Install Node.js
|
|
ansible.builtin.apt:
|
|
name: nodejs
|
|
state: present
|
|
update_cache: true
|
|
|
|
- name: Install Yarn globally
|
|
ansible.builtin.npm:
|
|
name: yarn
|
|
global: true
|
|
state: present
|
|
|
|
- name: Create anythingllm group
|
|
ansible.builtin.group:
|
|
name: "{{ anythingllm_group }}"
|
|
|
|
- name: Create anythingllm user
|
|
ansible.builtin.user:
|
|
name: "{{ anythingllm_user }}"
|
|
comment: "AnythingLLM service account"
|
|
group: "{{ anythingllm_group }}"
|
|
home: "{{ anythingllm_directory }}"
|
|
system: true
|
|
shell: /bin/bash
|
|
|
|
- name: Add keeper_user to anythingllm group
|
|
ansible.builtin.user:
|
|
name: "{{ keeper_user }}"
|
|
groups: "{{ anythingllm_group }}"
|
|
append: true
|
|
|
|
- name: Create anythingllm directory
|
|
ansible.builtin.file:
|
|
path: "{{ anythingllm_directory }}"
|
|
owner: "{{ anythingllm_user }}"
|
|
group: "{{ anythingllm_group }}"
|
|
state: directory
|
|
mode: '0750'
|
|
|
|
- name: Create app directory
|
|
ansible.builtin.file:
|
|
path: "{{ anythingllm_directory }}/app"
|
|
owner: "{{ anythingllm_user }}"
|
|
group: "{{ anythingllm_group }}"
|
|
state: directory
|
|
mode: '0750'
|
|
|
|
- name: Transfer and unarchive AnythingLLM release
|
|
ansible.builtin.unarchive:
|
|
src: "~/rel/anythingllm_{{ anythingllm_rel }}.tar"
|
|
dest: "{{ anythingllm_directory }}/app"
|
|
owner: "{{ anythingllm_user }}"
|
|
group: "{{ anythingllm_group }}"
|
|
mode: '0750'
|
|
register: app_unarchive
|
|
notify:
|
|
- Restart AnythingLLM Server
|
|
- Restart AnythingLLM Collector
|
|
|
|
- name: Run yarn setup
|
|
become_user: "{{ anythingllm_user }}"
|
|
ansible.builtin.command:
|
|
cmd: yarn setup
|
|
chdir: "{{ anythingllm_directory }}/app"
|
|
when: app_unarchive.changed
|
|
register: yarn_setup
|
|
|
|
- name: Create storage directory
|
|
ansible.builtin.file:
|
|
path: "{{ anythingllm_directory }}/storage"
|
|
owner: "{{ anythingllm_user }}"
|
|
group: "{{ anythingllm_group }}"
|
|
state: directory
|
|
mode: '0750'
|
|
|
|
- name: Create plugins directory
|
|
ansible.builtin.file:
|
|
path: "{{ anythingllm_directory }}/storage/plugins"
|
|
owner: "{{ anythingllm_user }}"
|
|
group: "{{ anythingllm_group }}"
|
|
state: directory
|
|
mode: '0750'
|
|
|
|
- name: Template MCP servers configuration
|
|
ansible.builtin.template:
|
|
src: anythingllm_mcp_servers.json.j2
|
|
dest: "{{ anythingllm_directory }}/storage/plugins/anythingllm_mcp_servers.json"
|
|
owner: "{{ anythingllm_user }}"
|
|
group: "{{ anythingllm_group }}"
|
|
mode: '0600'
|
|
notify:
|
|
- Restart AnythingLLM Server
|
|
- Restart AnythingLLM Collector
|
|
|
|
- name: Create hotdir directory
|
|
ansible.builtin.file:
|
|
path: "{{ anythingllm_directory }}/hotdir"
|
|
owner: "{{ anythingllm_user }}"
|
|
group: "{{ anythingllm_group }}"
|
|
state: directory
|
|
mode: '0750'
|
|
|
|
- name: Create collector symlink directory
|
|
ansible.builtin.file:
|
|
path: /srv/collector
|
|
owner: "{{ anythingllm_user }}"
|
|
group: "{{ anythingllm_group }}"
|
|
state: directory
|
|
mode: '0755'
|
|
|
|
- name: Create hotdir symlink for AnythingLLM path resolution
|
|
ansible.builtin.file:
|
|
src: "{{ anythingllm_directory }}/hotdir"
|
|
dest: /srv/collector/hotdir
|
|
owner: "{{ anythingllm_user }}"
|
|
group: "{{ anythingllm_group }}"
|
|
state: link
|
|
|
|
- name: Remove collector's default hotdir directory
|
|
ansible.builtin.file:
|
|
path: "{{ anythingllm_directory }}/app/collector/hotdir"
|
|
state: absent
|
|
|
|
- name: Create hotdir symlink for collector
|
|
ansible.builtin.file:
|
|
src: "{{ anythingllm_directory }}/hotdir"
|
|
dest: "{{ anythingllm_directory }}/app/collector/hotdir"
|
|
owner: "{{ anythingllm_user }}"
|
|
group: "{{ anythingllm_group }}"
|
|
state: link
|
|
|
|
- name: Template server environment file
|
|
ansible.builtin.template:
|
|
src: env.j2
|
|
dest: "{{ anythingllm_directory }}/app/server/.env"
|
|
owner: "{{ anythingllm_user }}"
|
|
group: "{{ anythingllm_group }}"
|
|
mode: '0600'
|
|
notify:
|
|
- Restart AnythingLLM Server
|
|
- Restart AnythingLLM Collector
|
|
|
|
- name: Configure frontend API base
|
|
ansible.builtin.lineinfile:
|
|
path: "{{ anythingllm_directory }}/app/frontend/.env"
|
|
regexp: "^VITE_API_BASE="
|
|
line: "VITE_API_BASE='/api'"
|
|
create: true
|
|
owner: "{{ anythingllm_user }}"
|
|
group: "{{ anythingllm_group }}"
|
|
mode: '0644'
|
|
register: frontend_env
|
|
|
|
- name: Build frontend
|
|
become_user: "{{ anythingllm_user }}"
|
|
ansible.builtin.command:
|
|
cmd: yarn build
|
|
chdir: "{{ anythingllm_directory }}/app/frontend"
|
|
when: app_unarchive.changed or frontend_env.changed
|
|
register: frontend_build
|
|
|
|
- name: Remove old server/public directory
|
|
ansible.builtin.file:
|
|
path: "{{ anythingllm_directory }}/app/server/public"
|
|
state: absent
|
|
when: frontend_build.changed
|
|
|
|
- name: Copy frontend build to server/public
|
|
become_user: "{{ anythingllm_user }}"
|
|
ansible.builtin.copy:
|
|
src: "{{ anythingllm_directory }}/app/frontend/dist/"
|
|
dest: "{{ anythingllm_directory }}/app/server/public/"
|
|
remote_src: true
|
|
owner: "{{ anythingllm_user }}"
|
|
group: "{{ anythingllm_group }}"
|
|
when: frontend_build.changed
|
|
|
|
- name: Generate Prisma client
|
|
become_user: "{{ anythingllm_user }}"
|
|
ansible.builtin.command:
|
|
cmd: npx prisma generate --schema=./prisma/schema.prisma
|
|
chdir: "{{ anythingllm_directory }}/app/server"
|
|
when: app_unarchive.changed or yarn_setup.changed
|
|
|
|
- name: Run Prisma migrations
|
|
become_user: "{{ anythingllm_user }}"
|
|
ansible.builtin.command:
|
|
cmd: npx prisma migrate deploy --schema=./prisma/schema.prisma
|
|
chdir: "{{ anythingllm_directory }}/app/server"
|
|
when: app_unarchive.changed or yarn_setup.changed
|
|
|
|
- name: Create AnythingLLM server systemd service
|
|
ansible.builtin.template:
|
|
src: anythingllm-server.service.j2
|
|
dest: /etc/systemd/system/anythingllm-server.service
|
|
mode: '0644'
|
|
notify:
|
|
- Reload systemd
|
|
- Restart AnythingLLM Server
|
|
|
|
- name: Create AnythingLLM collector systemd service
|
|
ansible.builtin.template:
|
|
src: anythingllm-collector.service.j2
|
|
dest: /etc/systemd/system/anythingllm-collector.service
|
|
mode: '0644'
|
|
notify:
|
|
- Reload systemd
|
|
- Restart AnythingLLM Collector
|
|
|
|
- name: Enable and start AnythingLLM server
|
|
ansible.builtin.systemd:
|
|
name: anythingllm-server
|
|
enabled: true
|
|
state: started
|
|
daemon_reload: true
|
|
|
|
- name: Enable and start AnythingLLM collector
|
|
ansible.builtin.systemd:
|
|
name: anythingllm-collector
|
|
enabled: true
|
|
state: started
|
|
daemon_reload: true
|
|
|
|
handlers:
|
|
- name: Reload systemd
|
|
ansible.builtin.systemd:
|
|
daemon_reload: true
|
|
|
|
- name: Restart AnythingLLM Server
|
|
ansible.builtin.systemd:
|
|
name: anythingllm-server
|
|
state: restarted
|
|
|
|
- name: Restart AnythingLLM Collector
|
|
ansible.builtin.systemd:
|
|
name: anythingllm-collector
|
|
state: restarted
|