1
0
Fork 0
mirror of https://github.com/roles-ansible/ansible_collection_wireguard.git synced 2024-10-27 22:47:42 +01:00

impreove wireguard-ui

This commit is contained in:
L3D 2024-10-14 01:34:07 +02:00
parent ee511af2b0
commit 3dd97f056c
Signed by: l3d
GPG key ID: CD08445BFF4313D1
9 changed files with 140 additions and 2 deletions

View file

@ -0,0 +1,24 @@
---
- name: Run systemctl restart wgui.path
listen: 'systemctl restart wgui.path'
become: true
ansible.builtin.systemd_service:
name: 'wgui.path'
enabled: true
state: 'restarted'
- name: Run systemctl restart wgui.service
listen: 'systemctl restart wgui.service'
become: true
ansible.builtin.systemd_service:
name: 'wgui.service'
enabled: true
state: 'restarted'
- name: Run systemctl restart wireguard-ui.service
listen: 'systemctl restart wireguard-ui.service'
become: true
ansible.builtin.systemd_service:
name: 'wireguard-ui.service'
enabled: true
state: 'restarted'

View file

@ -0,0 +1,19 @@
---
- name: Create wireguard-ui systemd service
become: true
ansible.builtin.template:
src: 'templates/wireguard-ui.service.j2'
dest: "/etc/systemd/system/wireguard-ui.service"
owner: 'root'
group: 'root'
mode: '0644'
notify: "systemctl restart wireguard-ui.service"
- name: Run systemctl start wireguard-ui.service
become: true
ansible.builtin.systemd_service:
name: 'wireguard-ui.service'
enabled: true
state: 'started'
daemon_reload: true
notify: "systemctl restart wireguard-ui.service"

View file

@ -11,3 +11,11 @@
- name: Download wireguard-ui - name: Download wireguard-ui
ansible.builtin.include_tasks: ansible.builtin.include_tasks:
file: 'download.yml' file: 'download.yml'
- name: Create wireguard-ui config
ansible.builtin.include_tasks:
file: 'configure.yml'
- name: Create systemd unit
ansible.builtin.include_tasks:
file: 'systemd.yml'

View file

@ -0,0 +1,33 @@
---
- name: Make sure wireguard config exist
become: true
ansible.builtin.file:
path: '/etc/wireguard/wg0.conf'
state: 'touch'
owner: 'root'
group: 'root'
mode: '0644'
- name: Copy systemd units
become: true
ansible.builtin.template:
src: "templates/{{ item }}.j2"
dest: "/etc/systemd/system/{{ item }}"
owner: 'root'
group: 'root'
mode: '0644'
with_items:
- 'wgui.path'
- 'wgui.service'
notify: "systemctl restart {{ item }}"
- name: Run systemctl start wgui
become: true
ansible.builtin.systemd_service:
name: "{{ item }}"
enabled: true
state: 'started'
daemon_reload: true
with_items:
- 'wgui.path'
- 'wgui.service'

View file

@ -0,0 +1,17 @@
---
- name: Create group for wireguardui
become: true
ansible.builtin.group:
name: "{{ wireguardui__group }}"
state: present
- name: Add user for wireguardui with disabled password
become: true
ansible.builtin.user:
name: "{{ wireguardui__owner }}"
home: "{{ wireguardui__home }}"
group: "{{ wireguardui__group }}"
password: '!'
create_home: true
system: true
shell: '/bin/bash'

View file

@ -0,0 +1,9 @@
{{ ansible_managed | comment }}
[Unit]
Description=Watch /etc/wireguard/wg0.conf for changes
[Path]
PathModified=/etc/wireguard/wg0.conf
[Install]
WantedBy=multi-user.target

View file

@ -0,0 +1,13 @@
{{ ansible_managed | comment }}
[Unit]
Description=Restart WireGuard
After=network.target
[Service]
Type=oneshot
ExecStart=/usr/bin/systemctl restart wg-quick@wg0.service
User=root
Group=root
[Install]
RequiredBy=wgui.path

View file

@ -0,0 +1,13 @@
{{ ansible_managed | comment }}
[Unit]
Description=Wireguard-ui Service
After=network.target
[Service]
Type=oneshot
ExecStart={{ wireguardui__full_executable_path }}
User=root
Group=root
[Install]
WantedBy=multi-user.target

View file

@ -1,5 +1,7 @@
--- ---
wireguardui__dependencies: [] wireguardui__dependencies:
- 'wireguard'
- 'wireguard-tools'
wireguardui__full_executable_path: '/usr/local/bin/wireguard-ui' wireguardui__full_executable_path: '/usr/local/bin/wireguard-ui'
@ -13,5 +15,5 @@ wireguardui__go_arch_map:
wireguardui__arch: "{{ wireguardui__go_arch_map[ansible_architecture] | default(ansible_architecture) }}" wireguardui__arch: "{{ wireguardui__go_arch_map[ansible_architecture] | default(ansible_architecture) }}"
packages__playbook_version_number: 3 packages__playbook_version_number: 4
packages__playbook_version_path: 'l3d.wireguard.wireguardui.version' packages__playbook_version_path: 'l3d.wireguard.wireguardui.version'