innernet-playbook/roles/server/tasks/main.yml
2021-11-13 16:21:19 +01:00

60 lines
1.6 KiB
YAML

# SPDX-FileCopyrightText: 2021 Free Software Foundation Europe <https://fsfe.org>
#
# SPDX-License-Identifier: AGPL-3.0-or-later
---
- name: Install needed packages
apt:
package:
- rsync
- wireguard
- wireguard-tools
- name: Copy binary to server
synchronize: src= dest=
- name: Create base network
shell: |
innernet-server new \
--network-name "{{ network_name }}" \
--network-cidr "{{ network_cidr }}" \
--external-endpoint "[{{ hostvars[inventory_hostname]['ansible_default_ipv6']['address'] }}]:{{ network_listen_port }}" \
--listen-port {{ network_listen_port }}
ignore_errors: true
- name: Create CIDRs
shell: |
innernet-server add-cidr "{{ network_name }}" \
--parent "{{ item.parent }}" \
--name "{{ item.name }}" \
--cidr "{{ item.cidr }}" \
--yes
with_items: "{{ cidrs }}"
ignore_errors: true
- name: Create admin peers
shell: |
innernet-server add-peer "{{ network_name }}" \
--name "{{ item.name }}" \
--cidr "{{ item.cidr }}" \
--admin true \
--save-config "{{ item.name }}.toml" \
--invite-expires "14d" \
--auto-ip \
--yes
with_items: "{{ admin_peers }}"
ignore_errors: true
- name: Create peers
shell: |
innernet-server add-peer "{{ network_name }}" \
--name "{{ item.name }}" \
--cidr "{{ item.cidr }}" \
--admin false \
--save-config "{{ item.name }}.toml" \
--invite-expires "14d" \
--auto-ip \
--yes
with_items: "{{ peers }}"
ignore_errors: true