first commit

This commit is contained in:
Nikita Simonov
2026-05-28 13:08:52 +04:00
commit 64e5afd148
5 changed files with 58 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
.galaxy_install_info

21
README.md Normal file
View File

@@ -0,0 +1,21 @@
# WireGuard ansible role
Configure wireguard
## Usega
Configure the role
```yml
wireguard_interfaces:
wg01:
interface:
Address: 10.0.0.1
ListenPort: 51820
PrivateKey: "{{ wireguard_private_key }}"
peers:
- AllowedIPs: 10.0.0.0/24
PublicKey: "{{ wireguard_public_key }}"
Endpoint: 1.1.1.1:51820
PersistentKeepalive: 25
'''

3
meta/main.yml Normal file
View File

@@ -0,0 +1,3 @@
# This file is required by `ansible-galalxy install'.
---
galaxy_info:

22
tasks/main.yml Normal file
View File

@@ -0,0 +1,22 @@
---
- name: Install wireguard package
ansible.builtin.apt:
name: wireguard
state: present
- name: Copy wireguard config
ansible.builtin.template:
src: "wg.conf.j2"
dest: "/etc/wireguard/{{ item }}.conf"
owner: root
group: root
mode: 0644
with_items: "{{ wireguard_interfaces }}"
- name: Enable and start wg-quick service
ansible.builtin.service:
name: wg-quick@{{ item }}.service
daemon_reload: yes
state: started
enabled: yes
with_items: "{{ wireguard_interfaces }}"

11
templates/wg.conf.j2 Normal file
View File

@@ -0,0 +1,11 @@
[Interface]
{% for key, value in wireguard_interfaces[item].interface | dictsort %}
{{ key }} = {{ value }}
{% endfor %}
{% for peer in wireguard_interfaces[item].peers %}
[Peer]
{% for key, value in peer | dictsort %}
{{ key }} = {{ value }}
{% endfor %}
{% endfor %}