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:
parent
ee511af2b0
commit
3dd97f056c
9 changed files with 140 additions and 2 deletions
24
roles/wireguardui/handlers/main.yml
Normal file
24
roles/wireguardui/handlers/main.yml
Normal 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'
|
19
roles/wireguardui/tasks/configure.yml
Normal file
19
roles/wireguardui/tasks/configure.yml
Normal 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"
|
|
@ -11,3 +11,11 @@
|
|||
- name: Download wireguard-ui
|
||||
ansible.builtin.include_tasks:
|
||||
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'
|
||||
|
|
33
roles/wireguardui/tasks/systemd.yml
Normal file
33
roles/wireguardui/tasks/systemd.yml
Normal 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'
|
17
roles/wireguardui/tasks/user.yml
Normal file
17
roles/wireguardui/tasks/user.yml
Normal 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'
|
9
roles/wireguardui/templates/wgui.path.j2
Normal file
9
roles/wireguardui/templates/wgui.path.j2
Normal 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
|
13
roles/wireguardui/templates/wgui.service.j2
Normal file
13
roles/wireguardui/templates/wgui.service.j2
Normal 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
|
13
roles/wireguardui/templates/wireguard-ui.service.j2
Normal file
13
roles/wireguardui/templates/wireguard-ui.service.j2
Normal 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
|
|
@ -1,5 +1,7 @@
|
|||
---
|
||||
wireguardui__dependencies: []
|
||||
wireguardui__dependencies:
|
||||
- 'wireguard'
|
||||
- 'wireguard-tools'
|
||||
|
||||
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) }}"
|
||||
|
||||
packages__playbook_version_number: 3
|
||||
packages__playbook_version_number: 4
|
||||
packages__playbook_version_path: 'l3d.wireguard.wireguardui.version'
|
||||
|
|
Loading…
Reference in a new issue