2022-07-13 11:51:25 +00:00
|
|
|
- name: Install WireGuard UI with container
|
|
|
|
block:
|
|
|
|
- name: Login to image registries with podman
|
|
|
|
containers.podman.podman_login:
|
|
|
|
registry: '{{ item.key }}'
|
|
|
|
username: '{{ item.value.username }}'
|
|
|
|
password: '{{ item.value.password }}'
|
|
|
|
become: true
|
|
|
|
no_log: true
|
|
|
|
changed_when: False
|
|
|
|
loop: '{{ wireguard_ui_container_registry_auth | dict2items }}'
|
|
|
|
when: wireguard_ui_container_registry_auth is defined
|
|
|
|
|
2023-03-10 13:18:46 +00:00
|
|
|
- name: Create configuration dir and subdirs for WireGuard UI
|
2022-07-13 11:51:25 +00:00
|
|
|
file:
|
2023-03-10 13:18:46 +00:00
|
|
|
name: "{{ item }}"
|
2022-07-13 11:51:25 +00:00
|
|
|
state: directory
|
2023-03-10 13:18:46 +00:00
|
|
|
loop:
|
|
|
|
- "{{ wireguard_ui_config_dir }}"
|
|
|
|
- "{{ wireguard_ui_config_dir }}/server"
|
|
|
|
|
2024-03-31 22:56:18 +00:00
|
|
|
- name: Force login and password change for first admin user
|
2023-03-10 13:18:46 +00:00
|
|
|
template:
|
2024-03-31 22:56:18 +00:00
|
|
|
dest: "{{ wireguard_ui_config_dir }}/users/admin.json"
|
2023-03-10 13:18:46 +00:00
|
|
|
src: users.json.j2
|
|
|
|
register: wireguard_ui_auth
|
|
|
|
notify: Restart WireGuard UI with podman
|
2022-07-13 11:51:25 +00:00
|
|
|
|
|
|
|
- name: Create WireGuard UI with podman
|
|
|
|
containers.podman.podman_container:
|
|
|
|
name: "{{ wireguard_ui_container_name }}"
|
|
|
|
hostname: "{{ wireguard_ui_container_name }}"
|
|
|
|
network_mode: "{{ wireguard_ui_network_mode }}"
|
|
|
|
image: "{{ wireguard_ui_container_registry }}/{{ wireguard_ui_image_name }}:{{ wireguard_ui_image_tag }}"
|
|
|
|
state: created
|
2023-03-10 13:18:46 +00:00
|
|
|
cap_add:
|
|
|
|
- NET_ADMIN
|
2022-07-15 15:14:47 +00:00
|
|
|
env: "{{ wireguard_ui_combined_env }}"
|
2023-03-10 13:18:46 +00:00
|
|
|
volumes: "{{ wireguard_ui_volumes }}"
|
2022-07-13 11:51:25 +00:00
|
|
|
register: wireguard_ui_container
|
2022-07-13 18:31:50 +00:00
|
|
|
notify: Restart WireGuard UI with podman
|
2022-07-13 11:51:25 +00:00
|
|
|
|
|
|
|
- name: Generate container systemd unit
|
|
|
|
shell: "podman generate systemd {{ wireguard_ui_container_name }}"
|
|
|
|
register: wireguard_ui_systemd_unit
|
|
|
|
changed_when: False
|
|
|
|
|
|
|
|
- name: Create WireGuard UI systemd unit
|
|
|
|
copy:
|
|
|
|
dest: "/etc/systemd/system/{{ wireguard_ui_systemd_unit_name }}"
|
|
|
|
content: "{{ wireguard_ui_systemd_unit.stdout | regex_replace('^#.*', multiline=True) | trim }}"
|
|
|
|
|
|
|
|
- name: Create WireGuard UI systemd watcher unit
|
2022-07-13 12:31:37 +00:00
|
|
|
template:
|
2022-07-13 11:51:25 +00:00
|
|
|
dest: "/etc/systemd/system/{{ wireguard_ui_watcher_systemd_service_unit_name }}"
|
|
|
|
src: wireguard-ui-watcher.service.j2
|
|
|
|
|
|
|
|
- name: Create WireGuard UI systemd watcher path
|
2022-07-13 12:31:37 +00:00
|
|
|
template:
|
2022-07-13 11:51:25 +00:00
|
|
|
dest: "/etc/systemd/system/{{ wireguard_ui_watcher_systemd_path_unit_name }}"
|
|
|
|
src: wireguard-ui-watcher.path.j2
|
|
|
|
|
|
|
|
- name: Logout from image registries
|
|
|
|
containers.podman.podman_logout:
|
|
|
|
registry: '{{ item.key }}'
|
|
|
|
become: true
|
|
|
|
no_log: true
|
|
|
|
changed_when: False
|
|
|
|
loop: '{{ wireguard_ui_container_registry_auth | dict2items }}'
|
|
|
|
when: wireguard_ui_container_registry_auth is defined
|