Skip to content

Commit

Permalink
Merge pull request #25 from m4rcu5nl/develop
Browse files Browse the repository at this point in the history
Release 1.2.0
  • Loading branch information
m4rcu5nl committed Dec 2, 2018
2 parents 89c5635 + bd95d5b commit b5cca4b
Show file tree
Hide file tree
Showing 6 changed files with 697 additions and 11 deletions.
674 changes: 674 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ A list of IP addresses to assign this member. The member will be automatically a
### zerotier_member_description
Optional desription for a member.

### zerotier_api_delegate
Option to delegate tasks for Zerotier API calls. By default the API calls are made from the machine running the role.

Example Playbook
----------------

Expand All @@ -44,7 +47,7 @@ Example Playbook
zerotier_register_short_hostname: true

roles:
- { role: m4rcu5nl.zerotier }
- { role: m4rcu5nl.zerotier, become: true }
```

Example Inventory
Expand Down
1 change: 1 addition & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
# defaults file for ansible-role-zerotier
zerotier_api_url: https://my.zerotier.com
zerotier_api_delegate: localhost
zerotier_apt_state: present
zerotier_register_short_hostname: false
zerotier_authorize_member: true
5 changes: 3 additions & 2 deletions meta/main.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
galaxy_info:
author: Marcus Meurs
description: Install zerotier-one package and add new members to a zerotier network
company: None

# If the issue tracker for your role is not on github, uncomment the
# next line and provide a value
Expand All @@ -13,7 +14,7 @@ galaxy_info:
# - GPLv3
# - Apache
# - CC-BY
license: BSD
license: GPLv3

min_ansible_version: 2.4

Expand Down Expand Up @@ -49,7 +50,7 @@ galaxy_info:
# - 99.99

galaxy_tags:
- zerotier-one
- zerotier
- networking
# 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
Expand Down
22 changes: 14 additions & 8 deletions tasks/authorize_node.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,15 @@
set_fact:
zerotier_node_id: "{{ nodeid.stdout }}"

when:
- zerotier_accesstoken is defined
- not ansible_check_mode
tags:
- configuration

- block:
- name: Authorize members to network
local_action:
module: uri
uri:
url: "{{ zerotier_api_url }}/api/network/{{ zerotier_network_id }}/member/{{ zerotier_node_id }}"
method: POST
headers:
Expand All @@ -21,12 +27,11 @@
config:
authorized: "{{ zerotier_authorize_member }}"
body_format: json
register: auth_apiresult
become: false
register: auth_apiresult
delegate_to: "{{ zerotier_api_delegate }}"

- name: Configure members in network
local_action:
module: uri
uri:
url: "{{ zerotier_api_url }}/api/network/{{ zerotier_network_id }}/member/{{ zerotier_node_id }}"
method: POST
headers:
Expand All @@ -37,11 +42,12 @@
config:
ipAssignments: "{{ zerotier_member_ip_assignments | default([]) | list }}"
body_format: json
register: conf_apiresult
become: false
register: conf_apiresult
delegate_to: "{{ zerotier_api_delegate }}"

when:
- zerotier_accesstoken is defined
- not ansible_check_mode
tags:
- configuration
become: false
1 change: 1 addition & 0 deletions tasks/install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
package:
name: zerotier-one
state: present
update_cache: yes
register: zerotier_client

- name: Start zerotier-one service
Expand Down

0 comments on commit b5cca4b

Please sign in to comment.