Skip to content

Commit

Permalink
fix: [BUG] If tailscale_up_timeout is bigger than 60s... (artis3n#426)
Browse files Browse the repository at this point in the history
* fix: [BUG] If tailscale_up_timeout is bigger than 60s...

* add type check

* fix fail condition

* add zero check condition

---------

Co-authored-by: Ari Kalfus <[email protected]>
  • Loading branch information
McSim85 and artis3n authored Feb 7, 2024
1 parent 1fe9171 commit 8bf2072
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 6 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -235,9 +235,9 @@ If you need to view the unredacted value, see [`insecurely_log_authkey`](#insecu

### tailscale_up_timeout

**Default**: `120s`
**Default**: `120`

Defines the timeout duration for the `tailscale up` command.
Defines the timeout duration for the `tailscale up` command in seconds.

> --timeout duration
>
Expand Down
4 changes: 2 additions & 2 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ tailscale_authkey: ""
tailscale_args: ""
# Apply provided tags to node
tailscale_tags: []
# Set timeout for 'tailscale up' command
tailscale_up_timeout: "120s"
# Set timeout for 'tailscale up' command in seconds
tailscale_up_timeout: "120"

# Used for OAuth authentication
# Register as an ephemeral node (recommended)
Expand Down
4 changes: 2 additions & 2 deletions tasks/install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@

- name: Install | Build the final tailscale_args
ansible.builtin.set_fact:
tailscale_args_string: "{{ tailscale_args }} {{ tailscale_tags_string | trim }} --timeout={{ tailscale_up_timeout | trim }}"
tailscale_args_string: "{{ tailscale_args }} {{ tailscale_tags_string | trim }} --timeout={{ tailscale_up_timeout | trim }}s"

- name: Install | Final `tailscale up` arguments string
ansible.builtin.debug:
Expand Down Expand Up @@ -142,7 +142,7 @@
- not tailscale_up_skip
- state_file is changed or not tailscale_is_online
notify: Confirm Tailscale is Connected
async: 60
async: "{{ (tailscale_up_timeout | trim | int) + 10 }}"
poll: 5

- name: Install | Report non-sensitive stdout from "tailscale up" # noqa: no-handler
Expand Down
9 changes: 9 additions & 0 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,15 @@
- state != "absent"
- not tailscale_up_skip

- name: Tailscale timeout verification
ansible.builtin.fail:
msg: "`tailscale_up_timeout` variable should be parseable as an integer."
when:
- tailscale_up_timeout != 0
- (tailscale_up_timeout | type_debug == "bool") or not (tailscale_up_timeout | int)
- state != "absent"
- not tailscale_up_skip

- name: Use tailscale_tags instead of tailscale_args for tags
ansible.builtin.debug:
msg: You must use `tailscale_tags` instead of `tailscale_args` to assign tags.
Expand Down

0 comments on commit 8bf2072

Please sign in to comment.