Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 25 additions & 3 deletions roles/openclaw/tasks/openclaw-development.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,36 @@
msg: "Build failed - dist directory not found"
when: not dist_dir.stat.exists

- name: Resolve openclaw CLI entrypoint path
ansible.builtin.shell:
cmd: |
set -euo pipefail
for rel in openclaw.mjs bin/openclaw.js dist/index.js; do
if [ -f "{{ openclaw_repo_dir }}/$rel" ]; then
printf '%s\n' "{{ openclaw_repo_dir }}/$rel"
exit 0
fi
done
exit 1

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Handle missing entrypoints without shell task failure

When none of the candidate files exist, this probe exits with code 1 and ansible.builtin.shell fails the play immediately, so the following Fail if openclaw CLI entrypoint is missing task (with the clearer error message) never runs. This makes the new error-handling path unreachable in exactly the failure scenario it is meant to cover (for example, if upstream layout changes again or build artifacts are missing), so the probe should be made non-fatal (e.g., failed_when: false) and let the explicit fail task report the issue.

Useful? React with 👍 / 👎.

executable: /bin/bash
register: openclaw_cli_entry
changed_when: false

- name: Fail if openclaw CLI entrypoint is missing
ansible.builtin.fail:
msg: >-
Unable to locate OpenClaw CLI entrypoint in {{ openclaw_repo_dir }}.
Expected one of: openclaw.mjs, bin/openclaw.js, dist/index.js
when: (openclaw_cli_entry.stdout | trim) == ""

- name: Remove existing global openclaw symlink (if any)
ansible.builtin.file:
path: "{{ openclaw_home }}/.local/bin/openclaw"
state: absent

- name: Create symlink to openclaw binary
ansible.builtin.file:
src: "{{ openclaw_repo_dir }}/bin/openclaw.js"
src: "{{ openclaw_cli_entry.stdout | trim }}"
dest: "{{ openclaw_home }}/.local/bin/openclaw"
state: link
owner: "{{ openclaw_user }}"
Expand All @@ -99,7 +121,7 @@

- name: Make openclaw binary executable
ansible.builtin.file:
path: "{{ openclaw_repo_dir }}/bin/openclaw.js"
path: "{{ openclaw_cli_entry.stdout | trim }}"
mode: '0755'
owner: "{{ openclaw_user }}"
group: "{{ openclaw_user }}"
Expand All @@ -122,7 +144,7 @@
msg: |
OpenClaw installed from source: {{ openclaw_dev_version.stdout }}
Repository: {{ openclaw_repo_dir }}
Binary: {{ openclaw_home }}/.local/bin/openclaw -> {{ openclaw_repo_dir }}/bin/openclaw.js
Binary: {{ openclaw_home }}/.local/bin/openclaw -> {{ openclaw_cli_entry.stdout | trim }}

- name: Add development mode info to .bashrc
ansible.builtin.blockinfile:
Expand Down