update controller api to support new routes

pull/1/head
Malar Invention 2024-10-07 21:54:26 +05:30
parent ca3cc077d6
commit bd13f3a938
10 changed files with 93 additions and 93 deletions

View File

@ -9,7 +9,7 @@ sudo: false
addons:
apt:
packages:
- python-pip
- python-pip
install:
# 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)
ZeroTier

View File

@ -1,7 +1,7 @@
---
# defaults file for ansible-role-zerotier
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_apt_state: present
zerotier_member_register_short_hostname: "{{ zerotier_register_short_hostname | default(false) }}" # For backwards compatibility

View File

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

View File

@ -1,39 +1,39 @@
---
- block:
- name: Authorize new members to network
uri:
url: "{{ zerotier_api_url }}/api/network/{{ zerotier_network_id }}/member/{{ ansible_local['zerotier']['node_id'] }}"
method: POST
headers:
Authorization: bearer {{ zerotier_api_accesstoken }}
body:
hidden: false
config:
authorized: "{{ zerotier_authorize_member }}"
body_format: json
register: auth_apiresult
delegate_to: "{{ zerotier_api_delegate }}"
when:
- ansible_local['zerotier']['networks'][zerotier_network_id] is not defined or
ansible_local['zerotier']['networks'][zerotier_network_id]['status'] != 'OK'
- name: Authorize new members to network
uri:
url: "{{ zerotier_api_url }}/api/v1/network/{{ zerotier_network_id }}/member/{{ ansible_local['zerotier']['node_id'] }}"
method: POST
headers:
Authorization: bearer {{ zerotier_api_accesstoken }}
body:
hidden: false
config:
authorized: "{{ zerotier_authorize_member }}"
body_format: json
register: auth_apiresult
delegate_to: "{{ zerotier_api_delegate }}"
when:
- 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
uri:
url: "{{ zerotier_api_url }}/api/network/{{ zerotier_network_id }}/member/{{ ansible_local['zerotier']['node_id'] }}"
method: POST
headers:
Authorization: bearer {{ zerotier_api_accesstoken }}
body:
name: "{{ zerotier_member_register_short_hostname | ternary(inventory_hostname_short, inventory_hostname) }}"
description: "{{ zerotier_member_description | default() }}"
config:
ipAssignments: "{{ zerotier_member_ip_assignments | default([]) | list }}"
body_format: json
register: conf_apiresult
delegate_to: "{{ zerotier_api_delegate }}"
- name: Configure members in network
uri:
url: "{{ zerotier_api_url }}/api/v1/network/{{ zerotier_network_id }}/member/{{ ansible_local['zerotier']['node_id'] }}"
method: POST
headers:
Authorization: bearer {{ zerotier_api_accesstoken }}
body:
name: "{{ zerotier_member_register_short_hostname | ternary(inventory_hostname_short, inventory_hostname) }}"
description: "{{ zerotier_member_description | default() }}"
config:
ipAssignments: "{{ zerotier_member_ip_assignments | default([]) | list }}"
body_format: json
register: conf_apiresult
delegate_to: "{{ zerotier_api_delegate }}"
when:
- not ansible_check_mode
- not ansible_check_mode
tags:
- configuration
- configuration
become: false

View File

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

View File

@ -12,12 +12,12 @@
register: release_repo
- block:
- name: Overwrite Ubuntu release repo name
set_fact:
zerotier_deb_release_repo: bionic
- name: Overwrite Ubuntu release repo name
set_fact:
zerotier_deb_release_repo: bionic
- name: Re-gather facts
setup: ~
- name: Re-gather facts
setup: ~
when:
- ansible_facts['distribution'] == "Ubuntu"

View File

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

View File

@ -2,21 +2,20 @@
# tasks file for ansible-role-zerotier
- import_tasks: install.yml
when:
- not skip_install | default(false) | bool
- not skip_install | default(false) | bool
- block:
- name: Update ansible_local facts
script: set_facts.sh
- name: Re-gather ansible_local facts
setup: filter=ansible_local
- name: Update ansible_local facts
script: set_facts.sh
- name: Re-gather ansible_local facts
setup: filter=ansible_local
- import_tasks: authorize_node.yml
when:
- zerotier_api_accesstoken | length > 0
- ansible_local['zerotier']['node_id'] is defined
- zerotier_api_accesstoken | length > 0
- ansible_local['zerotier']['node_id'] is defined
- import_tasks: join_network.yml
when:
- zerotier_network_id is defined
- zerotier_network_id is defined

View File

@ -3,4 +3,4 @@
zerotier_download_base_url: http://download.zerotier.com
zerotier_deb_release_repo: "{{ ansible_facts['distribution_release'] }}"
zerotier_gpg_url: https://download.zerotier.com/contact@zerotier.com.gpg
zerotier_gpg_fingerprint: 74A5E9C458E1A431F1DA57A71657198823E52A61
zerotier_gpg_fingerprint: 74A5E9C458E1A431F1DA57A71657198823E52A61