2020-11-08 01:34:05 -06:00
|
|
|
#!/usr/bin/env ansible-playbook
|
|
|
|
# vim:ft=ansible:
|
|
|
|
---
|
2020-12-04 09:22:56 -06:00
|
|
|
- name: configure zerotier for apt
|
|
|
|
block:
|
|
|
|
- name: ensure zerotier repo key
|
2022-06-16 23:45:29 -05:00
|
|
|
ansible.builtin.apt_key: url="{{ zerotier_repo_deb_key }}"
|
2020-12-04 09:22:56 -06:00
|
|
|
- name: ensure zerotier repo
|
2022-06-16 23:45:29 -05:00
|
|
|
ansible.builtin.apt_repository: repo="{{ zerotier_repo_deb }}"
|
2020-12-04 09:22:56 -06:00
|
|
|
- name: update apt cache
|
2022-06-16 23:45:29 -05:00
|
|
|
ansible.builtin.apt: update_cache=yes cache_valid_time=86400
|
2020-12-04 09:22:56 -06:00
|
|
|
- name: ensure packages
|
2022-06-16 23:45:29 -05:00
|
|
|
ansible.builtin.apt: name=zerotier-one
|
2020-12-04 09:22:56 -06:00
|
|
|
when: ansible_pkg_mgr == "apt"
|
2020-11-08 01:34:05 -06:00
|
|
|
- name: template unit file
|
2022-06-16 23:45:29 -05:00
|
|
|
ansible.builtin.template: src=zerotier-one.service dest=/etc/systemd/system/zerotier-one.service mode=0644
|
2020-11-08 01:34:05 -06:00
|
|
|
notify: restart zerotier
|
2022-01-23 17:17:35 -06:00
|
|
|
- name: join networks
|
2022-06-16 23:45:29 -05:00
|
|
|
ansible.builtin.command:
|
2022-01-23 17:17:35 -06:00
|
|
|
argv: [ zerotier-cli, join, "{{ item }}" ]
|
|
|
|
with_items: "{{ zerotier_networks_join }}"
|
2020-11-08 01:34:05 -06:00
|
|
|
changed_when: no
|
2022-01-23 17:17:35 -06:00
|
|
|
- name: leave networks
|
2022-06-16 23:45:29 -05:00
|
|
|
ansible.builtin.command:
|
2022-01-23 17:17:35 -06:00
|
|
|
argv: [ zerotier-cli, leave, "{{ item }}" ]
|
|
|
|
register: zerotierleave
|
|
|
|
with_items: "{{ zerotier_networks_leave }}"
|
|
|
|
changed_when: no
|
|
|
|
failed_when: "'0 leave connection failed' in zerotierleave.stdout"
|