From 810733b3c98801717593467bdee10f05afab3936 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 1 Jan 2026 07:53:20 +0000 Subject: [PATCH] Fix bootstrap --dev flag and is_desktop templating error bootstrap script: - Filter out --dev from args before passing to ansible-playbook - Previously --dev was passed through causing "unrecognized arguments" error playbook.yml: - Remove self-referencing is_desktop from vars (caused templating error) - Move desktop detection entirely to pre_tasks with proper conditionals - Use "is_desktop is not defined" to allow --extra-vars override --- .config/dotfiles/playbook.yml | 16 ++++++++++------ bin/bootstrap | 8 +++++--- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/.config/dotfiles/playbook.yml b/.config/dotfiles/playbook.yml index 7d18f0c..6664038 100644 --- a/.config/dotfiles/playbook.yml +++ b/.config/dotfiles/playbook.yml @@ -27,16 +27,14 @@ vars: dev_mode: false force: false - # Desktop detection: macOS is always desktop, Linux checks systemd target - # Override with --extra-vars "is_desktop=true" or "is_desktop=false" - _linux_desktop: "{{ ansible_service_mgr == 'systemd' and (ansible_facts['default_target'] | default('multi-user.target')) == 'graphical.target' }}" - is_desktop: "{{ is_desktop | default(true if ansible_os_family == 'Darwin' else _linux_desktop) }}" # Standard paths for tools (to avoid PATH dependency during bootstrap) brew_bin: /opt/homebrew/bin/brew local_bin: "{{ ansible_env.HOME }}/.local/bin" cargo_bin: "{{ ansible_env.HOME }}/.cargo/bin" pre_tasks: + # Desktop detection: macOS is always desktop, Linux checks systemd target + # Override with --extra-vars "is_desktop=true" or "is_desktop=false" - name: Gather systemd default target (Linux only) command: systemctl get-default register: systemd_target @@ -44,9 +42,15 @@ failed_when: false when: ansible_system == "Linux" and ansible_service_mgr == "systemd" - - name: Set desktop fact from systemd target + - name: Set desktop fact (macOS is always desktop) + set_fact: + is_desktop: true + when: is_desktop is not defined and ansible_os_family == "Darwin" + + - name: Set desktop fact (Linux checks systemd target) set_fact: - is_desktop: "{{ is_desktop | default(true if ansible_os_family == 'Darwin' else (systemd_target.stdout | default('multi-user.target')) == 'graphical.target') }}" + is_desktop: "{{ (systemd_target.stdout | default('multi-user.target')) == 'graphical.target' }}" + when: is_desktop is not defined and ansible_os_family != "Darwin" - name: Display system type debug: diff --git a/bin/bootstrap b/bin/bootstrap index 0b9f2a1..6552b81 100755 --- a/bin/bootstrap +++ b/bin/bootstrap @@ -46,12 +46,14 @@ echo "Running bootstrap setup..." echo "========================================" echo "" -# Parse arguments to determine if dev mode is requested +# Parse arguments - filter out our custom flags before passing to ansible EXTRA_VARS="" +ANSIBLE_ARGS=() for arg in "$@"; do if [[ "$arg" == "--dev" ]]; then EXTRA_VARS="--extra-vars dev_mode=true" - break + else + ANSIBLE_ARGS+=("$arg") fi done @@ -63,7 +65,7 @@ uvx --from ansible-core ansible-playbook \ --tags setup \ --ask-become-pass \ $EXTRA_VARS \ - "$@" + "${ANSIBLE_ARGS[@]}" echo "" echo "========================================"