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

68 lines
1.6 KiB
YAML
Raw Normal View History

2021-11-15 19:09:18 +01:00
# 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"
2021-11-15 19:09:18 +01:00
- name: Install needed packages
tags: [update]
2021-11-15 19:09:18 +01:00
apt:
package:
- rsync
- wireguard
- wireguard-tools
- name: Copy package to host
tags: [update]
2021-11-15 19:09:18 +01:00
synchronize:
2021-12-02 17:46:40 +01:00
src: "innernet.deb"
dest: "/tmp/innernet.deb"
2021-11-15 19:09:18 +01:00
2021-12-02 17:46:40 +01:00
- name: Install package
tags: [update]
2021-12-02 17:46:40 +01:00
apt:
deb: "/tmp/innernet.deb"
update_cache: true
2021-12-02 17:46:40 +01:00
install_recommends: true
2021-11-15 19:09:18 +01:00
- name: Copy non-admin invitation to hosts
2021-11-15 19:09:18 +01:00
synchronize:
src: "{{ item.name }}.toml"
2021-12-02 17:46:40 +01:00
dest: "/tmp/{{ item.name }}.toml"
2021-11-15 19:09:18 +01:00
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 }}"
2021-11-15 19:09:18 +01:00
- name: Install non-admin invitation on hosts
2021-11-15 19:09:18 +01:00
shell: |
2021-12-02 17:46:40 +01:00
innernet install /tmp/{{ item.name }}.toml \
--default-name \
--delete-invite
2021-11-15 19:09:18 +01:00
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 }}"
2021-12-02 17:46:40 +01:00
- name: Enable innernet daemon
systemd:
name: "innernet@{{ network_name }}"
state: started
enabled: true