From 7b9f5d02a31db05d1b3560379f6e54aea909418e Mon Sep 17 00:00:00 2001 From: Marcus Meurs Date: Thu, 5 Apr 2018 11:23:07 +0200 Subject: [PATCH 1/3] Conditional installation Don't import installation tasks when the zt0 interface is present on target host. --- tasks/main.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tasks/main.yml b/tasks/main.yml index 554c10e..6410992 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,6 +1,8 @@ --- # tasks file for ansible-role-zerotier - import_tasks: install.yml + when: + - "'zt0' not in ansible_interfaces" - import_tasks: authorize_node.yml when: From 31e25cb3f0598d89b8154bd88261d8a9d62460f2 Mon Sep 17 00:00:00 2001 From: Marcus Meurs Date: Thu, 5 Apr 2018 11:32:19 +0200 Subject: [PATCH 2/3] Make API call local_action Having the controller talk to the ZeroTier API instead of connecting to the target hosts and make them do it is much faster. --- tasks/authorize_node.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tasks/authorize_node.yml b/tasks/authorize_node.yml index 50c34e7..a6f7c87 100644 --- a/tasks/authorize_node.yml +++ b/tasks/authorize_node.yml @@ -10,7 +10,8 @@ zerotier_node_id: "{{ nodeid.stdout }}" - name: Add and authorize members to network - uri: + local_action: + module: uri url: "{{ zerotier_api_url }}/api/network/{{ zerotier_network_id }}/member/{{ zerotier_node_id }}" method: POST headers: @@ -24,6 +25,7 @@ ipAssignments: "{{ zerotier_member_ip_assignments | default([]) | list }}" body_format: json register: apiresult + become: false when: - zerotier_accesstoken is defined From 4146b7a2576018129e1c28354024b086edcd217d Mon Sep 17 00:00:00 2001 From: Marcus Meurs Date: Mon, 9 Apr 2018 04:30:56 +0200 Subject: [PATCH 3/3] Option to skip installation Give the user an option to skip the installation tasks. There's no real need to download the pgp key and packages again when all you want to do is reconfigure existing members. --- tasks/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasks/main.yml b/tasks/main.yml index 6410992..0b2aa25 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -2,7 +2,7 @@ # tasks file for ansible-role-zerotier - import_tasks: install.yml when: - - "'zt0' not in ansible_interfaces" + - not skip_install|default(false)|bool - import_tasks: authorize_node.yml when: