first commit
This commit is contained in:
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
.galaxy_install_info
|
||||
21
README.md
Normal file
21
README.md
Normal 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
3
meta/main.yml
Normal file
@@ -0,0 +1,3 @@
|
||||
# This file is required by `ansible-galalxy install'.
|
||||
---
|
||||
galaxy_info:
|
||||
22
tasks/main.yml
Normal file
22
tasks/main.yml
Normal 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
11
templates/wg.conf.j2
Normal 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 %}
|
||||
Reference in New Issue
Block a user