innernet-playbook/roles/client/tasks/main.yml

68 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
tags: [never, uninstall]
apt:
package:
- python3-pexpect
- name: Remove existing innernet
tags: [never, uninstall]
expect:
command: "innernet uninstall {{ network_name }}"
responses:
(?i)delete: "yes"
- name: Install needed packages
tags: [update]
apt:
package:
- rsync
- wireguard
- wireguard-tools
- name: Copy package to host
tags: [update]
synchronize:
src: "innernet.deb"
dest: "/tmp/innernet.deb"
- name: Install package
tags: [update]
apt:
deb: "/tmp/innernet.deb"
update_cache: true
install_recommends: true
- name: Copy non-admin invitation to hosts
synchronize:
src: "{{ item.name }}.toml"
dest: "/tmp/{{ item.name }}.toml"
when:
# is not existing
- item.name not in hostvars['kaim.fsfeurope.org'].global_existing_peers.stdout_lines
# only if filename contains a part of the hostname
- item.name in ansible_host|replace('.', '-')
loop: "{{ peers }}"
- name: Install non-admin invitation on hosts
shell: |
innernet install /tmp/{{ item.name }}.toml \
--default-name \
--delete-invite
when:
# is not existing
- item.name not in hostvars['kaim.fsfeurope.org'].global_existing_peers.stdout_lines
# only if filename contains a part of the hostname
- item.name in ansible_host|replace('.', '-')
loop: "{{ peers }}"
- name: Enable innernet daemon
systemd:
name: "innernet@{{ network_name }}"
state: started
enabled: true