Update playbooks/debian/install-zerotier.yml
This commit is contained in:
1 parent
553ec4642f
commit
69f915c11b
1 file changed
+31
-17
@@ -5,11 +5,10 @@
|
|||||||
gather_facts: true
|
gather_facts: true
|
||||||
|
|
||||||
tasks:
|
tasks:
|
||||||
- name: Verify the host is running Debian
|
- name: Verify Debian
|
||||||
ansible.builtin.assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- ansible_distribution == "Debian"
|
- ansible_distribution == "Debian"
|
||||||
fail_msg: "This playbook only supports Debian hosts."
|
|
||||||
|
|
||||||
- name: Install prerequisites
|
- name: Install prerequisites
|
||||||
ansible.builtin.apt:
|
ansible.builtin.apt:
|
||||||
@@ -19,31 +18,46 @@
|
|||||||
- gpg
|
- gpg
|
||||||
state: present
|
state: present
|
||||||
update_cache: true
|
update_cache: true
|
||||||
cache_valid_time: 3600
|
|
||||||
|
|
||||||
- name: Download the official ZeroTier installer
|
- name: Download official ZeroTier installer
|
||||||
ansible.builtin.get_url:
|
ansible.builtin.get_url:
|
||||||
url: https://install.zerotier.com/
|
url: https://install.zerotier.com/
|
||||||
dest: /tmp/zerotier-install.sh
|
dest: /tmp/zerotier-install.sh
|
||||||
mode: "0755"
|
mode: "0755"
|
||||||
|
|
||||||
- name: Install ZeroTier
|
- name: Run official ZeroTier installer
|
||||||
ansible.builtin.command:
|
ansible.builtin.command:
|
||||||
cmd: bash /tmp/zerotier-install.sh
|
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
|
- name: Enable and start ZeroTier
|
||||||
ansible.builtin.systemd:
|
ansible.builtin.systemd:
|
||||||
name: zerotier-one
|
name: zerotier-one.service
|
||||||
enabled: true
|
enabled: true
|
||||||
state: started
|
state: started
|
||||||
|
when:
|
||||||
- name: Check ZeroTier status
|
- ansible_service_mgr == "systemd"
|
||||||
ansible.builtin.command:
|
- zerotier_unit.stdout is defined
|
||||||
cmd: zerotier-cli info
|
- "'zerotier-one.service' in zerotier_unit.stdout"
|
||||||
register: zerotier_status
|
|
||||||
changed_when: false
|
|
||||||
|
|
||||||
- name: Display ZeroTier status
|
|
||||||
ansible.builtin.debug:
|
|
||||||
msg: "{{ inventory_hostname }}: {{ zerotier_status.stdout }}"
|
|
||||||
Reference in new issue
Block a user