---
- name: Create RAG directories on RAID5
  ansible.builtin.file:
    path: "{{ item }}"
    state: directory
    mode: '0755'
  loop:
    - "{{ rag_data_dir }}"
    - "{{ rag_docs_dir }}"

- name: Deploy rag-ingest script
  ansible.builtin.copy:
    src: rag-ingest
    dest: /usr/local/bin/rag-ingest
    mode: '0755'
  notify: Run rag-ingest

- name: Deploy rag-query script
  ansible.builtin.copy:
    src: rag-query
    dest: /usr/local/bin/rag-query
    mode: '0755'

- name: Sync admin docs to RAG docs dir
  ansible.builtin.copy:
    src: "{{ inventory_dir }}/../admin/"
    dest: "{{ rag_docs_dir }}/"
    mode: '0644'
  notify: Run rag-ingest

- name: Deploy RAG skill to Hermes global skills
  ansible.builtin.copy:
    src: rag-docs/
    dest: /srv/data/hermes/skills/funk/rag-docs/
    owner: hermes
    group: hermes
    mode: '0644'

- name: Deploy RAG skill to funk-ai profile
  ansible.builtin.copy:
    src: rag-docs/
    dest: /srv/data/hermes/profiles/funk-ai/skills/funk/rag-docs/
    owner: hermes
    group: hermes
    mode: '0644'
  notify: Restart hermes-agent
