mirror of
https://github.com/skoobasteeve/ansible-server-setup.git
synced 2026-03-20 03:18:57 +00:00
initial working commit
This commit is contained in:
43
roles/tailscale/tasks/main.yml
Normal file
43
roles/tailscale/tasks/main.yml
Normal file
@@ -0,0 +1,43 @@
|
||||
---
|
||||
- name: check for tailscale install
|
||||
command:
|
||||
cmd: tailscale status
|
||||
register: tailscale_status
|
||||
ignore_errors: yes
|
||||
|
||||
- name: check tailscale_status
|
||||
ansible.builtin.debug:
|
||||
msg: "{{ tailscale_status }}"
|
||||
|
||||
- name: Download Tailscale install script
|
||||
get_url:
|
||||
url: https://tailscale.com/install.sh
|
||||
dest: /tmp/tailscale_install.sh
|
||||
mode: '0555'
|
||||
when: tailscale_status.failed
|
||||
|
||||
- name: Run Tailscale install script
|
||||
command:
|
||||
cmd: /tmp/tailscale_install.sh
|
||||
when: tailscale_status.failed
|
||||
|
||||
- name: Prompt to authorize device
|
||||
debug:
|
||||
msg: "Device requires authorization in the TailScale admin panel. Task will wait 60s for you to do so."
|
||||
when:
|
||||
- tailscale_status.failed == false
|
||||
- '"not yet authorized" in tailscale_status.stdout'
|
||||
|
||||
- name: Start Tailscale
|
||||
command:
|
||||
cmd: /usr/bin/tailscale up --authkey "{{ tailscale_key }}"
|
||||
async: 60
|
||||
when: tailscale_status.failed
|
||||
register: tailscale_start_status
|
||||
|
||||
- name: Machine added confirmation
|
||||
debug:
|
||||
msg: "Device successfully added to TailScale."
|
||||
when:
|
||||
- tailscale_start_status.changed
|
||||
- '"Success" in tailscale_start_status.stderr'
|
||||
Reference in New Issue
Block a user