Skip to content
Snippets Groups Projects
Unverified Commit de6badeb authored by Dmitriy Safronov's avatar Dmitriy Safronov Committed by GitHub
Browse files

initial (#1)

parent 1d296970
No related branches found
No related tags found
No related merge requests found
# ansible_role-template
# ansible_role-wireguard
Install & configure wireguard.
collections: []
dependencies: []
galaxy_info:
author: template
description: template
author: Dmitriy Safronov
description: "Install & configure wireguard"
license: Apache-2.0
min_ansible_version: "2.16"
namespace: template
role_name: template
namespace: dmitriysafronov
role_name: wireguard
---
- name: Install wireguard
ansible.builtin.package:
name: wireguard
state: present
- name: Fail on spaces in overlay file names
ansible.builtin.assert:
that:
- "' ' not in item.key"
with_dict: "{{ wireguard }}"
no_log: true
- name: Template wireguard configs
when:
- item.value is defined
- item.value != None
- item.value | length > 0
with_dict: "{{ wireguard }}"
ansible.builtin.template:
src: wireguard.conf.j2
dest: "/etc/wireguard/wg{{ item.key }}.conf"
owner: root
group: root
mode: "0644"
register: wireguard_service
no_log: true
- name: (Re)start wireguard service
when:
- wireguard is defined
- wireguard != None
- wireguard | length > 0
with_items: "{{ wireguard_service.results | selectattr('changed', 'equalto', true) | map(attribute='item.key') | list | unique }}"
ansible.builtin.systemd:
state: restarted
enabled: true
daemon_reload: true
name: "wg-quick@wg{{ item }}.service"
{{ ansible_managed | comment }}
{{ item.value }}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment