From b97d7b5159ae7dd378da59f2d81ea7e1e7f42e57 Mon Sep 17 00:00:00 2001 From: Brad Cowie Date: Sun, 29 Sep 2024 17:56:05 +1300 Subject: [PATCH] Automatically check for valid tailscale authentication --- tasks/auth.yml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tasks/auth.yml b/tasks/auth.yml index e0e1bcb..97572c0 100644 --- a/tasks/auth.yml +++ b/tasks/auth.yml @@ -49,9 +49,17 @@ - name: Prompt user to authenticate with tailscale in web browser ansible.builtin.pause: - prompt: |- + seconds: 1 + prompt: | To authenticate {{ inventory_hostname }} with tailscale, visit: {{ _tailscale_state.AuthURL }} - Press enter to continue + - name: Wait for device to be authenticated and approved + ansible.builtin.command: + cmd: "tailscale status --peers=false --json" + register: _tailscale_status_cmd + retries: 30 + delay: 10 + until: (_tailscale_status_cmd.stdout | from_json).BackendState == "Running" + changed_when: false