51 lines
1.5 KiB
YAML
51 lines
1.5 KiB
YAML
---
|
|
# tasks file for headscale
|
|
|
|
- name: Download headscale binary (arm64)
|
|
ansible.builtin.get_url:
|
|
url: https://github.com/juanfont/headscale/releases/download/v0.22.3/headscale_0.22.3_linux_arm64.deb
|
|
dest: /tmp/headscale_install.deb
|
|
when: ansible_architecture == "aarch64"
|
|
|
|
- name: Download headscale binary (amd64)
|
|
ansible.builtin.get_url:
|
|
url: https://github.com/juanfont/headscale/releases/download/v0.22.3/headscale_0.22.3_linux_amd64.deb
|
|
dest: /tmp/headscale_install.deb
|
|
when: ansible_architecture == "x86_64"
|
|
|
|
- name: Install headscale
|
|
apt:
|
|
deb: /tmp/headscale_install.deb
|
|
become: true
|
|
|
|
- name: Enable and start headscale service
|
|
ansible.builtin.service:
|
|
name: headscale
|
|
state: started
|
|
enabled: yes
|
|
become: true
|
|
when: inventory_hostname in groups['headscale_server']
|
|
|
|
- name: Create headscale users
|
|
loop: "{{ groups['headscale_client'] }}"
|
|
command: headscale users create "{{ hostname }}"
|
|
when: inventory_hostname in groups['headscale_server']
|
|
become: true
|
|
|
|
- name: Generate pre authentication keys
|
|
loop: "{{ groups['headscale_client'] }}"
|
|
command: headscale --user "{{ hostname }}" preauthkeys create --expiration 1h
|
|
when: inventory_hostname in groups['headscale_server']
|
|
become: true
|
|
register: headscale_preauthkey
|
|
|
|
- name: Print keys
|
|
loop: "{{ headscale_preauthkey.results }}"
|
|
debug:
|
|
msg: "{{ item.stdout }}"
|
|
when: inventory_hostname in groups['headscale_server']
|
|
|
|
#- name:
|
|
# ansible.builtin.command: headscale --
|
|
# register:
|