-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
123 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
--- | ||
# defaults file for ansible-role-zerotier | ||
zerotier_api_accesstoken: "{{ zerotier_accesstoken | default() }}" # For backwards compatibility | ||
zerotier_api_url: https://my.zerotier.com | ||
zerotier_api_delegate: localhost | ||
zerotier_apt_state: present | ||
zerotier_register_short_hostname: false | ||
zerotier_member_register_short_hostname: "{{ zerotier_register_short_hostname | default(false) }}" # For backwards compatibility | ||
zerotier_authorize_member: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#!/bin/bash | ||
FACTS_DIR='/etc/ansible/facts.d' | ||
FACT_FILE="${FACTS_DIR}/zerotier.fact" | ||
NODE_STATUS=($(zerotier-cli status)) | ||
NETWORKS=$(zerotier-cli listnetworks | tail -n+2) | ||
|
||
function file_content { | ||
if [ ! -z "$NETWORKS" ]; then | ||
network_count=$(echo $NETWORKS |wc -l) | ||
counter=1 | ||
|
||
echo "{" | ||
echo " \"node_id\":\"${NODE_STATUS[2]}\"," | ||
echo " \"networks\": {" | ||
while read -r; do | ||
network=($REPLY) | ||
echo " \"${network[2]}\": {" | ||
echo " \"status\":\"${network[5]}\"" | ||
echo " \"device\":\"${network[7]}\"" | ||
|
||
if [ "$counter" -eq "$network_count" ]; then | ||
echo " }" | ||
else | ||
echo " }," | ||
fi | ||
((counter++)) | ||
done <<< $NETWORKS | ||
echo " }" | ||
echo "}" | ||
else | ||
echo "{\"node_id\":\"${NODE_STATUS[2]}\",\"networks\":{}}" | ||
fi | ||
} | ||
|
||
if [ ! -d "$FACTS_DIR" ]; then | ||
mkdir -p $FACTS_DIR | ||
fi | ||
|
||
file_content > $FACT_FILE | ||
|
||
|
||
# TO-DO | ||
# Handle different states than "OK". Other statuses can mess up positions. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
--- | ||
# vars file for ansible-role-zerotier | ||
zerotier_download_base_url: http://download.zerotier.com | ||
zerotier_deb_release_repo: "{{ ansible_facts['distribution_release'] }}" | ||
zerotier_gpg_url: https://download.zerotier.com/[email protected] |