Skip to content

Automated OpenClaw Deployment with Ansible

I hate manual server setup. Every time I think a deployment will take five minutes, I end up debugging firewall rules or missing dependencies for two hours. It is tedious work that distracts from building things. I prefer automating these tasks so the environment is consistent and secure every time.

For production servers, I recommend using the openclaw-ansible installer. It handles the security-first architecture for you and saves a lot of time.

Before you start, make sure your environment meets these requirements:

  • OS: Debian 11+ or Ubuntu 20.04+
  • Access: Root or sudo privileges
  • Network: Internet connection for package installation
  • Ansible: 2.14+ (The quick-start script installs this automatically)

You can get everything running with one command. This script pulls the installer and begins the process immediately.

Terminal window
curl -fsSL https://raw.githubusercontent.com/openclaw/openclaw-ansible/main/install.sh | bash

Once the installation finishes, you need to switch to the openclaw user to complete the setup:

Terminal window
sudo -i -u openclaw

The post-install script guides you through four main steps. You will go through the onboarding wizard to configure settings and log into your providers like WhatsApp, Telegram, Discord, or Signal. You will also test the gateway and finish the Tailscale setup to connect to your VPN mesh.

I use these commands often to check on the service or manage the providers:

Terminal window
# Check service status
sudo systemctl status openclaw
# View live logs
sudo journalctl -u openclaw -f
# Restart gateway
sudo systemctl restart openclaw
# Provider login (run as openclaw user)
sudo -i -u openclaw
openclaw channels login

The playbook handles the heavy lifting. It installs Tailscale for secure mesh VPN access and configures the UFW firewall to allow only SSH and Tailscale ports. It also sets up Docker CE and Compose V2 for agent sandboxes.

The runtime environment includes Node.js 22.x and pnpm. The OpenClaw gateway runs directly on your host as a systemd service with security hardening. While the gateway is host-based, the agent sandboxes use Docker to keep tool execution isolated.

I like this setup because it uses a 4-layer defense strategy. The UFW firewall blocks everything except SSH (22) and Tailscale (41641/udp). The Tailscale VPN ensures the gateway is only accessible via your private mesh.

Docker isolation prevents external port exposure via the DOCKER-USER iptables chain. Finally, systemd hardening uses features like NoNewPrivileges and PrivateTmp to protect the host. You can verify this by running an external scan:

Terminal window
nmap -p- YOUR_SERVER_IP

This should show only port 22 as open. All other services stay locked down.

If you want more control over the process, you can run the steps manually:

Terminal window
# 1. Install prerequisites
sudo apt update && sudo apt install -y ansible git
# 2. Clone repository
git clone https://github.com/openclaw/openclaw-ansible.git
cd openclaw-ansible
# 3. Install Ansible collections
ansible-galaxy collection install -r requirements.yml
# 4. Run playbook
./run-playbook.sh

If you find yourself locked out, check your Tailscale VPN connection. Remember that the gateway is only accessible via Tailscale by design. SSH access on port 22 should always remain open.

You can check the logs to see what is happening:

Terminal window
sudo journalctl -u openclaw -n 100

Verify permissions on /opt/openclaw or try a manual start as the openclaw user to see specific errors.

Make sure the Docker service is running with sudo systemctl status docker. If the sandbox image is missing, you can build it manually:

Terminal window
cd /opt/openclaw/openclaw
sudo -u openclaw ./scripts/sandbox-setup.sh

This usually happens if you are not the right user. Always make sure you have switched to the openclaw user before running login commands:

Terminal window
sudo -i -u openclaw
openclaw channels login

If you run into other issues, you can ask the AI Setup Assistant for help.

OpenClaw

OpenClaw Expert

Still stuck?

If this page didn't answer your case, ask OpenClaw Expert for step-by-step guidance.