From 8ebb6b96d5819956c6811f8d961c434ccc42a2d6 Mon Sep 17 00:00:00 2001 From: Anthony Perkins Date: Tue, 17 Jan 2023 13:58:26 +0000 Subject: [PATCH] Make playbook work on WSL again --- main.yml | 18 +++++++++++++++--- roles/debian/tasks/main.yml | 3 +++ roles/debian/tasks/ssh.yml | 3 ++- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/main.yml b/main.yml index ba8edec..e5fdab9 100755 --- a/main.yml +++ b/main.yml @@ -14,9 +14,21 @@ # See the License for the specific language governing permissions and # limitations under the License. -- name: Check for /run/ostree-booted - stat: path=/run/ostree-booted - register: ostree +- name: Check if an ostree OS (e.g. Silverblue) + ansible.builtin.stat: + path: /run/ostree-booted + register: check_ostree +- name: Check for WSL + ansible.builtin.command: + cmd: 'grep microsoft /proc/version' + changed_when: false + ignore_errors: true + register: check_wsl + +- name: Register useful variables + ansible.builtin.set_fact: + ostree: check_ostree.exists + wsl: not check_wsl.failed - include_role: name: arch diff --git a/roles/debian/tasks/main.yml b/roles/debian/tasks/main.yml index e59ba75..09207e7 100644 --- a/roles/debian/tasks/main.yml +++ b/roles/debian/tasks/main.yml @@ -20,10 +20,13 @@ - import_tasks: modules.yml - import_tasks: ssh.yml - import_tasks: solokeys.yml + when: wsl == false - import_tasks: sudo.yml when: gui == true - import_tasks: packagekit.yml when: gui == true - import_tasks: timezone.yml + when: wsl == false - import_tasks: systemd.yml + when: wsl == false - import_tasks: gdm.yml diff --git a/roles/debian/tasks/ssh.yml b/roles/debian/tasks/ssh.yml index bd668c2..6c31d94 100644 --- a/roles/debian/tasks/ssh.yml +++ b/roles/debian/tasks/ssh.yml @@ -26,9 +26,10 @@ name: ssh.service enabled: yes state: started + when: wsl == false - name: Restart SSH become: true ansible.builtin.systemd: name: ssh.service state: restarted - when: changed_ssh_config.changed == true + when: changed_ssh_config.changed == true and wsl == false