From 671443de67d42b97db9a1288c97fb0de540fa0ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zden=C4=9Bk=20Vydra?= <80331839+vydrazde@users.noreply.github.com> Date: Thu, 16 Jan 2025 14:48:09 +0100 Subject: [PATCH 1/2] Fix windows commands --- tasks/install_runner_win.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tasks/install_runner_win.yml b/tasks/install_runner_win.yml index 1ceca98..d94472e 100644 --- a/tasks/install_runner_win.yml +++ b/tasks/install_runner_win.yml @@ -15,7 +15,7 @@ when: runner_version == "latest" - name: Check if desired version already installed - ansible.windows.win_command: "grep -i {{ runner_version }} {{ runner_dir }}\\bin\\Runner.Listener.deps.json" + ansible.windows.win_command: "findstr -i {{ runner_version }} {{ runner_dir }}\\bin\\Runner.Listener.deps.json" register: runner_installed check_mode: false changed_when: false @@ -116,27 +116,27 @@ reinstall_runner - name: Read service name from file - ansible.windows.win_command: "cat {{ runner_dir }}\\.service" + ansible.windows.win_shell: "type {{ runner_dir }}\\.service" register: runner_service changed_when: false - name: START and enable Github Actions Runner service ansible.windows.win_service: - name: "{{ runner_service.stdout }}" + name: "{{ runner_service.stdout | trim }}" start_mode: auto state: started when: runner_state|lower == "started" - name: STOP and disable Github Actions Runner service ansible.windows.win_service: - name: "{{ runner_service.stdout }}" + name: "{{ runner_service.stdout | trim }}" start_mode: manual state: stopped when: runner_state|lower == "stopped" - name: Version changed - RESTART Github Actions Runner service ansible.windows.win_service: - name: "{{ runner_service.stdout }}" + name: "{{ runner_service.stdout | trim }}" start_mode: auto state: restarted when: runner_version not in runner_installed.stdout and not runner_state|lower == "stopped" From 617210a65bfc0fb5522e4ec1b3f6f266636b7b43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zden=C4=9Bk=20Vydra?= <80331839+vydrazde@users.noreply.github.com> Date: Thu, 16 Jan 2025 14:48:09 +0100 Subject: [PATCH 2/2] Fix windows conditions for when determining installed version fails --- tasks/install_runner_win.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tasks/install_runner_win.yml b/tasks/install_runner_win.yml index d94472e..2da19fe 100644 --- a/tasks/install_runner_win.yml +++ b/tasks/install_runner_win.yml @@ -26,14 +26,14 @@ url: "https://github.com/{{ runner_download_repository }}/releases/download/v{{ runner_version }}/\ actions-runner-{{ github_actions_system }}-{{ github_actions_architecture }}-{{ runner_version }}.zip" dest: "%TEMP%\\actions-runner-{{ github_actions_system }}-{{ github_actions_architecture }}-{{ runner_version }}.zip" - when: runner_version not in runner_installed.stdout or reinstall_runner + when: runner_installed.stdout is not defined or runner_version not in runner_installed.stdout or reinstall_runner - name: Unarchive runner package community.windows.win_unzip: src: "%TEMP%\\actions-runner-{{ github_actions_system }}-{{ github_actions_architecture }}-{{ runner_version }}.zip" dest: "{{ runner_dir }}\\" delete_archive: yes - when: runner_version not in runner_installed.stdout or reinstall_runner + when: runner_installed.stdout is not defined or runner_version not in runner_installed.stdout or reinstall_runner - name: Configure custom env file if required randrej.windows.win_blockinfile: