From 5c0bf2c71231ba48c73306ad30bd27ce894fec33 Mon Sep 17 00:00:00 2001
From: Oliver Davies <oliver@oliverdavies.uk>
Date: Thu, 31 Mar 2022 00:17:36 +0100
Subject: [PATCH] chore: automatically skip tags if in WSL

---
 bin/dotfiles | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/bin/dotfiles b/bin/dotfiles
index 911ee5a6..c5d30c8d 100755
--- a/bin/dotfiles
+++ b/bin/dotfiles
@@ -4,6 +4,8 @@ set -e
 
 CONFIG_DIR="$HOME/.config/dotfiles"
 DOTFILES_DIR="$HOME/.dotfiles"
+# TODO: Determine this automatically based on username or somehow.
+IS_WSL=${IS_WSL:=false}
 
 clone_or_update_dotfiles() {
   git -C $DOTFILES_DIR pull
@@ -18,8 +20,11 @@ install_dependencies() {
 }
 
 run_playbook() {
-  # TODO: automatically skip roles if the playbook is run within WSL.
-  ansible-playbook --diff --extra-vars "@${CONFIG_DIR}/values.yaml" --ask-become-pass "${DOTFILES_DIR}/main.yaml" "${@}"
+  if [[ $IS_WSL ]]; then
+    ansible-playbook --diff --extra-vars "@${CONFIG_DIR}/values.yaml" --ask-become-pass "${DOTFILES_DIR}/main.yaml" --skip-tags skip-if-wsl "${@}"
+  else
+    ansible-playbook --diff --extra-vars "@${CONFIG_DIR}/values.yaml" --ask-become-pass "${DOTFILES_DIR}/main.yaml" "${@}"
+  fi
 }
 
 clone_or_update_dotfiles