Deployment Overview of OpenClaw on Server¶
Prerequisites and Basic Requirements¶
The deployment of OpenClaw requires a Linux environment with specific package dependencies and user privileges. The system must meet the following criteria:
-
Operating System: Ubuntu (verified via
aptpackage manager). -
Privileges: Root access or
sudoprivileges are required to install system packages and manage services. -
Required Packages:
-
ansible -
git -
User Account: A dedicated system user named
openclawis created with a password and membership in thesudogroup. -
Package Management: The installer temporarily disables
unattended-upgradesto prevent conflicts during the installation process and re-enables it upon completion.
File and Directory Structure¶
The application and its supporting files are organized within specific directories on the host system:
-
Installation Directory:
/opt/openclaw-ansible -
Contains the cloned repository from
https://github.com/openclaw/openclaw-ansible.git. -
Includes the execution script
run-playbook.sh. -
User Home Directory:
/home/openclaw -
Serves as the primary working directory for the
openclawuser. -
Contains user-specific configurations and environment variables.
-
Environment Configuration:
-
/home/openclaw/.profile: Configures thePNPM_HOMEenvironment variable and updates thePATH. -
/etc/environment: Updates the system-widePATHto include OpenClaw binaries. -
/etc/sudoers.d/openclaw-path: Configuressecure_pathandenv_keepfor theopenclawuser to ensurepnpmbinaries are accessible duringsudooperations.
Application Installation Process¶
The OpenClaw application is installed via a script that clones the repository and executes the deployment logic. The process involves the following steps:
-
Repository Cloning: The system clones or updates the OpenClaw repository from the
mainbranch into/opt/openclaw-ansible. -
Dependency Installation: Ansible collections are installed using
ansible-galaxy collection install -r requirements.yml. -
Execution: The installation is triggered by running the script
./run-playbook.shwith elevated privileges. -
Command:
./run-playbook.sh -e ansible_become=true -
Working Directory:
/opt/openclaw-ansible -
Environment Variables: The installer runs with specific environment constraints to manage memory and concurrency:
-
NODE_OPTIONS:--max-old-space-size=768 -
npm_config_jobs:2 -
npm_config_loglevel:warn -
CI:true -
PNPM_HOME:/home/openclaw/.local/share/pnpm -
Retry Logic: The installation script includes a retry mechanism (up to 3 attempts with a 30-second delay) to ensure successful completion.
Access Rights and Security¶
Security configurations are applied to the openclaw user and the system environment:
-
User Creation: The
openclawuser is created with/bin/bashas the default shell. -
Group Membership: The user is added to the
sudogroup to allow administrative tasks. -
Password: A password is set for the
openclawuser using SHA512 hashing. -
Sudo Configuration:
-
The
secure_pathis extended to include/home/openclaw/.local/share/pnpm/binand/home/openclaw/.local/bin. -
Environment variables
PNPM_HOMEandPATHare preserved duringsudoexecution. -
Package Manager Locking: The installer includes logic to wait for
apt,apt-get,dpkg, andunattended-upgradeprocesses to finish or terminate before proceeding, preventing file lock conflicts.
Permission Settings¶
File and directory permissions are strictly defined to ensure the application runs correctly:
-
Home Directory:
/home/openclawis owned byopenclaw:openclawwith mode0755. -
Recursive Ownership: All files within
/home/openclaware recursively owned by theopenclawuser and group. -
Profile File:
/home/openclaw/.profileis set to mode0644and owned byopenclaw:openclaw. -
Sudoers File:
/etc/sudoers.d/openclaw-pathis set to mode0440and owned byroot:root. -
Environment File:
/etc/environmentis set to mode0644and owned byroot:root. -
Execution Script: The
run-playbook.shscript is granted execute permissions for the user (chmod u+x).
Starting, Stopping, and Updating¶
The deployment utilizes a specific script to manage the installation and update lifecycle.
-
Update/Run Command: To execute the deployment or update the application, run the following command from the installation directory:
-
Environment Context: The script relies on the
openclawuser environment. Ensure that thePATHincludes thepnpmbinaries located in/home/openclaw/.local/share/pnpm/bin. -
Post-Installation: After the installation completes, the
unattended-upgradesservice is re-enabled to maintain system security updates.