forked from extern/innernet-playbook
92 lines
2.6 KiB
YAML
92 lines
2.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 package to server
|
|
synchronize:
|
|
src: "innernet-server.deb"
|
|
dest: "/tmp/innernet-server.deb"
|
|
|
|
- name: Install package
|
|
apt:
|
|
deb: "/tmp/innernet-server.deb"
|
|
install_recommends: true
|
|
|
|
- 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 }}
|
|
# FIXME innernet gives an error if network exists already
|
|
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 }}"
|
|
# FIXME innernet gives an error if CIDR exists already
|
|
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 }}"
|
|
# FIXME innernet gives an error if admin peer exists already
|
|
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 }}"
|
|
# FIXME innernet gives an error if peer exists already
|
|
ignore_errors: true
|
|
|
|
- name: Copy invitation files of admin peers to controller
|
|
# other machines should never be admins. Only humans.
|
|
synchronize:
|
|
src: "/root/{{ item.name }}.toml"
|
|
dest: "{{ playbook_dir }}/roles/client/files/{{ item.name }}_admin.toml"
|
|
mode: pull
|
|
with_items: "{{ admin_peers }}"
|
|
|
|
- name: Copy invitation files of peers to controller
|
|
synchronize:
|
|
src: "/root/{{ item.name }}.toml"
|
|
dest: "{{ playbook_dir }}/roles/client/files/{{ item.name }}.toml"
|
|
mode: pull
|
|
with_items: "{{ peers }}"
|
|
|
|
- name: Enable innernet-server daemon
|
|
systemd:
|
|
name: "innernet-server@{{ network_name }}"
|
|
state: restarted
|
|
daemon_reload: true
|