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

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

@ -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,39 +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] is not defined or
ansible_local['zerotier']['networks'][zerotier_network_id]['status'] != 'OK' 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_facts['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

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

@ -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 ansible_local facts
setup: filter=ansible_local
- 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