Update playbooks/debian/install-zerotier.yml

This commit is contained in:
diablo committed 2026-10-09 23:54:21 +08:00
1 parent 553ec4642f
commit 69f915c11b
1 file changed
+31 -17
+31 -17
View File
@@ -5,11 +5,10 @@
gather_facts: true
tasks:
- name: Verify the host is running Debian
- name: Verify Debian
ansible.builtin.assert:
that:
- ansible_distribution == "Debian"
fail_msg: "This playbook only supports Debian hosts."
- name: Install prerequisites
ansible.builtin.apt:
@@ -19,31 +18,46 @@
- gpg
state: present
update_cache: true
cache_valid_time: 3600
- name: Download the official ZeroTier installer
- name: Download official ZeroTier installer
ansible.builtin.get_url:
url: https://install.zerotier.com/
dest: /tmp/zerotier-install.sh
mode: "0755"
- name: Install ZeroTier
- name: Run official ZeroTier installer
ansible.builtin.command:
cmd: bash /tmp/zerotier-install.sh
creates: /usr/sbin/zerotier-one
register: zerotier_install
changed_when: zerotier_install.rc == 0
- name: Refresh systemd service definitions
ansible.builtin.command:
cmd: systemctl daemon-reload
changed_when: false
when: ansible_service_mgr == "systemd"
- name: Check for ZeroTier service
ansible.builtin.command:
cmd: systemctl list-unit-files zerotier-one.service
register: zerotier_unit
changed_when: false
failed_when: false
when: ansible_service_mgr == "systemd"
- name: Show installer and service diagnostics
ansible.builtin.debug:
msg:
- "Installer output: {{ zerotier_install.stdout | default('') }}"
- "Installer errors: {{ zerotier_install.stderr | default('') }}"
- "Service unit: {{ zerotier_unit.stdout | default('systemd unavailable') }}"
- name: Enable and start ZeroTier
ansible.builtin.systemd:
name: zerotier-one
name: zerotier-one.service
enabled: true
state: started
- name: Check ZeroTier status
ansible.builtin.command:
cmd: zerotier-cli info
register: zerotier_status
changed_when: false
- name: Display ZeroTier status
ansible.builtin.debug:
msg: "{{ inventory_hostname }}: {{ zerotier_status.stdout }}"
when:
- ansible_service_mgr == "systemd"
- zerotier_unit.stdout is defined
- "'zerotier-one.service' in zerotier_unit.stdout"