This guide deploys Moltis on Debian 10 to latest stable, Ubuntu LTS, and RHEL 9+ compatible hosts using Docker. Moltis is distributed as a single binary but Docker deployment is recommended for sandboxed agent execution.
- name: Deploy Moltis AI Gateway
hosts: moltis
become: true
vars:
moltis_version: latest
moltis_port: 13131
moltis_data_dir: /var/lib/moltis
moltis_config_dir: /etc/moltis
moltis_password: "" # Set for remote access
moltis_ssl_enabled: false
tasks:
- name: Install Docker on Debian/Ubuntu
apt:
name:
- docker.io
- docker-compose
state: present
update_cache: true
when: ansible_os_family == "Debian"
- name: Install Docker on RHEL family
dnf:
name:
- docker
- docker-compose
state: present
when: ansible_os_family == "RedHat"
- name: Enable and start Docker
service:
name: docker
state: started
enabled: true
- name: Create Moltis data directory
file:
path: "{{ moltis_data_dir }}"
state: directory
mode: "0750"
owner: root
group: docker
- name: Create Moltis config directory
file:
path: "{{ moltis_config_dir }}"
state: directory
mode: "0750"
owner: root
group: docker
- name: Write Moltis configuration (moltis.toml)
copy:
dest: "{{ moltis_config_dir }}/moltis.toml"
mode: "0640"
content: |
# Moltis Configuration
# Generated by Ansible
[server]
bind = "0.0.0.0:{{ moltis_port }}"
[paths]
data = "{{ moltis_data_dir }}"
config = "{{ moltis_config_dir }}"
[sandbox]
runtime = "docker"
[memory]
enabled = true
[security]
require_auth_remote = true
rate_limit = 60
ssrf_protection = true
- name: Write Docker Compose file
copy:
dest: "{{ moltis_data_dir }}/docker-compose.yml"
mode: "0644"
content: |
version: "3.8"
services:
moltis:
image: ghcr.io/moltis-org/moltis:{{ moltis_version }}
container_name: moltis
restart: unless-stopped
ports:
- "{{ moltis_port }}:13131"
- "1455:1455"
volumes:
- {{ moltis_config_dir }}:/home/moltis/.config/moltis:ro
- {{ moltis_data_dir }}/data:/home/moltis/.moltis
- /var/run/docker.sock:/var/run/docker.sock
environment:
{% if moltis_password %}
- MOLTIS_PASSWORD={{ moltis_password }}
{% endif %}
deploy:
resources:
limits:
memory: 1G
reservations:
memory: 256M
volumes:
moltis-data:
name: moltis-data
- name: Deploy Moltis with Docker Compose
community.docker.docker_compose:
project_src: "{{ moltis_data_dir }}"
files:
- docker-compose.yml
state: present
recreate: never
- name: Enable Docker Compose service
systemd:
name: docker
state: started
enabled: true
- name: Wait for Moltis to be ready
wait_for:
port: "{{ moltis_port }}"
delay: 5
timeout: 60
ansible-playbook -i inventory.ini moltis.yml
After deployment, access the Web UI at:
http://your-server:13131
On localhost, no authentication is required. For remote access, set moltis_password in the playbook vars.
vars:
moltis_ssl_enabled: true
moltis_domain: moltis.example.com
Add tasks for certificate provisioning:
- name: Install Certbot
apt:
name: certbot
state: present
when: ansible_os_family == "Debian"
- name: Obtain SSL certificate
command: >
certbot certonly --standalone
-d {{ moltis_domain }}
--non-interactive
--agree-tos
--email admin@{{ moltis_domain }}
args:
creates: /etc/letsencrypt/live/{{ moltis_domain }}/fullchain.pem
Update the Moltis configuration:
[server]
bind = "0.0.0.0:13131"
[server.https]
cert = "/etc/letsencrypt/live/{{ moltis_domain }}/fullchain.pem"
key = "/etc/letsencrypt/live/{{ moltis_domain }}/privkey.pem"
Add provider configuration to moltis.toml:
- name: Write LLM provider configuration
blockinfile:
path: "{{ moltis_config_dir }}/moltis.toml"
marker: "# {mark} ANSIBLE MANAGED LLM PROVIDERS"
block: |
[providers.openai]
api_key = "{{ openai_api_key }}"
[providers.anthropic]
api_key = "{{ anthropic_api_key }}"
[providers.ollama]
endpoint = "http://localhost:11434"
- name: Write MCP server configuration
blockinfile:
path: "{{ moltis_config_dir }}/moltis.toml"
marker: "# {mark} ANSIBLE MANAGED MCP SERVERS"
block: |
[[mcp.servers]]
name = "filesystem"
command = "npx"
args = ["-y", "@modelcontextprotocol/server-filesystem", "{{ moltis_data_dir }}"]
moltis.toml), not environment variablesghcr.io/moltis-org/moltis:latest/home/moltis/.config/moltis (config), /home/moltis/.moltis (data)docker ps | grep moltis
docker logs moltis
docker exec moltis cat /home/moltis/.config/moltis/moltis.toml
docker restart moltis
Any questions?
Feel free to contact us. Find all contact information on our contact page.