18 Commits

Author SHA1 Message Date
bd13f3a938 update controller api to support new routes 2024-10-07 21:54:26 +05:30
Marcus
ca3cc077d6 Merge pull request #35 from m4rcu5nl/develop
Release v1.2.3
2020-03-13 01:35:01 +01:00
Marcus
904dcb399d Merge branch 'feature/gpg_fingerprint_variable' into develop 2020-03-09 23:19:28 +01:00
Marcus
0b9f100aa5 Use variable for gpg fingerprint
Using the fingerprint in the rpm_key module requires Ansible 2.9. Updated meta file to reflect this requirement.
2020-03-09 02:44:38 +01:00
Marcus
90167ae771 Merge pull request #30 from ClashTheBunny/pgp_key_id
Add PGP key `id` for added security
2020-03-09 02:33:09 +01:00
Marcus
a84ea36b37 Merge pull request #31 from quivalen/set_fact.sh-patch-1
Update set_fact.sh to support multiple network
2020-03-09 02:28:44 +01:00
Marcus
dc68166c27 Merge pull request #32 from dsteinkopf/master
fix usage of register variable function
2020-03-09 02:16:00 +01:00
Dirk Steinkopf
c9339c1f3b fix usage of register variable function 2019-11-16 18:23:45 +01:00
Andrea Lora
0755fa30b2 Update set_fact.sh to support multiple network
Currently the role will fail to regather fact if $network_count > 1

That's because without the quotes echo will suppress the \n writing everything in one line. Thus wc -l will return `1`, confusing the file_content function that will lead to an incorrect json being produced
2019-07-08 11:40:05 +01:00
Randall Mason
76b57fb097 Add PGP key id for added security 2019-06-09 12:50:53 -05:00
Marcus
49d61b875e Merge pull request #29 from papanito/papanito/correct-readme
Papanito/correct readme
2019-04-21 04:04:09 +02:00
papanito
ffba32f382 Fix some minor typos in text 2019-04-20 20:59:35 +02:00
papanito
2b56aaf46c Correct typo in example playbook 2019-04-20 20:53:09 +02:00
Marcus Meurs
154899586e Use the same fact syntax throughout the role
Create consistency by using the ansible_facts['somefact'] syntax everywhere.
2018-12-10 23:47:16 +01:00
Marcus Meurs
c7aae63e16 Merge branch 'hotfix/v1.2.2' 2018-12-08 02:26:57 +01:00
Marcus Meurs
a9fa164ebe Merge branch 'hotfix/v1.2.2' into develop 2018-12-08 02:26:57 +01:00
Marcus Meurs
5431276c8e Missed a pretty important comma 2018-12-08 02:25:12 +01:00
Marcus Meurs
a0228786d3 Merge branch 'release/v1.2.1' into develop 2018-12-07 23:48:30 +01:00
12 changed files with 108 additions and 105 deletions

View File

@@ -9,7 +9,7 @@ sudo: false
addons: addons:
apt: apt:
packages: packages:
- python-pip - python-pip
install: install:
# Install ansible # Install ansible

View File

@@ -1,3 +1,4 @@
[TODO] Update build
[![Build Status](https://travis-ci.org/m4rcu5nl/ansible-role-zerotier.svg?branch=master)](https://travis-ci.org/m4rcu5nl/ansible-role-zerotier) [![GitHub issues](https://img.shields.io/github/issues/m4rcu5nl/ansible-role-zerotier.svg)](https://github.com/m4rcu5nl/ansible-role-zerotier/issues) [![Build Status](https://travis-ci.org/m4rcu5nl/ansible-role-zerotier.svg?branch=master)](https://travis-ci.org/m4rcu5nl/ansible-role-zerotier) [![GitHub issues](https://img.shields.io/github/issues/m4rcu5nl/ansible-role-zerotier.svg)](https://github.com/m4rcu5nl/ansible-role-zerotier/issues)
ZeroTier ZeroTier
@@ -13,7 +14,6 @@ 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
-------------- --------------
@@ -35,7 +35,7 @@ Role Variables
### 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
@@ -50,7 +50,7 @@ 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 +59,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:

View File

@@ -1,7 +1,7 @@
--- ---
# defaults file for ansible-role-zerotier # defaults file for ansible-role-zerotier
zerotier_api_accesstoken: "{{ zerotier_accesstoken | default() }}" # For backwards compatibility zerotier_api_accesstoken: "{{ zerotier_accesstoken | default() }}" # For backwards compatibility
zerotier_api_url: https://my.zerotier.com zerotier_api_url: https://api.zerotier.com
zerotier_api_delegate: localhost zerotier_api_delegate: localhost
zerotier_apt_state: present zerotier_apt_state: present
zerotier_member_register_short_hostname: "{{ zerotier_register_short_hostname | default(false) }}" # For backwards compatibility zerotier_member_register_short_hostname: "{{ zerotier_register_short_hostname | default(false) }}" # For backwards compatibility

View File

@@ -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 "{"
@@ -15,7 +15,7 @@ function file_content {
while read -r; do while read -r; do
network=($REPLY) network=($REPLY)
echo " \"${network[2]}\": {" echo " \"${network[2]}\": {"
echo " \"status\":\"${network[5]}\"" echo " \"status\":\"${network[5]}\","
echo " \"device\":\"${network[7]}\"" echo " \"device\":\"${network[7]}\""
if [ "$counter" -eq "$network_count" ]; then if [ "$counter" -eq "$network_count" ]; then

View File

@@ -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:
@@ -33,19 +33,19 @@ galaxy_info:
# platforms is a list of platforms, and each platform has a name and a list of versions. # platforms is a list of platforms, and each platform has a name and a list of versions.
# #
platforms: platforms:
- name: EL - name: EL
versions: versions:
- 7 - 7
- name: Debian - name: Debian
versions: versions:
- stretch - stretch
- name: Ubuntu - name: Ubuntu
versions: versions:
- Bionic - Bionic
- Cosmic - Cosmic
- name: Fedora - name: Fedora
versions: versions:
- 28 - 39
# - name: SomePlatform # - name: SomePlatform
# versions: # versions:
# - all # - all
@@ -54,15 +54,16 @@ galaxy_info:
# - 99.99 # - 99.99
galaxy_tags: galaxy_tags:
- zerotier - zerotier
- networking - networking
# List tags for your role here, one per line. A tag is a keyword that describes # List tags for your role here, one per line. A tag is a keyword that describes
# and categorizes the role. Users find roles by searching for tags. Be sure to # and categorizes the role. Users find roles by searching for tags. Be sure to
# remove the '[]' above, if you add tags to this list. # remove the '[]' above, if you add tags to this list.
# #
# NOTE: A tag is limited to a single word comprised of alphanumeric characters. # NOTE: A tag is limited to a single word comprised of alphanumeric characters.
# Maximum 20 tags per role. # Maximum 20 tags per role.
dependencies: [] dependencies:
[]
# List your role dependencies here, one per line. Be sure to remove the '[]' above, # List your role dependencies here, one per line. Be sure to remove the '[]' above,
# if you add dependencies to this list. # if you add dependencies to this list.

View File

@@ -1,38 +1,39 @@
--- ---
- 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/v1/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 }}
body: body:
hidden: false hidden: false
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/v1/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 }}
body: body:
name: "{{ zerotier_member_register_short_hostname | ternary(inventory_hostname_short, inventory_hostname) }}" name: "{{ zerotier_member_register_short_hostname | ternary(inventory_hostname_short, inventory_hostname) }}"
description: "{{ zerotier_member_description | default() }}" description: "{{ zerotier_member_description | default() }}"
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:
- not ansible_check_mode - not ansible_check_mode
tags: tags:
- configuration - configuration
become: false become: false

View File

@@ -1,30 +1,29 @@
--- ---
- include_tasks: install/{{ ansible_facts['os_family'] }}.yml
- include_tasks: install/{{ ansible_os_family }}.yml
tags: tags:
- installation - installation
- repositories - repositories
- block: #Install and enable zerotier-one - block: #Install and enable zerotier-one
- name: Install zerotier-one - name: Install zerotier-one
package: package:
name: zerotier-one name: zerotier-one
state: present state: present
update_cache: yes update_cache: yes
register: zerotier_client register: zerotier_client
- name: Start zerotier-one service - name: Start zerotier-one service
service: service:
name: zerotier-one name: zerotier-one
state: started state: started
when: when:
- zerotier_client is succeeded - zerotier_client is succeeded
notify: notify:
- enable zerotier-one - enable zerotier-one
when: when:
- zerotier_repo is not defined or zerotier_repo is succeeded - zerotier_repo is not defined or zerotier_repo is succeeded
- not ansible_check_mode - not ansible_check_mode
tags: tags:
- installation - installation
- packages - packages

View File

@@ -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:
@@ -11,12 +12,12 @@
register: release_repo register: release_repo
- block: - block:
- name: Overwrite Ubuntu release repo name - name: Overwrite Ubuntu release repo name
set_fact: set_fact:
zerotier_deb_release_repo: bionic zerotier_deb_release_repo: bionic
- name: Re-gather facts - name: Re-gather facts
setup: ~ setup: ~
when: when:
- ansible_facts['distribution'] == "Ubuntu" - ansible_facts['distribution'] == "Ubuntu"

View File

@@ -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"

View File

@@ -4,4 +4,4 @@
args: args:
creates: /var/lib/zerotier-one/networks.d/{{ zerotier_network_id }}.conf creates: /var/lib/zerotier-one/networks.d/{{ zerotier_network_id }}.conf
tags: tags:
- configuration - configuration

View File

@@ -2,21 +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
setup: ~
- name: Re-gather ansible_local facts
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:
- zerotier_network_id is defined - zerotier_network_id is defined

View File

@@ -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