From 5c7f5a24b3fa94fe8d25f38a3f3c4be846bce834 Mon Sep 17 00:00:00 2001 From: Anarion <2185791+anarion80@users.noreply.github.com> Date: Wed, 8 May 2024 17:33:56 +0200 Subject: [PATCH] :sparkles: Add n.eko (#127) * :sparkles: Add n.eko --- README.md | 1 + nas.yml | 4 ++ roles/neko/defaults/main.yml | 37 ++++++++++++ roles/neko/docs/neko.md | 11 ++++ roles/neko/molecule/default/molecule.yml | 6 ++ roles/neko/molecule/default/side_effect.yml | 10 ++++ roles/neko/molecule/default/verify.yml | 19 ++++++ .../neko/molecule/default/verify_stopped.yml | 19 ++++++ roles/neko/requirements.yml | 1 + roles/neko/tasks/main.yml | 59 +++++++++++++++++++ website/docs/applications/other/neko.md | 14 +++++ 11 files changed, 181 insertions(+) create mode 100644 roles/neko/defaults/main.yml create mode 100644 roles/neko/docs/neko.md create mode 100644 roles/neko/molecule/default/molecule.yml create mode 100644 roles/neko/molecule/default/side_effect.yml create mode 100644 roles/neko/molecule/default/verify.yml create mode 100644 roles/neko/molecule/default/verify_stopped.yml create mode 120000 roles/neko/requirements.yml create mode 100644 roles/neko/tasks/main.yml create mode 100644 website/docs/applications/other/neko.md diff --git a/README.md b/README.md index b0690decfb..7771327680 100644 --- a/README.md +++ b/README.md @@ -122,6 +122,7 @@ If you have a spare domain name you can configure applications to be accessible * [MySql](https://www.mysql.com/) - The world's most popular open source database * [n8n](https://n8n.io/) - Nodemation, a node based workflow and automation service like IFTTT. * [navidrome](https://www.navidrome.org/) - Modern Music Server and Streamer compatible with Subsonic/Airsonic +* [n.eko](https://github.com/m1k1o/neko/) - A self hosted virtual browser that runs in docker and uses WebRTC. * [netboot.xyz](https://netboot.xyz/) - a PXE boot server * [Netbox](https://netbox.dev/) - The premiere source of truth powering network automation * [Netdata](https://my-netdata.io/) - An extremely comprehensive system monitoring solution diff --git a/nas.yml b/nas.yml index f9b0d73cb6..105368906a 100644 --- a/nas.yml +++ b/nas.yml @@ -478,6 +478,10 @@ tags: - navidrome + - role: neko + tags: + - neko + - role: netbootxyz tags: - netbootxyz diff --git a/roles/neko/defaults/main.yml b/roles/neko/defaults/main.yml new file mode 100644 index 0000000000..ee31da64d5 --- /dev/null +++ b/roles/neko/defaults/main.yml @@ -0,0 +1,37 @@ +--- +neko_enabled: false +neko_available_externally: false + +# directories +neko_data_directory: "{{ docker_home }}/neko" + +# network +neko_port: "8137" +neko_port_epr: "52000-52100" +neko_hostname: "neko" + +# specs +neko_memory: 1g +neko_shm_size: 2G + +# docker +neko_container_name: neko +neko_image_name: "m1k1o/neko" +neko_image_version: chromium +neko_user_id: "1000" +neko_group_id: "1000" + +# neko +neko_screen: "1920x1080@30" +neko_password: neko +neko_password_admin: admin +neko_epr: "52000-52100" +neko_icelite: "true" +neko_file_transfer_enabled: "true" +neko_control_protection: "false" +neko_implicit_control: "false" +neko_locks: "control" +neko_video_codec: "vp8" +neko_audio_codec: "opus" +neko_broadcast_pipeline: "" +neko_nat1to1: "{{ hostvars[inventory_hostname]['ansible_default_ipv4']['address'] }}" diff --git a/roles/neko/docs/neko.md b/roles/neko/docs/neko.md new file mode 100644 index 0000000000..ec58efa9ee --- /dev/null +++ b/roles/neko/docs/neko.md @@ -0,0 +1,11 @@ +# n.eko + +Homepage: [https://github.com/m1k1o/neko/](https://github.com/m1k1o/neko/) + +A self hosted virtual browser that runs in docker and uses WebRTC. + +## Usage + +Set `neko_enabled: true` in your `inventories//group_vars/nas.yml` file. + +neko web interface can be found at [http://ansible_nas_host_or_ip:8137](http://ansible_nas_host_or_ip:8137). diff --git a/roles/neko/molecule/default/molecule.yml b/roles/neko/molecule/default/molecule.yml new file mode 100644 index 0000000000..2d966c48bd --- /dev/null +++ b/roles/neko/molecule/default/molecule.yml @@ -0,0 +1,6 @@ +--- +provisioner: + inventory: + group_vars: + all: + neko_enabled: true diff --git a/roles/neko/molecule/default/side_effect.yml b/roles/neko/molecule/default/side_effect.yml new file mode 100644 index 0000000000..fe601d535b --- /dev/null +++ b/roles/neko/molecule/default/side_effect.yml @@ -0,0 +1,10 @@ +--- +- name: Stop + hosts: all + become: true + tasks: + - name: "Include {{ lookup('env', 'MOLECULE_PROJECT_DIRECTORY') | basename }} role" + ansible.builtin.include_role: + name: "{{ lookup('env', 'MOLECULE_PROJECT_DIRECTORY') | basename }}" + vars: + neko_enabled: false diff --git a/roles/neko/molecule/default/verify.yml b/roles/neko/molecule/default/verify.yml new file mode 100644 index 0000000000..4eae3b2de7 --- /dev/null +++ b/roles/neko/molecule/default/verify.yml @@ -0,0 +1,19 @@ +--- +- name: Verify + hosts: all + gather_facts: false + tasks: + - name: Include vars + ansible.builtin.include_vars: + file: ../../defaults/main.yml + + - name: Get neko container state + community.docker.docker_container: + name: "{{ neko_container_name }}" + register: result + + - name: Check if neko containers are running + ansible.builtin.assert: + that: + - result.container['State']['Status'] == "running" + - result.container['State']['Restarting'] == false diff --git a/roles/neko/molecule/default/verify_stopped.yml b/roles/neko/molecule/default/verify_stopped.yml new file mode 100644 index 0000000000..46868ed704 --- /dev/null +++ b/roles/neko/molecule/default/verify_stopped.yml @@ -0,0 +1,19 @@ +--- +- name: Verify + hosts: all + gather_facts: false + tasks: + - name: Include vars + ansible.builtin.include_vars: + file: ../../defaults/main.yml + + - name: Try and stop and remove neko + community.docker.docker_container: + name: "{{ neko_container_name }}" + state: absent + register: result + + - name: Check if neko is stopped + ansible.builtin.assert: + that: + - not result.changed diff --git a/roles/neko/requirements.yml b/roles/neko/requirements.yml new file mode 120000 index 0000000000..9a736435ab --- /dev/null +++ b/roles/neko/requirements.yml @@ -0,0 +1 @@ +../../requirements.yml \ No newline at end of file diff --git a/roles/neko/tasks/main.yml b/roles/neko/tasks/main.yml new file mode 100644 index 0000000000..1845f20136 --- /dev/null +++ b/roles/neko/tasks/main.yml @@ -0,0 +1,59 @@ +--- +- name: Start neko + block: + - name: Create neko Directories + ansible.builtin.file: + path: "{{ item }}" + state: directory + with_items: + - "{{ neko_data_directory }}" + + - name: Create neko Docker Container + community.docker.docker_container: + container_default_behavior: no_defaults + name: "{{ neko_container_name }}" + image: "{{ neko_image_name }}:{{ neko_image_version }}" + pull: true + capabilities: SYS_ADMIN + volumes: + - "{{ neko_data_directory }}/data:/home/neko/Downloads" + - "{{ neko_data_directory }}/media:/media" + ports: + - "{{ neko_port }}:8080" + - "{{ neko_port_epr }}:52000-52100/udp" + env: + TZ: "{{ ansible_nas_timezone }}" + UID: "{{ neko_user_id | quote }}" + GID: "{{ neko_group_id | quote }}" + NEKO_SCREEN: "{{ neko_screen }}" + NEKO_PASSWORD: "{{ neko_password }}" + NEKO_PASSWORD_ADMIN: "{{ neko_password_admin }}" + NEKO_EPR: "{{ neko_epr }}" + NEKO_ICELITE: "{{ neko_icelite }}" + NEKO_FILE_TRANSFER_ENABLED: "{{ neko_file_transfer_enabled }}" + NEKO_CONTROL_PROTECTION: "{{ neko_control_protection }}" + NEKO_IMPLICIT_CONTROL: "{{ neko_implicit_control }}" + NEKO_LOCKS: "{{ neko_locks }}" + NEKO_VIDEO_CODEC: "{{ neko_video_codec }}" + NEKO_AUDIO_CODEC: "{{ neko_audio_codec }}" + NEKO_BROADCAST_PIPELINE: "{{ neko_broadcast_pipeline }}" + NEKO_NAT1TO1: "{{ neko_nat1to1 }}" + restart_policy: unless-stopped + memory: "{{ neko_memory }}" + shm_size: "{{ neko_shm_size }}" + labels: + traefik.enable: "{{ neko_available_externally | string }}" + traefik.http.routers.neko.rule: "Host(`{{ neko_hostname }}.{{ ansible_nas_domain }}`)" + traefik.http.routers.neko.tls.certresolver: "letsencrypt" + traefik.http.routers.neko.tls.domains[0].main: "{{ ansible_nas_domain }}" + traefik.http.routers.neko.tls.domains[0].sans: "*.{{ ansible_nas_domain }}" + traefik.http.services.neko.loadbalancer.server.port: "8080" + when: neko_enabled is true + +- name: Stop neko + block: + - name: Stop neko + community.docker.docker_container: + name: "{{ neko_container_name }}" + state: absent + when: neko_enabled is false diff --git a/website/docs/applications/other/neko.md b/website/docs/applications/other/neko.md new file mode 100644 index 0000000000..a3738e186c --- /dev/null +++ b/website/docs/applications/other/neko.md @@ -0,0 +1,14 @@ +--- +title: "n.eko" +description: "A self hosted virtual browser that runs in docker and uses WebRTC." +--- + +Homepage: [https://github.com/m1k1o/neko/](https://github.com/m1k1o/neko/) + +A self hosted virtual browser that runs in docker and uses WebRTC. + +## Usage + +Set `neko_enabled: true` in your `inventories//group_vars/nas.yml` file. + +neko web interface can be found at [http://ansible_nas_host_or_ip:8137](http://ansible_nas_host_or_ip:8137).