commit
ca3cc077d6
19
README.md
19
README.md
|
|
@ -13,13 +13,12 @@ Technically this role has no requirements. If it's ran without any variables set
|
||||||
[**zerotier_network_id**](#zerotier_network_id): when set hosts are told to join this network.
|
[**zerotier_network_id**](#zerotier_network_id): when set hosts are told to join this network.
|
||||||
[**zerotier_api_accesstoken**](#zerotier_api_accesstoken): when set the role can handle member authentication and configuration using the ZeroTier API.
|
[**zerotier_api_accesstoken**](#zerotier_api_accesstoken): when set the role can handle member authentication and configuration using the ZeroTier API.
|
||||||
|
|
||||||
|
|
||||||
Role Variables
|
Role Variables
|
||||||
--------------
|
--------------
|
||||||
|
|
||||||
### zerotier_network_id
|
### zerotier_network_id
|
||||||
*Type*: string
|
*Type*: string
|
||||||
*Default value*:
|
*Default value*:
|
||||||
*Description*: The 16 character network ID of the network the new members should join. The node will not join any network if omitted.
|
*Description*: The 16 character network ID of the network the new members should join. The node will not join any network if omitted.
|
||||||
|
|
||||||
### zerotier_member_register_short_hostname
|
### zerotier_member_register_short_hostname
|
||||||
|
|
@ -29,17 +28,17 @@ Role Variables
|
||||||
|
|
||||||
### zerotier_member_ip_assignments
|
### zerotier_member_ip_assignments
|
||||||
*Type*: list
|
*Type*: list
|
||||||
*Default value*: `[]`
|
*Default value*: `[]`
|
||||||
*Description*: A list of IP addresses to assign this member. The member will be automatically assigned an address on the network if left out.
|
*Description*: A list of IP addresses to assign this member. The member will be automatically assigned an address on the network if left out.
|
||||||
|
|
||||||
### zerotier_member_description
|
### zerotier_member_description
|
||||||
*Type*: string
|
*Type*: string
|
||||||
*Default value*: `""`
|
*Default value*: `""`
|
||||||
*Description*: Optional desription for a member.
|
*Description*: Optional description for a member.
|
||||||
|
|
||||||
### zerotier_api_accesstoken
|
### zerotier_api_accesstoken
|
||||||
*Type*: string
|
*Type*: string
|
||||||
*Default value*: `""`
|
*Default value*: `""`
|
||||||
*Description*: The access token needed to authorize with the ZeroTier API. You can generate one in your account settings at https://my.zerotier.com/. If this is left out then the newly joined member will not be automatically authorized.
|
*Description*: The access token needed to authorize with the ZeroTier API. You can generate one in your account settings at https://my.zerotier.com/. If this is left out then the newly joined member will not be automatically authorized.
|
||||||
|
|
||||||
### zerotier_api_url
|
### zerotier_api_url
|
||||||
|
|
@ -49,8 +48,8 @@ Role Variables
|
||||||
|
|
||||||
### zerotier_api_delegate
|
### zerotier_api_delegate
|
||||||
*Type*: string
|
*Type*: string
|
||||||
*Default value*: `localhost`
|
*Default value*: `localhost`
|
||||||
*Description*: Option to delegate tasks for Zerotier API calls. This is usefull in a situation where API calls can only be made from a whitelisted management server, for example.
|
*Description*: Option to delegate tasks for Zerotier API calls. This is useful in a situation where API calls can only be made from a white-listed management server, for example.
|
||||||
|
|
||||||
Example Playbook
|
Example Playbook
|
||||||
----------------
|
----------------
|
||||||
|
|
@ -59,7 +58,7 @@ Example Playbook
|
||||||
- hosts: servers
|
- hosts: servers
|
||||||
vars:
|
vars:
|
||||||
zerotier_network_id: 1234567890qwerty
|
zerotier_network_id: 1234567890qwerty
|
||||||
zerotier_accesstoken: "{{ vault_zerotier_accesstoken }}"
|
zerotier_api_accesstoken: "{{ vault_zerotier_accesstoken }}"
|
||||||
zerotier_register_short_hostname: true
|
zerotier_register_short_hostname: true
|
||||||
|
|
||||||
roles:
|
roles:
|
||||||
|
|
@ -91,4 +90,4 @@ Example Inventory
|
||||||
|
|
||||||
[dbservers:vars]
|
[dbservers:vars]
|
||||||
zerotier_member_description='<AppName> db cluster node'
|
zerotier_member_description='<AppName> db cluster node'
|
||||||
```
|
```
|
||||||
|
|
@ -6,7 +6,7 @@ NETWORKS=$(zerotier-cli listnetworks | tail -n+2)
|
||||||
|
|
||||||
function file_content {
|
function file_content {
|
||||||
if [ ! -z "$NETWORKS" ]; then
|
if [ ! -z "$NETWORKS" ]; then
|
||||||
network_count=$(echo $NETWORKS |wc -l)
|
network_count=$(echo "$NETWORKS" |wc -l)
|
||||||
counter=1
|
counter=1
|
||||||
|
|
||||||
echo "{"
|
echo "{"
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ galaxy_info:
|
||||||
# - CC-BY
|
# - CC-BY
|
||||||
license: GPLv3
|
license: GPLv3
|
||||||
|
|
||||||
min_ansible_version: 2.4
|
min_ansible_version: 2.9
|
||||||
|
|
||||||
# If this a Container Enabled role, provide the minimum Ansible Container version.
|
# If this a Container Enabled role, provide the minimum Ansible Container version.
|
||||||
# min_ansible_container_version:
|
# min_ansible_container_version:
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
- block:
|
- block:
|
||||||
- name: Authorize new members to network
|
- name: Authorize new members to network
|
||||||
uri:
|
uri:
|
||||||
url: "{{ zerotier_api_url }}/api/network/{{ zerotier_network_id }}/member/{{ ansible_local.zerotier.node_id }}"
|
url: "{{ zerotier_api_url }}/api/network/{{ zerotier_network_id }}/member/{{ ansible_local['zerotier']['node_id'] }}"
|
||||||
method: POST
|
method: POST
|
||||||
headers:
|
headers:
|
||||||
Authorization: bearer {{ zerotier_api_accesstoken }}
|
Authorization: bearer {{ zerotier_api_accesstoken }}
|
||||||
|
|
@ -11,14 +11,15 @@
|
||||||
config:
|
config:
|
||||||
authorized: "{{ zerotier_authorize_member }}"
|
authorized: "{{ zerotier_authorize_member }}"
|
||||||
body_format: json
|
body_format: json
|
||||||
register: auth_apiresult
|
register: auth_apiresult
|
||||||
delegate_to: "{{ zerotier_api_delegate }}"
|
delegate_to: "{{ zerotier_api_delegate }}"
|
||||||
when:
|
when:
|
||||||
- ansible_local.zerotier.networks[zerotier_network_id] is not defined or ansible_local.zerotier.networks[zerotier_network_id].status != 'OK'
|
- ansible_local['zerotier']['networks'][zerotier_network_id] is not defined or
|
||||||
|
ansible_local['zerotier']['networks'][zerotier_network_id]['status'] != 'OK'
|
||||||
|
|
||||||
- name: Configure members in network
|
- name: Configure members in network
|
||||||
uri:
|
uri:
|
||||||
url: "{{ zerotier_api_url }}/api/network/{{ zerotier_network_id }}/member/{{ ansible_local.zerotier.node_id }}"
|
url: "{{ zerotier_api_url }}/api/network/{{ zerotier_network_id }}/member/{{ ansible_local['zerotier']['node_id'] }}"
|
||||||
method: POST
|
method: POST
|
||||||
headers:
|
headers:
|
||||||
Authorization: bearer {{ zerotier_api_accesstoken }}
|
Authorization: bearer {{ zerotier_api_accesstoken }}
|
||||||
|
|
@ -28,7 +29,7 @@
|
||||||
config:
|
config:
|
||||||
ipAssignments: "{{ zerotier_member_ip_assignments | default([]) | list }}"
|
ipAssignments: "{{ zerotier_member_ip_assignments | default([]) | list }}"
|
||||||
body_format: json
|
body_format: json
|
||||||
register: conf_apiresult
|
register: conf_apiresult
|
||||||
delegate_to: "{{ zerotier_api_delegate }}"
|
delegate_to: "{{ zerotier_api_delegate }}"
|
||||||
|
|
||||||
when:
|
when:
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
---
|
---
|
||||||
|
|
||||||
- include_tasks: install/{{ ansible_os_family }}.yml
|
- include_tasks: install/{{ ansible_facts['os_family'] }}.yml
|
||||||
tags:
|
tags:
|
||||||
- installation
|
- installation
|
||||||
- repositories
|
- repositories
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
- name: Add ZeroTier PGP key
|
- name: Add ZeroTier PGP key
|
||||||
apt_key:
|
apt_key:
|
||||||
url: "{{ zerotier_gpg_url }}"
|
url: "{{ zerotier_gpg_url }}"
|
||||||
|
id: "{{ zerotier_gpg_fingerprint }}"
|
||||||
|
|
||||||
- name: Check if Ubuntu release has dedicated repo
|
- name: Check if Ubuntu release has dedicated repo
|
||||||
uri:
|
uri:
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
rpm_key:
|
rpm_key:
|
||||||
state: present
|
state: present
|
||||||
key: "{{ zerotier_gpg_url }}"
|
key: "{{ zerotier_gpg_url }}"
|
||||||
|
fingerprint: "{{ zerotier_gpg_fingerprint }}"
|
||||||
|
|
||||||
- name: Add ZeroTier repo for RHEL/CentOS
|
- name: Add ZeroTier repo for RHEL/CentOS
|
||||||
yum_repository:
|
yum_repository:
|
||||||
|
|
@ -11,7 +12,7 @@
|
||||||
gpgcheck: yes
|
gpgcheck: yes
|
||||||
enabled: yes
|
enabled: yes
|
||||||
register: zerotier_repo
|
register: zerotier_repo
|
||||||
when: ansible_distribution != "Fedora"
|
when: ansible_facts['distribution'] != "Fedora"
|
||||||
|
|
||||||
- name: Add zerotier repo for Fedora
|
- name: Add zerotier repo for Fedora
|
||||||
yum_repository:
|
yum_repository:
|
||||||
|
|
@ -21,4 +22,4 @@
|
||||||
gpgcheck: yes
|
gpgcheck: yes
|
||||||
enabled: yes
|
enabled: yes
|
||||||
register: zerotier_repo
|
register: zerotier_repo
|
||||||
when: ansible_distribution == "Fedora"
|
when: ansible_facts['distribution'] == "Fedora"
|
||||||
|
|
|
||||||
|
|
@ -2,20 +2,20 @@
|
||||||
# tasks file for ansible-role-zerotier
|
# tasks file for ansible-role-zerotier
|
||||||
- import_tasks: install.yml
|
- import_tasks: install.yml
|
||||||
when:
|
when:
|
||||||
- not skip_install|default(false)|bool
|
- not skip_install | default(false) | bool
|
||||||
|
|
||||||
- block:
|
- block:
|
||||||
- name: Update ansible_local facts
|
- name: Update ansible_local facts
|
||||||
script: set_facts.sh
|
script: set_facts.sh
|
||||||
|
|
||||||
- name: Re-gather facts
|
- name: Re-gather ansible_local facts
|
||||||
setup: ~
|
setup: filter=ansible_local
|
||||||
|
|
||||||
|
|
||||||
- import_tasks: authorize_node.yml
|
- import_tasks: authorize_node.yml
|
||||||
when:
|
when:
|
||||||
- zerotier_api_accesstoken | length > 0
|
- zerotier_api_accesstoken | length > 0
|
||||||
- ansible_local.zerotier.node_id is defined
|
- ansible_local['zerotier']['node_id'] is defined
|
||||||
|
|
||||||
- import_tasks: join_network.yml
|
- import_tasks: join_network.yml
|
||||||
when:
|
when:
|
||||||
|
|
|
||||||
|
|
@ -3,3 +3,4 @@
|
||||||
zerotier_download_base_url: http://download.zerotier.com
|
zerotier_download_base_url: http://download.zerotier.com
|
||||||
zerotier_deb_release_repo: "{{ ansible_facts['distribution_release'] }}"
|
zerotier_deb_release_repo: "{{ ansible_facts['distribution_release'] }}"
|
||||||
zerotier_gpg_url: https://download.zerotier.com/contact@zerotier.com.gpg
|
zerotier_gpg_url: https://download.zerotier.com/contact@zerotier.com.gpg
|
||||||
|
zerotier_gpg_fingerprint: 74A5E9C458E1A431F1DA57A71657198823E52A61
|
||||||
Loading…
Reference in New Issue