From 483326c2316405ed01a8175a02a365a669a07e21 Mon Sep 17 00:00:00 2001 From: Anthony Perkins Date: Tue, 17 Jan 2023 21:56:36 +0000 Subject: [PATCH] Fix WSL checks on non-WSL distro --- main.yml | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/main.yml b/main.yml index e5fdab9..28293e0 100755 --- a/main.yml +++ b/main.yml @@ -19,16 +19,27 @@ path: /run/ostree-booted register: check_ostree - name: Check for WSL - ansible.builtin.command: - cmd: 'grep microsoft /proc/version' + ansible.builtin.shell: 'grep microsoft /proc/version || /bin/true' changed_when: false - ignore_errors: true register: check_wsl -- name: Register useful variables +- name: Register ostree fact ansible.builtin.set_fact: ostree: check_ostree.exists - wsl: not check_wsl.failed +- name: Default wsl fact + ansible.builtin.set_fact: + wsl: false +- name: Register wsl fact + ansible.builtin.set_fact: + wsl: true + when: '"microsoft" in check_wsl.stdout' + +- name: Debug WSL - check_wsl + ansible.builtin.debug: + var: check_wsl +- name: Debug WSL - wsl + ansible.builtin.debug: + var: wsl - include_role: name: arch