feat(gateway_openclaw): add Windows tasks implementation

This commit is contained in:
Haitao Pan 2026-06-21 19:53:26 +08:00
parent 5f7bc697fc
commit aedf457ddc
2 changed files with 72 additions and 0 deletions

View File

@ -88,6 +88,7 @@
'changed ' in (gateway_openclaw_package_install.stdout | default(''))
when:
- not ansible_check_mode
- ansible_os_family != 'Windows'
notify: Restart openclaw
- name: Ensure OpenClaw extensions directory exists
@ -147,6 +148,7 @@
label: "{{ item.package_spec | default(item.name ~ '@' ~ item.version) }}"
when:
- not ansible_check_mode
- ansible_os_family != 'Windows'
notify: Restart openclaw
- name: Remove unsupported OpenClaw global plugin packages
@ -185,6 +187,7 @@
delay: 3
when:
- not ansible_check_mode
- ansible_os_family != 'Windows'
- >-
(gateway_openclaw_package_install.changed | default(false))
or
@ -201,6 +204,7 @@
mode: "0755"
when:
- not ansible_check_mode
- ansible_os_family != 'Windows'
- >-
(gateway_openclaw_package_install.changed | default(false))
or
@ -221,6 +225,7 @@
changed_when: false
when:
- not ansible_check_mode
- ansible_os_family != 'Windows'
- name: Move stale OpenClaw plugin backups out of extension scan path
ansible.builtin.shell: |
@ -245,6 +250,7 @@
changed_when: "'moved=1' in (gateway_openclaw_stale_extension_backups.stdout | default(''))"
when:
- not ansible_check_mode
- ansible_os_family != 'Windows'
- name: Inspect OpenClaw gateway JSON config attributes
ansible.builtin.command:
@ -305,6 +311,7 @@
when:
- gateway_openclaw_package_manifest.stat.exists | default(false)
- not ansible_check_mode
- ansible_os_family != 'Windows'
- name: Inspect OpenClaw extension package manifests
ansible.builtin.stat:
@ -331,6 +338,7 @@
when:
- item.stat.exists | default(false)
- not ansible_check_mode
- ansible_os_family != 'Windows'
- name: Restore immutable flag on OpenClaw gateway JSON config
ansible.builtin.command:
@ -368,6 +376,7 @@
changed_when: false
when:
- not ansible_check_mode
- ansible_os_family != 'Windows'
- name: Assert OpenClaw gateway version is pinned
ansible.builtin.assert:
@ -378,6 +387,7 @@
package upgrade. Actual version output: {{ gateway_openclaw_version.stdout | default('') }}
when:
- not ansible_check_mode
- ansible_os_family != 'Windows'
- name: Check OpenClaw plugin registry
ansible.builtin.command:
@ -393,6 +403,7 @@
changed_when: false
when:
- not ansible_check_mode
- ansible_os_family != 'Windows'
- name: Assert OpenClaw Codex plugin matches gateway version
ansible.builtin.assert:
@ -426,6 +437,7 @@
and must not keep stale global @openclaw/acpx.
when:
- not ansible_check_mode
- ansible_os_family != 'Windows'
- name: Ensure OpenClaw user systemd unit directory exists
ansible.builtin.file:
@ -461,6 +473,7 @@
creates: "/var/lib/systemd/linger/{{ gateway_openclaw_service_user }}"
when:
- not ansible_check_mode
- ansible_os_family != 'Windows'
- ansible_os_family != 'Darwin'
- name: Resolve OpenClaw service user uid
@ -487,6 +500,7 @@
state: started
when:
- not ansible_check_mode
- ansible_os_family != 'Windows'
- ansible_os_family != 'Darwin'
- name: Stop and disable stale root-managed OpenClaw gateway service
@ -497,6 +511,7 @@
failed_when: false
when:
- not ansible_check_mode
- ansible_os_family != 'Windows'
- ansible_os_family != 'Darwin'
- name: Inspect stale OpenClaw gateway root systemd unit attributes
@ -546,6 +561,7 @@
changed_when: false
when:
- not ansible_check_mode
- ansible_os_family != 'Windows'
- ansible_os_family != 'Darwin'
- name: Ensure OpenClaw user gateway service is enabled and running
@ -567,6 +583,7 @@
'Created symlink' in (gateway_openclaw_user_service_enable.stderr | default(''))
when:
- not ansible_check_mode
- ansible_os_family != 'Windows'
- ansible_os_family != 'Darwin'
- name: Restart OpenClaw user gateway service after unit changes
@ -591,6 +608,10 @@
ansible.builtin.import_tasks: macos.yml
when: ansible_os_family == 'Darwin'
- name: Include Windows specific service tasks
ansible.builtin.include_tasks: windows.yml
when: ansible_os_family == 'Windows'
# Caddy ingress for OpenClaw. Skipped entirely when caddy_enabled is false
# (default on macOS single-host deploys), so /etc/caddy is never touched and no
# caddy service is started/notified. Override with -e caddy_enabled=true.

View File

@ -0,0 +1,51 @@
---
- name: Install required OpenClaw gateway package version on Windows
community.windows.win_command:
cmd: >-
npm install --global --omit=dev --no-audit --no-fund
--prefix "{{ gateway_openclaw_home }}\.local"
"{{ gateway_openclaw_npm_package_spec }}"
environment:
OPENCLAW_NO_RESPAWN: "1"
NODE_COMPILE_CACHE: "{{ gateway_openclaw_compile_cache_dir }}"
register: gateway_openclaw_package_install_win
changed_when: >-
'added ' in (gateway_openclaw_package_install_win.stdout | default('')) or
'updated ' in (gateway_openclaw_package_install_win.stdout | default(''))
when: not ansible_check_mode
notify: Restart openclaw
- name: Ensure OpenClaw extensions directory exists on Windows
ansible.windows.win_file:
path: "{{ gateway_openclaw_home }}\.openclaw\extensions"
state: directory
- name: Extract OpenClaw Multi-Session Plugins on Windows
community.windows.win_unzip:
src: "{{ gateway_openclaw_multi_session_plugin_archive_url }}"
dest: "{{ gateway_openclaw_home }}\.openclaw\extensions"
creates: "{{ gateway_openclaw_home }}\.openclaw\extensions\openclaw-multi-session-plugins"
when: not ansible_check_mode
notify: Restart openclaw
- name: Deploy OpenClaw gateway JSON config on Windows
ansible.windows.win_template:
src: openclaw.json.j2
dest: "{{ gateway_openclaw_config_path }}"
notify: Restart openclaw
- name: Register OpenClaw gateway as a Windows Service (schtasks)
community.windows.win_command:
cmd: "{{ gateway_openclaw_home }}\.local\node_modules\openclaw\bin\openclaw.cmd gateway install"
environment:
OPENCLAW_NO_RESPAWN: "1"
register: gateway_openclaw_service_install_win
changed_when: "'created' in (gateway_openclaw_service_install_win.stdout | default(''))"
when: not ansible_check_mode
- name: Ensure OpenClaw Windows gateway service is enabled and running
community.windows.win_command:
cmd: "{{ gateway_openclaw_home }}\.local\node_modules\openclaw\bin\openclaw.cmd gateway status"
register: gateway_openclaw_service_status_win
changed_when: false
when: not ansible_check_mode