forked from extern/innernet-playbook
71 lines
1.9 KiB
YAML
71 lines
1.9 KiB
YAML
# SPDX-FileCopyrightText: 2021 Free Software Foundation Europe <https://fsfe.org>
|
|
#
|
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
|
|
---
|
|
- hosts: innernet_server
|
|
remote_user: root
|
|
tasks:
|
|
- name: Install needed packages
|
|
apt:
|
|
package:
|
|
- sqlite3
|
|
|
|
- name: Query innernet-server for CIDRs
|
|
shell: 'sqlite3 /var/lib/innernet-server/{{ network_name }}.db "select name from cidrs;"'
|
|
register: global_existing_cidrs
|
|
ignore_errors: true
|
|
|
|
- name: CIDRs already registered on innernet-server
|
|
debug:
|
|
msg: "{{ item }}"
|
|
loop: "{{ global_existing_cidrs.stdout_lines }}"
|
|
|
|
- name: CIDRs defined in this playbook
|
|
debug:
|
|
msg: "{{ item.name }}"
|
|
loop: "{{ cidrs }}"
|
|
|
|
- name: These CIDRs have been added
|
|
debug:
|
|
msg: "{{ item.name }} is new!"
|
|
when: item.name not in global_existing_cidrs.stdout_lines
|
|
loop: "{{ cidrs }}"
|
|
|
|
- name: Query innernet-server for peers
|
|
shell: 'sqlite3 /var/lib/innernet-server/{{ network_name }}.db "select name from peers;"'
|
|
register: global_existing_peers
|
|
ignore_errors: true
|
|
|
|
- name: Peers already registered on innernet-server
|
|
debug:
|
|
msg: "{{ item }}"
|
|
loop: "{{ global_existing_peers.stdout_lines }}"
|
|
|
|
- name: Peers defined in this playbook
|
|
debug:
|
|
msg: "{{ item.name }}"
|
|
loop: "{{ peers }}"
|
|
|
|
- name: These peers have been added
|
|
debug:
|
|
msg: "{{ item.name }} is new!"
|
|
when: item.name not in global_existing_peers.stdout_lines
|
|
loop: "{{ peers }}"
|
|
|
|
- hosts: innernet_server
|
|
remote_user: root
|
|
vars:
|
|
existing_peers: "{{ global_existing_peers.stdout_lines }}"
|
|
existing_cidrs: "{{ global_existing_cidrs.stdout_lines }}"
|
|
roles:
|
|
- server
|
|
|
|
- hosts: innernet_client
|
|
remote_user: root
|
|
vars:
|
|
existing_peers: "{{ global_existing_peers.stdout_lines }}"
|
|
existing_cidrs: "{{ global_existing_cidrs.stdout_lines }}"
|
|
roles:
|
|
- client
|