fix deploy and bump to 0.4.0

This commit is contained in:
ace 2023-03-10 16:18:46 +03:00
parent 352428ce8c
commit fd0c675ce6
Signed by: ace
GPG Key ID: 2C08973DD37A76FD
8 changed files with 33 additions and 27 deletions

View File

@ -5,7 +5,7 @@ wireguard_ui_network_mode: "host"
wireguard_ui_config_dir: "/opt/{{ wireguard_ui_container_name }}" wireguard_ui_config_dir: "/opt/{{ wireguard_ui_container_name }}"
wireguard_ui_container_registry: "{{ container_registry | default(docker_registry) | default('docker.io') }}" wireguard_ui_container_registry: "{{ container_registry | default(docker_registry) | default('docker.io') }}"
wireguard_ui_image_name: "ngoduykhanh/wireguard-ui" wireguard_ui_image_name: "ngoduykhanh/wireguard-ui"
wireguard_ui_image_tag: "0.3.7" wireguard_ui_image_tag: "0.4.0"
wireguard_ui_systemd_unit_name: "{{ wireguard_ui_container_name }}.service" wireguard_ui_systemd_unit_name: "{{ wireguard_ui_container_name }}.service"
wireguard_ui_watcher_systemd_service_unit_name: "{{ wireguard_ui_container_name }}-watcher.service" wireguard_ui_watcher_systemd_service_unit_name: "{{ wireguard_ui_container_name }}-watcher.service"
wireguard_ui_watcher_systemd_path_unit_name: "{{ wireguard_ui_container_name }}-watcher.path" wireguard_ui_watcher_systemd_path_unit_name: "{{ wireguard_ui_container_name }}-watcher.path"
@ -17,13 +17,14 @@ wireguard_ui_default_volumes:
#wireguard_ui_env: {} #wireguard_ui_env: {}
wireguard_ui_default_env: wireguard_ui_default_env:
WGUI_USERNAME: admin WGUI_USERNAME: "admin"
WGUI_PASSWORD: admin WGUI_PASSWORD: "admin"
WGUI_MTU: 1420 WGUI_MTU: "1420"
BIND_ADDRESS: 127.0.0.1:5001 WGUI_SERVER_INTERFACE_ADDRESSES: "10.252.1.1/24"
SESSION_SECRET: 74f8155b3c91437db6e6c29c28e23ecc BIND_ADDRESS: "127.0.0.1:5001"
WGUI_CONFIG_FILE_PATH: /etc/wireguard/wg0.conf SESSION_SECRET: "74f8155b3c91437db6e6c29c28e23ecc"
BASE_PATH: / WGUI_CONFIG_FILE_PATH: "/etc/wireguard/wg0.conf"
BASE_PATH: "/"
# Example for auth # Example for auth
#wireguard_ui_container_registry_auth: #wireguard_ui_container_registry_auth:

View File

@ -8,7 +8,7 @@
detach: true detach: true
restart_policy: unless-stopped restart_policy: unless-stopped
env: "{{ wireguard_ui_combined_env }}" env: "{{ wireguard_ui_combined_env }}"
volumes: "{{ wireguard_ui_combined_volumes }}" volumes: "{{ wireguard_ui_volumes }}"
when: when:
- wireguard_ui_container_engine == 'docker' - wireguard_ui_container_engine == 'docker'
- not wireguard_ui_container.changed - not wireguard_ui_container.changed
@ -23,7 +23,7 @@
state: started state: started
restart: yes restart: yes
env: "{{ wireguard_ui_combined_env }}" env: "{{ wireguard_ui_combined_env }}"
volumes: "{{ wireguard_ui_combined_volumes }}" volumes: "{{ wireguard_ui_volumes }}"
when: when:
- wireguard_ui_container_engine == 'podman' - wireguard_ui_container_engine == 'podman'
- not wireguard_ui_container.changed - not wireguard_ui_container.changed

View File

@ -11,10 +11,20 @@
loop: '{{ wireguard_ui_container_registry_auth | dict2items }}' loop: '{{ wireguard_ui_container_registry_auth | dict2items }}'
when: wireguard_ui_container_registry_auth is defined when: wireguard_ui_container_registry_auth is defined
- name: Create configuration dir for WireGuard UI - name: Create configuration dir and subdirs for WireGuard UI
file: file:
name: "{{ wireguard_ui_config_dir }}" name: "{{ item }}"
state: directory state: directory
loop:
- "{{ wireguard_ui_config_dir }}"
- "{{ wireguard_ui_config_dir }}/server"
- name: Force login and password change
template:
dest: "{{ wireguard_ui_config_dir }}/server/users.json"
src: users.json.j2
register: wireguard_ui_auth
notify: Restart WireGuard UI with podman
- name: Create WireGuard UI with podman - name: Create WireGuard UI with podman
containers.podman.podman_container: containers.podman.podman_container:
@ -23,18 +33,13 @@
network_mode: "{{ wireguard_ui_network_mode }}" network_mode: "{{ wireguard_ui_network_mode }}"
image: "{{ wireguard_ui_container_registry }}/{{ wireguard_ui_image_name }}:{{ wireguard_ui_image_tag }}" image: "{{ wireguard_ui_container_registry }}/{{ wireguard_ui_image_name }}:{{ wireguard_ui_image_tag }}"
state: created state: created
cap_add:
- NET_ADMIN
env: "{{ wireguard_ui_combined_env }}" env: "{{ wireguard_ui_combined_env }}"
volumes: "{{ wireguard_ui_combined_volumes }}" volumes: "{{ wireguard_ui_volumes }}"
register: wireguard_ui_container register: wireguard_ui_container
notify: Restart WireGuard UI with podman notify: Restart WireGuard UI with podman
- name: Force login and password change
template:
dest: "{{ wireguard_ui_config_dir }}/server/users.json"
src: users.json.j2
register: wireguard_ui_auth
notify: Restart WireGuard UI with podman
- name: Generate container systemd unit - name: Generate container systemd unit
shell: "podman generate systemd {{ wireguard_ui_container_name }}" shell: "podman generate systemd {{ wireguard_ui_container_name }}"
register: wireguard_ui_systemd_unit register: wireguard_ui_systemd_unit

View File

@ -49,6 +49,6 @@
- name: Enable wg-quick systemd unit - name: Enable wg-quick systemd unit
systemd: systemd:
name: wg-quick@{{ wireguard_ui_env['WGUI_CONFIG_FILE_PATH'] | basename | split('.') | first }} name: wg-quick@{{ wireguard_ui_combined_env['WGUI_CONFIG_FILE_PATH'] | basename | split('.') | first }}
enabled: yes enabled: yes
daemon_reload: yes daemon_reload: yes

View File

@ -14,7 +14,7 @@
- name: Merge volumes - name: Merge volumes
set_fact: set_fact:
wireguard_ui_combined_volumes: "{{ wireguard_ui_volumes | default([]) + [item.key +':'+ item.value] }}" wireguard_ui_volumes: "{{ wireguard_ui_volumes | default([]) + [item.key +':'+ item.value] }}"
loop: "{{ wireguard_ui_default_volumes | dict2items }}" loop: "{{ wireguard_ui_default_volumes | dict2items }}"
- name: Merge ENV - name: Merge ENV

View File

@ -1,4 +1,4 @@
{ {
"username": "{{ wireguard_ui_env['WGUI_USERNAME'] }}", "username": "{{ wireguard_ui_combined_env['WGUI_USERNAME'] }}",
"password": "{{ wireguard_ui_env['WGUI_PASSWORD'] }}" "password": "{{ wireguard_ui_combined_env['WGUI_PASSWORD'] }}"
} }

View File

@ -1,8 +1,8 @@
[Unit] [Unit]
Description=Watch {{ wireguard_ui_env['WGUI_CONFIG_FILE_PATH'] }} for changes Description=Watch {{ wireguard_ui_combined_env['WGUI_CONFIG_FILE_PATH'] }} for changes
[Path] [Path]
PathModified={{ wireguard_ui_env['WGUI_CONFIG_FILE_PATH'] }} PathModified={{ wireguard_ui_combined_env['WGUI_CONFIG_FILE_PATH'] }}
[Install] [Install]
WantedBy=multi-user.target WantedBy=multi-user.target

View File

@ -4,7 +4,7 @@ After=network.target
[Service] [Service]
Type=oneshot Type=oneshot
ExecStart=/usr/bin/systemctl restart wg-quick@{{ wireguard_ui_env['WGUI_CONFIG_FILE_PATH'] | basename | split('.') | first }}.service ExecStart=/usr/bin/systemctl restart wg-quick@{{ wireguard_ui_combined_env['WGUI_CONFIG_FILE_PATH'] | basename | split('.') | first }}.service
[Install] [Install]
RequiredBy={{ wireguard_ui_watcher_systemd_path_unit_name }} RequiredBy={{ wireguard_ui_watcher_systemd_path_unit_name }}