innernet-playbook/roles/server/tasks/add_peer.yml

47 lines
1.4 KiB
YAML

# SPDX-FileCopyrightText: 2021 Free Software Foundation Europe <https://fsfe.org>
#
# SPDX-License-Identifier: AGPL-3.0-or-later
---
- name: Make sure peer invitation does not exist before creating a new one
file:
path: "/root/{{ peer_name }}.toml"
state: absent
- name: Add innernet peer on server
shell: |
innernet-server add-peer "{{ network_name }}" \
--name "{{ peer_name }}" \
--cidr "{{ peer_cidr }}" \
--admin "{{ peer_admin | lower }}" \
--save-config "/root/{{ peer_name }}.toml" \
--invite-expires "14d" \
--auto-ip \
--yes
throttle: 1
- name: Copy peer invitation file from server to controller
fetch:
src: "/root/{{ peer_name }}.toml"
dest: "{{ playbook_dir }}/roles/client/files/{{ peer_name }}.toml"
flat: yes
fail_on_missing: yes
- name: Delete peer invitation file on server
file:
path: "/root/{{ peer_name }}.toml"
state: absent
- name: Inform about invitation file
debug:
msg: "
{% if manual is defined and manual %}
ATTENTION! Now you have to install the peer invitation file for
{{ peer_name }} manually. You will find it here:
{% else %}
The peer invitation file has been downloaded to your computer. It will
be installed automatically on the machine, so if everything succeeded,
you can safely delete it here.
{% endif %}
{{ playbook_dir }}/roles/client/files/{{ peer_name }}.toml
"