From 0b084785d02f4b8ee4a14c21b3ca8f98440c5488 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Miotk?= Date: Thu, 10 Oct 2024 12:58:24 +0200 Subject: [PATCH] Add DNF5 support (#31) --- .gitignore | 1 + README.md | 53 +- playbooks/generic.yml | 1 + playbooks/group_vars/all.yml | 3 + playbooks/group_vars/x86_64.yml | 11 +- playbooks/vms.yml | 14 +- .../tasks/get_latest_version.yml | 13 + .../tasks/install.yml | 29 ++ .../azure-functions-core-tools/tasks/main.yml | 3 + .../tasks/setup.yml | 18 + roles/apps/docker/tasks/repo.yml | 2 +- roles/apps/netcore_sdk/tasks/main.yml | 2 +- .../oh_my_zsh/templates/oh_my_zsh_zshrc.j2 | 4 +- roles/apps/vagrant/tasks/install_x86_64.yml | 2 +- roles/apps/vagrant/tasks/main.yml | 1 - .../vscode/files/work/.vscode/settings.json | 6 +- .../desktop/gnome/tasks/extensions_manual.yml | 22 + roles/desktop/gnome/tasks/gsettings.yml | 19 +- roles/desktop/gnome/tasks/main.yml | 1 + roles/pkg_mgmt/dnf/tasks/dnf5.yml | 23 + roles/pkg_mgmt/dnf/tasks/main.yml | 4 +- roles/pkg_mgmt/dnf/tasks/update.yml | 7 +- roles/servers/apps/frigate/config.yml | 481 +++++++++++++++++- roles/servers/apps/frigate/config_intel.yml | 26 + roles/servers/apps/frigate/docker-compose.yml | 46 +- .../apps/frigate/docker-compose_intel.yml | 37 ++ .../apps/home-assistant/defaults/main.yml | 15 +- .../apps/home-assistant/tasks/custom.yml | 17 +- .../apps/home-assistant/tasks/hacs.yml | 5 + .../templates/config/configuration.yaml | 2 + .../templates/config/dashboard-tesla.yaml | 8 + .../templates/config/ui-lovelace.yaml | 24 + roles/servers/apps/llama-docker/Dockerfile | 18 + .../llama-docker/config/litellm/config.yaml | 36 ++ .../apps/llama-docker/docker-compose copy.yml | 8 + .../apps/llama-docker/docker-compose.yml | 112 ++++ .../apps/nginx/templates/docker-compose.yml | 2 +- 37 files changed, 1016 insertions(+), 60 deletions(-) create mode 100644 roles/apps/azure-functions-core-tools/tasks/get_latest_version.yml create mode 100644 roles/apps/azure-functions-core-tools/tasks/install.yml create mode 100644 roles/apps/azure-functions-core-tools/tasks/main.yml create mode 100644 roles/apps/azure-functions-core-tools/tasks/setup.yml create mode 100644 roles/pkg_mgmt/dnf/tasks/dnf5.yml create mode 100644 roles/servers/apps/frigate/config_intel.yml create mode 100644 roles/servers/apps/frigate/docker-compose_intel.yml create mode 100644 roles/servers/apps/home-assistant/tasks/hacs.yml create mode 100644 roles/servers/apps/llama-docker/Dockerfile create mode 100644 roles/servers/apps/llama-docker/config/litellm/config.yaml create mode 100644 roles/servers/apps/llama-docker/docker-compose copy.yml create mode 100644 roles/servers/apps/llama-docker/docker-compose.yml diff --git a/.gitignore b/.gitignore index 4a96db2c..4f0aa721 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ *.retry .vagrant +playbooks/dnf5 diff --git a/README.md b/README.md index 7e0ff8f0..bb392545 100644 --- a/README.md +++ b/README.md @@ -337,6 +337,7 @@ Contributions are what make the open source community such an amazing place to b - ```bash + ### Install using .run installer (manually) ### # Install DKMS to automatically install Nvidia driver when updating kernel dnf install dkms kernel-devel kernel-headers gcc make acpid libglvnd-glx libglvnd-opengl libglvnd-devel pkgconfig vdpauinfo libva-vdpau-driver libva-utils @@ -388,7 +389,45 @@ Contributions are what make the open source community such an amazing place to b # If you fail to boot to Fedora, you can edit boot entry in grub by clicking "e" in grub bootmenu and in line starting with "linux ..." add at the end "init 3" to boot in multi-user.target (without graphical interface) # If you are using Secure Boot, during installation of the NVIDIA drivers create new key pair (or use existing one), and if it's a new key pair then add them to UEFI key by executing - mokutil --import /usr/share/nvidia/nvidia-modsign-crt-${id}.der + + mkdir -p /usr/share/uefimok/ + cp -rfv /usr/share/nvidia/nvidia-modsign-crt-${id}.der /usr/share/uefimok/ + cp -rfv /usr/share/nvidia/nvidia-modsign-key-${id}.key /usr/share/uefimok/ + + mokutil --import /usr/share/uefimok/nvidia-modsign-crt-${id}.der + + bash NVIDIA-Linux-x86_64-550.107.02.run --module-signing-secret-key=/usr/share/uefimok/nvidia-modsign-key-${id}.key --module-signing-public-key=/usr/share/uefimok/nvidia-modsign-crt-${id}.der + + ### Install using packages from CUDA rpm repository ### + + # Check latest available rpm repo (fedora40 is not available) - https://developer.download.nvidia.com/compute/cuda/repos/ + distro=fedora39 + + dnf config-manager --add-repo https://developer.download.nvidia.com/compute/cuda/repos/$distro/x86_64/cuda-$distro.repo + dnf -y install dkms + dnf -y module install nvidia-driver:open-dkms + dnf -y install nvidia-container-toolkit + + # Make sure you're running desktop in X11 mode, wayland is a bit laggy still + # xorg.conf can be generated from nvidia-settings + + # Enroll MOK key if you're using SecureBoot + ## You can check by which key the kernel module is signed by, by executing: modinfo nvidia-drm, and then try to find it locally (i.e.: in dkms config file) + mokutil --import /var/lib/dkms/mok.pub + + ### Enabling wayland + + ## vi /etc/dracut.conf.d/nvidia.conf + force_drivers+=" nvidia nvidia_modeset nvidia_uvm nvidia_drm " + + ## vi /etc/modprobe.d/nvidia.conf + options nvidia_drm modeset=1 fbdev=1 + + ## + + mv /usr/lib/udev/rules.d/61-gdm.rules /root/61-gdm.rules + dracut -f + ``` 12. To fix purple'ish screen, enable OC and Fan control (I recommend to use GreenWithEnvy - gwe (installed using flatpak)) apply those changes to `/etc/X11/xorg.conf`: @@ -480,6 +519,18 @@ flatpak override com.valvesoftware.Steam --filesystem=${PATH_TO_FILESYSTEM} 18. Terminator fails to open with an error `terminator:24::ModuleNotFoundError: No module named 'psutil'`, try reinstalling `dnf reinstall python3-psutil` to fix it +19. Enable tabs scrolling in firefox: + +``` +### about:config + +# tabs mouse scrolling +toolkit.tabbox.switchByScrolling = true + +# if google docs crashes, page jumps +gfx.canvas.accelerated = false +``` + ## License diff --git a/playbooks/generic.yml b/playbooks/generic.yml index 816bfeab..a1b29e26 100644 --- a/playbooks/generic.yml +++ b/playbooks/generic.yml @@ -21,3 +21,4 @@ - apps/terraform - apps/terragrunt - apps/terraform-docs + - apps/azure-functions-core-tools diff --git a/playbooks/group_vars/all.yml b/playbooks/group_vars/all.yml index a84d0df6..e1b1ff66 100644 --- a/playbooks/group_vars/all.yml +++ b/playbooks/group_vars/all.yml @@ -84,6 +84,8 @@ dnf_gui_pkgs: - vlc - wireshark +dnf_extra_pkgs: [] + snap_apps: [] snap_classic_apps: [] @@ -167,6 +169,7 @@ vscode_extensions: - eamodio.gitlens - hashicorp.terraform - hediet.vscode-drawio + - mhutchie.git-graph - ms-azure-devops.azure-pipelines - ms-azuretools.vscode-docker - ms-dotnettools.csharp diff --git a/playbooks/group_vars/x86_64.yml b/playbooks/group_vars/x86_64.yml index e424608f..6803c487 100644 --- a/playbooks/group_vars/x86_64.yml +++ b/playbooks/group_vars/x86_64.yml @@ -4,8 +4,8 @@ architecture_common_name: "amd64" # Flatpak is better for GUI applications flatpak_apps: - # - name: com.valvesoftware.Steam - # remote: flathub + - name: com.valvesoftware.Steam + remote: flathub # - name: com.skype.Client # remote: flathub # - name: org.signal.Signal @@ -18,8 +18,15 @@ flatpak_apps: remote: flathub - name: com.discordapp.Discord remote: flathub + - name: com.mastermindzh.tidal-hifi + remote: flathub + - name: com.leinardi.gwe + remote: flathub # https://github.com/ishantanu/awesome-kubectl-plugins krew_plugins: - sniff - hns + +dnf_extra_pkgs: + - steam-devices diff --git a/playbooks/vms.yml b/playbooks/vms.yml index 094917a5..9cf9d353 100644 --- a/playbooks/vms.yml +++ b/playbooks/vms.yml @@ -8,11 +8,11 @@ hosts: clevo become: true tasks: - - name: Upgrade all packages - ansible.builtin.dnf: - name: "*" - state: latest - update_cache: true + # - name: Clean DNF + # shell: dnf clean all + + - import_tasks: roles/pkg_mgmt/dnf/tasks/dnf5.yml + - import_tasks: roles/pkg_mgmt/dnf/tasks/update.yml - name: Check if reboot required stat: @@ -26,10 +26,6 @@ - reboot_required_file.stat.exists == true - inventory_hostname != "mikeeClevo" - - name: Autoremove unneeded packages installed as dependencies - ansible.builtin.dnf: - autoremove: yes - - name: Set variables on an imported playbook ansible.builtin.import_playbook: generic-core.yml vars: diff --git a/roles/apps/azure-functions-core-tools/tasks/get_latest_version.yml b/roles/apps/azure-functions-core-tools/tasks/get_latest_version.yml new file mode 100644 index 00000000..7e489a5c --- /dev/null +++ b/roles/apps/azure-functions-core-tools/tasks/get_latest_version.yml @@ -0,0 +1,13 @@ +--- +- name: Get latest version azure_functions_core_tools + shell: curl -Is https://github.com/Azure/azure-functions-core-tools/releases/latest | grep -i 'location:' | rev | cut -d'/' -f1 | rev + register: version + changed_when: false + +- name: "Latest version of azure_functions_core_tools:" + debug: + var: version.stdout + +- name: "Set fact with latest version of azure_functions_core_tools" + set_fact: + azure_functions_core_tools_version: "{{ version.stdout }}" diff --git a/roles/apps/azure-functions-core-tools/tasks/install.yml b/roles/apps/azure-functions-core-tools/tasks/install.yml new file mode 100644 index 00000000..4e14066e --- /dev/null +++ b/roles/apps/azure-functions-core-tools/tasks/install.yml @@ -0,0 +1,29 @@ +--- +- name: Directory for azure_functions_core_tools + file: + path: "{{ item }}" + state: directory + loop: + - "/tmp/azure_functions_core_tools" + - "/opt/azure_functions_core_tools" + +- name: Download azure_functions_core_tools binary + get_url: + url: "https://github.com/Azure/azure-functions-core-tools/releases/download/{{ azure_functions_core_tools_version }}/Azure.Functions.Cli.linux-x64.{{ azure_functions_core_tools_version }}.zip" + dest: /tmp/azure_functions_core_tools/azure_functions_core_tools.zip + +- name: Unarchive a file that is already on the remote machine + unarchive: + src: /tmp/azure_functions_core_tools/azure_functions_core_tools.zip + dest: /opt/azure_functions_core_tools + remote_src: yes + +- name: Set executable permissions + file: + path: "/opt/azure_functions_core_tools/{{ item }}" + mode: 0755 + owner: root + group: root + loop: + - func + - gozip diff --git a/roles/apps/azure-functions-core-tools/tasks/main.yml b/roles/apps/azure-functions-core-tools/tasks/main.yml new file mode 100644 index 00000000..1351b20a --- /dev/null +++ b/roles/apps/azure-functions-core-tools/tasks/main.yml @@ -0,0 +1,3 @@ +--- +- include_tasks: setup.yml + when: ansible_architecture == "x86_64" diff --git a/roles/apps/azure-functions-core-tools/tasks/setup.yml b/roles/apps/azure-functions-core-tools/tasks/setup.yml new file mode 100644 index 00000000..26b02a9d --- /dev/null +++ b/roles/apps/azure-functions-core-tools/tasks/setup.yml @@ -0,0 +1,18 @@ +--- +- name: Get installed version of azure_functions_core_tools + become: true + become_user: "{{ user_name }}" + shell: /opt/azure_functions_core_tools/func --version + register: installed_azure_functions_core_tools_version + changed_when: false + ignore_errors: true + +- name: "Installed version of azure_functions_core_tools:" + debug: + var: installed_azure_functions_core_tools_version.stdout + +- include_tasks: get_latest_version.yml + when: azure_functions_core_tools_version is not defined + +- include_tasks: install.yml + when: installed_azure_functions_core_tools_version.stdout != azure_functions_core_tools_version diff --git a/roles/apps/docker/tasks/repo.yml b/roles/apps/docker/tasks/repo.yml index d44a6303..c37455d0 100644 --- a/roles/apps/docker/tasks/repo.yml +++ b/roles/apps/docker/tasks/repo.yml @@ -20,5 +20,5 @@ ansible.builtin.replace: path: /etc/yum.repos.d/docker-ce.repo regexp: '\$releasever' - replace: '36' + replace: '40' when: releasever_check.stdout == "rawhide" diff --git a/roles/apps/netcore_sdk/tasks/main.yml b/roles/apps/netcore_sdk/tasks/main.yml index 4079ef3e..787129f4 100644 --- a/roles/apps/netcore_sdk/tasks/main.yml +++ b/roles/apps/netcore_sdk/tasks/main.yml @@ -4,5 +4,5 @@ - name: netcore sdk package: - name: "dotnet-sdk-6.0" + name: "dotnet-sdk-8.0" state: present diff --git a/roles/apps/oh_my_zsh/templates/oh_my_zsh_zshrc.j2 b/roles/apps/oh_my_zsh/templates/oh_my_zsh_zshrc.j2 index 624a22c3..0e5f6463 100644 --- a/roles/apps/oh_my_zsh/templates/oh_my_zsh_zshrc.j2 +++ b/roles/apps/oh_my_zsh/templates/oh_my_zsh_zshrc.j2 @@ -17,6 +17,8 @@ plugins=( ansible fzf dnf + z + colored-man-pages {% if item != 'root' %} vscode terraform @@ -29,7 +31,7 @@ plugins=( source $ZSH/oh-my-zsh.sh {% if item != 'root' %} -export PATH="${KREW_ROOT:-$HOME/.krew}/bin:$HOME/.cargo/bin:$PATH" +export PATH="${KREW_ROOT:-$HOME/.krew}/bin:$HOME/.cargo/bin:/opt/azure_functions_core_tools:$PATH" {% endif %} # Extracting Dockerfile from image diff --git a/roles/apps/vagrant/tasks/install_x86_64.yml b/roles/apps/vagrant/tasks/install_x86_64.yml index 4ad193f8..64016505 100644 --- a/roles/apps/vagrant/tasks/install_x86_64.yml +++ b/roles/apps/vagrant/tasks/install_x86_64.yml @@ -26,7 +26,7 @@ when: vagrant_version is not defined # name: "https://releases.hashicorp.com/vagrant/{{ version.stdout }}/vagrant_{{ version.stdout }}_x86_64.rpm" -- name: Install vagrant from hashcorp repo +- name: Install vagrant from hashicorp repo dnf: name: "https://releases.hashicorp.com/vagrant/{{ version.stdout }}/vagrant-{{ version.stdout }}-1.x86_64.rpm" state: latest diff --git a/roles/apps/vagrant/tasks/main.yml b/roles/apps/vagrant/tasks/main.yml index 8134eeee..28cacbf1 100644 --- a/roles/apps/vagrant/tasks/main.yml +++ b/roles/apps/vagrant/tasks/main.yml @@ -1,4 +1,3 @@ --- # Vagrant is not available for arm64 linux. - include_tasks: install.yml - # when: ansible_architecture == "x86_64" diff --git a/roles/desktop/apps/vscode/files/work/.vscode/settings.json b/roles/desktop/apps/vscode/files/work/.vscode/settings.json index 94d6c190..bf0f95db 100644 --- a/roles/desktop/apps/vscode/files/work/.vscode/settings.json +++ b/roles/desktop/apps/vscode/files/work/.vscode/settings.json @@ -1,4 +1,6 @@ // path .vscode/settings.json +// sudo /bin/bash -c "echo \"$(whereis -b firefox | awk '{print $2}') -P WORK \\\"\\\$@\\\" \" > \"$(whereis -b firefox | awk '{print $2}')_WORK\"" +// sudo chmod +x $(whereis -b firefox | awk '{print $2}')_WORK { "terminal.integrated.defaultProfile.linux": "zshWORK_VAR", "terminal.integrated.profiles.linux" :{ @@ -23,5 +25,7 @@ "/home/mikee/.work_profiles/WORK_VAR/.kube/config" ], "vs-kubernetes.kubeconfig": "/home/mikee/.work_profiles/WORK_VAR/.kube/config" - } + }, + "ansible.python.interpreterPath": "/bin/python", + "workbench.externalBrowser": "firefox_WORK" } diff --git a/roles/desktop/gnome/tasks/extensions_manual.yml b/roles/desktop/gnome/tasks/extensions_manual.yml index 1956bba1..d357d191 100644 --- a/roles/desktop/gnome/tasks/extensions_manual.yml +++ b/roles/desktop/gnome/tasks/extensions_manual.yml @@ -79,6 +79,28 @@ label: "{{ item.item.item.json.name }}" when: not item is skipped + - name: Generate schemas Gnome Shell extensions + become: true + become_user: "{{ user_name }}" + shell: glib-compile-schemas . + args: + chdir: ~/.local/share/gnome-shell/extensions/{{ item.item.item.json.uuid }}/schemas + loop: "{{ download_gnome_shell_extensions.results }}" + loop_control: + label: "{{ item.item.item.json.name }}" + when: not item is skipped + register: gnome_shell_extension_info + + - name: Enable Gnome Shell extensions + become: true + become_user: "{{ user_name }}" + shell: gnome-extensions enable "{{ item.item.item.json.uuid }}" + loop: "{{ download_gnome_shell_extensions.results }}" + loop_control: + label: "{{ item.item.item.json.name }}" + when: not item is skipped + register: gnome_shell_extension_info + # - name: Enable Gnome Shell extensions # become: true # become_user: "{{ user_name }}" diff --git a/roles/desktop/gnome/tasks/gsettings.yml b/roles/desktop/gnome/tasks/gsettings.yml index a20b62d5..ac9b00ee 100644 --- a/roles/desktop/gnome/tasks/gsettings.yml +++ b/roles/desktop/gnome/tasks/gsettings.yml @@ -59,7 +59,7 @@ become_user: "{{ user_name }}" dconf: key: "/org/gnome/shell/favorite-apps" - value: "['google-chrome.desktop', 'firefox.desktop', 'terminator.desktop', 'code.desktop', 'com.discordapp.Discord.desktop', 'com.slack.Slack.desktop', 'com.skype.Client.desktop', 'keeweb.desktop', 'com.spotify.Client.desktop', 'org.gnome.Nautilus.desktop', 'org.gnome.Software.desktop', 'org.gnome.tweaks.desktop', 'gnome-control-center.desktop']" + value: "['firefox.desktop', 'terminator.desktop', 'code.desktop', 'com.discordapp.Discord.desktop', 'com.slack.Slack.desktop', 'com.skype.Client.desktop', 'keeweb.desktop', 'com.spotify.Client.desktop', 'org.gnome.Nautilus.desktop', 'org.gnome.Software.desktop', 'org.gnome.tweaks.desktop', 'gnome-control-center.desktop']" state: present # Alternate-tab is deprecated in Fedora 30 @@ -180,6 +180,23 @@ value: "false" state: present +- name: "Disable workspaces only on primary screen" + become: true + become_user: "{{ user_name }}" + dconf: + key: "/org/gnome/mutter/workspaces-only-on-primary" + value: "false" + state: present + +- name: "Set color-scheme to dark" + become: true + become_user: "{{ user_name }}" + dconf: + key: "/org/gnome/desktop/interface/color-scheme" + value: "'prefer-dark'" + state: present + + # - name: "dash-to-dock position" # become: true # become_user: "{{ user_name }}" diff --git a/roles/desktop/gnome/tasks/main.yml b/roles/desktop/gnome/tasks/main.yml index dd2a9438..a957efe0 100644 --- a/roles/desktop/gnome/tasks/main.yml +++ b/roles/desktop/gnome/tasks/main.yml @@ -3,4 +3,5 @@ - import_tasks: gsettings.yml - import_tasks: extensions_manual.yml +# - import_tasks: extensions.yml - import_tasks: remote_desktop.yml diff --git a/roles/pkg_mgmt/dnf/tasks/dnf5.yml b/roles/pkg_mgmt/dnf/tasks/dnf5.yml new file mode 100644 index 00000000..e90696be --- /dev/null +++ b/roles/pkg_mgmt/dnf/tasks/dnf5.yml @@ -0,0 +1,23 @@ +--- +- name: Check dnf symlink target + stat: + path: /usr/bin/dnf + register: dnf_symlink + +# - debug: +# var: dnf_symlink + +- name: Install dnf5 + dnf: + name: ["dnf5", "python3-libdnf5"] + state: present + # when: dnf_symlink.stat.lnk_target == "dnf-3" + +- name: Create a symbolic link + ansible.builtin.file: + src: /usr/bin/dnf + dest: dnf5 + owner: root + group: root + state: link + # when: dnf_symlink.stat.lnk_target == "dnf-3" diff --git a/roles/pkg_mgmt/dnf/tasks/main.yml b/roles/pkg_mgmt/dnf/tasks/main.yml index 6967aedd..4921db79 100644 --- a/roles/pkg_mgmt/dnf/tasks/main.yml +++ b/roles/pkg_mgmt/dnf/tasks/main.yml @@ -1,14 +1,16 @@ --- +- import_tasks: dnf5.yml - import_tasks: repos.yml - name: "[DNF] Install Apps" - dnf: + dnf5: name: "{{ item }}" state: present with_items: - "[{{ generic_pkgs }}]" - "[{{ dnf_pkgs }}]" - "[{{ dnf_gui_pkgs }}]" + - "[{{ dnf_extra_pkgs }}]" - import_tasks: update.yml tags: diff --git a/roles/pkg_mgmt/dnf/tasks/update.yml b/roles/pkg_mgmt/dnf/tasks/update.yml index 426be26f..399f4af0 100644 --- a/roles/pkg_mgmt/dnf/tasks/update.yml +++ b/roles/pkg_mgmt/dnf/tasks/update.yml @@ -1,7 +1,12 @@ --- - name: "[DNF] Update all packages" - dnf: + dnf5: name: "*" state: latest + update_cache: true tags: - update + +- name: Autoremove unneeded packages installed as dependencies + ansible.builtin.dnf5: + autoremove: yes diff --git a/roles/servers/apps/frigate/config.yml b/roles/servers/apps/frigate/config.yml index 845f614b..b9822df2 100644 --- a/roles/servers/apps/frigate/config.yml +++ b/roles/servers/apps/frigate/config.yml @@ -1,26 +1,477 @@ --- +# https://docs.frigate.video/configuration/reference/ mqtt: - host: 192.168.1.20 + host: 192.168.1.22 + port: 1883 user: mqtt password: password + +database: + path: /db/frigate.db + + +ffmpeg: + hwaccel_args: preset-nvidia-h264 + output_args: + record: -f segment -segment_time 10 -segment_format mp4 -reset_timestamps 1 -strftime + 1 -c:v copy -c:a aac + +detectors: + tensorrt: + type: tensorrt + device: 0 #This is the default, select the first GPU + +model: + path: /config/model_cache/tensorrt/8.5.3/yolov7-320.trt + input_tensor: nchw + input_pixel_format: rgb + width: 320 + height: 320 + +record: + enabled: True + retain: + days: 3 + mode: all + events: + retain: + default: 30 + mode: motion + +# audio: +# enabled: true +# listen: +# - bark +# - speech + +objects: + # Optional: list of objects to track from labelmap.txt (default: shown below) + track: + - person + - bicycle + - car + - motorcycle + - bus + - bird + - cat + - dog + - cell phone + - bear + +# person: 15 +# bicycle: 15 +# car: 10 +# motorcycle: 10 +# bus: 7 +# bird: 7 +# cat: 7 +# dog: 7 +# cell phone: 15 + +snapshots: + # Optional: Enable writing jpg snapshot to /media/frigate/clips (default: shown below) + # This value can be set via MQTT and will be updated in startup based on retained value + enabled: true + # Optional: print a timestamp on the snapshots (default: shown below) + timestamp: false + # Optional: draw bounding box on the snapshots (default: shown below) + bounding_box: false + # Optional: crop the snapshot (default: shown below) + crop: false + # Optional: height to resize the snapshot to (default: original size) + #height: 175 + # Optional: Restrict snapshots to objects that entered any of the listed zones (default: no required zones) + #required_zones: [] + # Optional: Camera override for retention settings (default: global values) + retain: + # Required: Default retention days (default: shown below) + default: 7 + # Optional: Per object retention days + objects: + person: 14 + +birdseye: + enabled: true + mode: continuous + +# cameras: +# # Required: name of the camera +# Annke79: +# mqtt: +# timestamp: false +# bounding_box: false +# crop: true +# quality: 100 +# height: 500 +# # Required: ffmpeg settings for the camera +# ffmpeg: +# # Required: A list of input streams for the camera. See documentation for more information. +# #hwaccel_args: preset-nvidia-h265 +# inputs: +# # Required: the path to the stream +# # NOTE: path may include environment variables, which must begin with 'FRIGATE_' and be referenced in {} +# - path: rtsp://user:pass@192.168.0.79:554/Streaming/Channels/102 +# roles: +# - detect +# - rtmp +# - path: rtsp://user:pass@192.168.0.79:554/Streaming/Channels/101 +# roles: +# - record +# #fps: 9 +# #width: 1920 +# #height: 1080 +# motion: +# mask: [] +# objects: +# track: +# - person +# - bicycle +# - car +# - motorcycle +# - bus +# - bird +# - cat +# - dog +# record: +# enabled: true +# retain: +# days: 15 +# mode: motion +# events: +# pre_capture: 5 +# post_capture: 60 +# #objects: +# # - person +# retain: +# default: 15 +# mode: active_objects +# objects: +# person: 15 +# bicycle: 15 +# car: 10 +# motorcycle: 10 +# bus: 7 +# bird: 7 +# cat: 7 +# dog: 7 +# cell phone: 15 +# detect: +# stationary: +# interval: 50 #interval is defined as the frequency for running detection on stationary objects. +# threshold: 50 #threshold is the number of frames an object needs to remain relatively still before it is considered stationary. +# # Optional: width of the frame for the input with the detect role (default: shown below) +# width: 1200 +# # Optional: height of the frame for the input with the detect role (default: shown below) +# height: 636 +# # Optional: desired fps for your camera for the input with the detect role (default: shown below) +# # NOTE: Recommended value of 5. Ideally, try and reduce your FPS on the camera. +# fps: 10 +# # Optional: enables detection for the camera (default: True) +# # This value can be set via MQTT and will be updated in startup based on retained value +# enabled: true +# # Optional: Number of frames without a detection before frigate considers an object to be gone. (default: 5x the frame rate) +# #max_disappeared: 25 +# # Optional: Configuration for stationary object tracking +# #stationary: +# # Optional: Frequency for confirming stationary objects (default: shown below) +# # When set to 0, object detection will not confirm stationary objects until movement is detected. +# # If set to 10, object detection will run to confirm the object still exists on every 10th frame. +# #interval: 0 +# # Optional: Number of frames without a position change for an object to be considered stationary (default: 10x the frame rate or 10s) +# #threshold: 50 +# # Optional: Define a maximum number of frames for tracking a stationary object (default: not set, track forever) +# # This can help with false positives for objects that should only be stationary for a limited amount of time. +# # It can also be used to disable stationary object tracking. For example, you may want to set a value for person, but leave +# # car at the default. +# # WARNING: Setting these values overrides default behavior and disables stationary object tracking. +# # There are very few situations where you would want it disabled. It is NOT recommended to +# # copy these values from the example config into your config unless you know they are needed. +# #max_frames: +# # Optional: Default for all object types (default: not set, track forever) +# # default: 3000 +# # Optional: Object specific values +# #objects: +# # person: 1000 + + + +# dahua81: +# mqtt: +# timestamp: false +# bounding_box: false +# crop: true +# quality: 100 +# height: 500 +# # Required: ffmpeg settings for the camera +# ffmpeg: +# # Required: A list of input streams for the camera. See documentation for more information. +# inputs: +# # Required: the path to the stream +# # NOTE: path may include environment variables, which must begin with 'FRIGATE_' and be referenced in {} +# - path: rtsp://user:pass@192.168.0.81:554/cam/realmonitor?channel=1&subtype=2 +# roles: +# - detect +# - rtmp +# - path: rtsp://user:pass@192.168.0.81:554/live +# roles: +# - record + +# #fps: 9 +# #width: 1920 +# #height: 1080 +# motion: +# mask: +# - 1430,85,1439,31,1859,34,1865,86 +# objects: +# track: +# - person +# - bicycle +# - car +# - motorcycle +# - bus +# - bird +# - cat +# - dog +# - cell phone +# record: +# enabled: true +# retain: +# days: 15 +# mode: motion +# events: +# pre_capture: 5 +# post_capture: 60 +# #objects: +# # - person +# retain: +# default: 15 +# mode: active_objects +# objects: +# person: 15 +# bicycle: 15 +# car: 10 +# motorcycle: 10 +# bus: 7 +# bird: 7 +# cat: 7 +# dog: 7 +# cell phone: 15 + +# detect: +# stationary: +# interval: 50 #interval is defined as the frequency for running detection on stationary objects. +# threshold: 50 #threshold is the number of frames an object needs to remain relatively still before it is considered stationary. # Optional: width of the frame for the input with the detect role (default: shown below) +# width: 1920 +# # Optional: height of the frame for the input with the detect role (default: shown below) +# height: 1080 +# # Optional: desired fps for your camera for the input with the detect role (default: shown below) +# # NOTE: Recommended value of 5. Ideally, try and reduce your FPS on the camera. +# fps: 6 +# # Optional: enables detection for the camera (default: True) +# # This value can be set via MQTT and will be updated in startup based on retained value +# enabled: true +# # Optional: Number of frames without a detection before frigate considers an object to be gone. (default: 5x the frame rate) +# #max_disappeared: 25 +# # Optional: Configuration for stationary object tracking +# #stationary: +# # Optional: Frequency for confirming stationary objects (default: shown below) +# # When set to 0, object detection will not confirm stationary objects until movement is detected. +# # If set to 10, object detection will run to confirm the object still exists on every 10th frame. +# #interval: 0 +# # Optional: Number of frames without a position change for an object to be considered stationary (default: 10x the frame rate or 10s) +# #threshold: 50 +# # Optional: Define a maximum number of frames for tracking a stationary object (default: not set, track forever) +# # This can help with false positives for objects that should only be stationary for a limited amount of time. +# # It can also be used to disable stationary object tracking. For example, you may want to set a value for person, but leave +# # car at the default. +# # WARNING: Setting these values overrides default behavior and disables stationary object tracking. +# # There are very few situations where you would want it disabled. It is NOT recommended to +# # copy these values from the example config into your config unless you know they are needed. +# #max_frames: +# # Optional: Default for all object types (default: not set, track forever) +# # default: 3000 +# # Optional: Object specific values +# #objects: +# # person: 1000 + + + + +# dahua82: +# mqtt: +# timestamp: false +# bounding_box: false +# crop: true +# quality: 100 +# height: 500 +# # Required: ffmpeg settings for the camera +# ffmpeg: +# # Required: A list of input streams for the camera. See documentation for more information. +# inputs: +# # Required: the path to the stream +# # NOTE: path may include environment variables, which must begin with 'FRIGATE_' and be referenced in {} +# - path: rtsp://user:pass@192.168.0.82:554/cam/realmonitor?channel=1&subtype=2 +# roles: +# - detect +# - rtmp +# - path: rtsp://user:pass@192.168.0.82:554/live +# roles: +# - record + +# #fps: 9 +# #width: 1920 +# #height: 1080 +# motion: +# mask: +# - 1430,85,1439,31,1859,34,1865,86 +# objects: +# track: +# - person +# - bicycle +# - car +# - motorcycle +# - bus +# - bird +# - cat +# - dog +# record: +# enabled: true +# retain: +# days: 15 +# mode: motion +# events: +# pre_capture: 5 +# post_capture: 60 +# #objects: +# # - person +# retain: +# default: 15 +# mode: active_objects +# objects: +# person: 15 +# bicycle: 15 +# car: 10 +# motorcycle: 10 +# bus: 7 +# bird: 7 +# cat: 7 +# dog: 7 +# cell phone: 15 +# detect: +# stationary: +# interval: 50 #interval is defined as the frequency for running detection on stationary objects. +# threshold: 50 #threshold is the number of frames an object needs to remain relatively still before it is considered stationary. # Optional: width of the frame for the input with the detect role (default: shown below) +# width: 1920 +# # Optional: height of the frame for the input with the detect role (default: shown below) +# height: 1080 +# # Optional: desired fps for your camera for the input with the detect role (default: shown below) +# # NOTE: Recommended value of 5. Ideally, try and reduce your FPS on the camera. +# fps: 6 +# # Optional: enables detection for the camera (default: True) +# # This value can be set via MQTT and will be updated in startup based on retained value +# enabled: true +# # Optional: Number of frames without a detection before frigate considers an object to be gone. (default: 5x the frame rate) +# #max_disappeared: 25 +# # Optional: Configuration for stationary object tracking +# #stationary: +# # Optional: Frequency for confirming stationary objects (default: shown below) +# # When set to 0, object detection will not confirm stationary objects until movement is detected. +# # If set to 10, object detection will run to confirm the object still exists on every 10th frame. +# #interval: 0 +# # Optional: Number of frames without a position change for an object to be considered stationary (default: 10x the frame rate or 10s) +# #threshold: 50 +# # Optional: Define a maximum number of frames for tracking a stationary object (default: not set, track forever) +# # This can help with false positives for objects that should only be stationary for a limited amount of time. +# # It can also be used to disable stationary object tracking. For example, you may want to set a value for person, but leave +# # car at the default. +# # WARNING: Setting these values overrides default behavior and disables stationary object tracking. +# # There are very few situations where you would want it disabled. It is NOT recommended to +# # copy these values from the example config into your config unless you know they are needed. +# #max_frames: +# # Optional: Default for all object types (default: not set, track forever) +# # default: 3000 +# # Optional: Object specific values +# #objects: +# version: 0.14 +version: 0.14 + +go2rtc: + streams: + reolink_doorbell_restream: + - "ffmpeg:http://192.168.1.58/flv?port=1935&app=bcs&stream=channel0_main.bcs&user=admin&password=password#video=copy#audio=copy#audio=opus" + - rtsp://admin:password@192.168.1.58/Preview_01_sub + # - "http://192.168.1.58/flv?port=1935&app=bcs&stream=channel0_main.bcs&user=admin&password=password#video=copy#audio=copy#audio=opus" + reolink_doorbell_restream_sub: + - "ffmpeg:http://192.168.1.58/flv?port=1935&app=bcs&stream=channel0_ext.bcs&user=admin&password=password" + # - "http://192.168.1.58/flv?port=1935&app=bcs&stream=channel0_ext.bcs&user=admin&password=password" + yi_hack: rtsp://192.168.1.52:554/ch0_0.h264 + yi_hack_sub: rtsp://192.168.1.52:554/ch0_1.h264 + # front_door_camera: + # - rtsp://{FRIGATE_RTSP_USER}:{FRIGATE_RTSP_PASSWORD}@192.168.86.11:554/Preview_01_main#backchannel=0 + # - rtsp://{FRIGATE_RTSP_USER}:{FRIGATE_RTSP_PASSWORD}@192.168.86.11:554/Preview_01_sub + # - ffmpeg:front_door_camera#audio=opus#hardware + # front_door_camera_sub: + # - rtsp://{FRIGATE_RTSP_USER}:{FRIGATE_RTSP_PASSWORD}@192.168.86.11:554/Preview_01_sub + # - ffmpeg:front_door_camera_sub#audio=opus#hardware + webrtc: + candidates: + - 192.168.4.20:8555 + - stun:8555 cameras: - kuchnia: # <------ Name the camera + reolink_doorbell: + enabled: true ffmpeg: - hwaccel_args: - - -hwaccel - - vaapi - - -hwaccel_device - - /dev/dri/renderD128 - - -hwaccel_output_format - - yuv420p inputs: - - path: rtsp://192.168.1.52:554/ch0_0.h264 # <----- Update for your camera + - path: rtsp://127.0.0.1:8554/reolink_doorbell_restream + input_args: preset-rtsp-restream + roles: + - record + - path: rtsp://127.0.0.1:8554/reolink_doorbell_restream_sub + input_args: preset-rtsp-restream roles: - detect - - rtmp - rtmp: - enabled: False # <-- RTMP should be disabled if your stream is not H264 detect: - width: 1280 # <---- update for your camera's resolution - height: 720 # <---- update for your camera's resolution + enabled: true + width: 640 + height: 360 + fps: 30 + record: + enabled: true + snapshots: + enabled: true + # front_door_camera: + # ffmpeg: + # inputs: + # - path: rtsp://127.0.0.1:8554/front_door_camera?video=copy&audio=aac + # input_args: preset-rtsp-restream-low-latency + # roles: + # - record + # - path: rtsp://127.0.0.1:8554/front_door_camera_sub?video=copy&audio=aac + # input_args: preset-rtsp-restream-low-latency + # roles: + # - detect + # - audio + yi_hack: + enabled: true + ffmpeg: + inputs: + - path: rtsp://127.0.0.1:8554/yi_hack?video=copy&audio=aac + input_args: preset-rtsp-restream + roles: + - record + - path: rtsp://127.0.0.1:8554/yi_hack_sub?video=copy + input_args: preset-rtsp-restream + roles: + - detect + # hwaccel_args: preset-vaapi + #ROLE SETTINGS + detect: + enabled: true + width: 640 + height: 360 + fps: 30 + record: + enabled: true + snapshots: + enabled: true diff --git a/roles/servers/apps/frigate/config_intel.yml b/roles/servers/apps/frigate/config_intel.yml new file mode 100644 index 00000000..845f614b --- /dev/null +++ b/roles/servers/apps/frigate/config_intel.yml @@ -0,0 +1,26 @@ +--- +mqtt: + host: 192.168.1.20 + user: mqtt + password: password + +cameras: + kuchnia: # <------ Name the camera + ffmpeg: + hwaccel_args: + - -hwaccel + - vaapi + - -hwaccel_device + - /dev/dri/renderD128 + - -hwaccel_output_format + - yuv420p + inputs: + - path: rtsp://192.168.1.52:554/ch0_0.h264 # <----- Update for your camera + roles: + - detect + - rtmp + rtmp: + enabled: False # <-- RTMP should be disabled if your stream is not H264 + detect: + width: 1280 # <---- update for your camera's resolution + height: 720 # <---- update for your camera's resolution diff --git a/roles/servers/apps/frigate/docker-compose.yml b/roles/servers/apps/frigate/docker-compose.yml index 45be1e38..8db5ca38 100644 --- a/roles/servers/apps/frigate/docker-compose.yml +++ b/roles/servers/apps/frigate/docker-compose.yml @@ -6,32 +6,38 @@ version: "3.9" services: frigate: container_name: frigate - privileged: true # this may not be necessary for all setups + privileged: true + network_mode: host restart: always - # https://hub.docker.com/r/blakeblackshear/frigate - # 0.10.1-amd64nvidia - image: blakeblackshear/frigate:0.10.1-amd64 - shm_size: "64mb" # update for your cameras based on calculation above - devices: - # - /dev/bus/usb:/dev/bus/usb # passes the USB Coral, needs to be modified for other versions - # - /dev/apex_0:/dev/apex_0 # passes a PCIe Coral, follow driver instructions here https://coral.ai/docs/m2/get-started/#2a-on-linux - - /dev/dri/renderD128 # for intel hwaccel, needs to be updated for your hardware + + image: ghcr.io/blakeblackshear/frigate:stable-tensorrt + + deploy: # <------------- Add this section + resources: + reservations: + devices: + - driver: nvidia + + count: 1 # number of GPUs + capabilities: [gpu] + + shm_size: "256mb" # update for your cameras based on calculation volumes: + +# devices: +# - /dev/dri/renderD128 # for intel hwaccel, needs to be updated for your hardware volumes: - /etc/localtime:/etc/localtime:ro - - ./config.yml:/config/config.yml:ro - - /opt/frigate/storage:/media/frigate + - ./config.yml:/config/config.yml + - ./frigate:/media/frigate + - ./frigatedb:/db - type: tmpfs # Optional: 1GB of memory, reduces SSD/SD Card wear target: /tmp/cache tmpfs: size: 1000000000 ports: - "5000:5000" - - "1935:1935" # RTMP feeds - environment: - FRIGATE_RTSP_PASSWORD: "password" - # iHD, i965 - LIBVA_DRIVER_NAME: "iHD" - logging: - driver: "json-file" - options: - max-size: "250m" + - "1935:1935" #RTMP feeds + - "8555:8555/tcp" # WebRTC over tcp + - "8555:8555/udp" # WebRTC over udp + # environment: + # FRIGATE_RTSP_PASSWORD: "pass" diff --git a/roles/servers/apps/frigate/docker-compose_intel.yml b/roles/servers/apps/frigate/docker-compose_intel.yml new file mode 100644 index 00000000..45be1e38 --- /dev/null +++ b/roles/servers/apps/frigate/docker-compose_intel.yml @@ -0,0 +1,37 @@ +# https://docs.docker.com/compose/compose-file/compose-file-v3/ +# https://docs.frigate.video/installation +# blue iris + deepstack, agentdvr +--- +version: "3.9" +services: + frigate: + container_name: frigate + privileged: true # this may not be necessary for all setups + restart: always + # https://hub.docker.com/r/blakeblackshear/frigate + # 0.10.1-amd64nvidia + image: blakeblackshear/frigate:0.10.1-amd64 + shm_size: "64mb" # update for your cameras based on calculation above + devices: + # - /dev/bus/usb:/dev/bus/usb # passes the USB Coral, needs to be modified for other versions + # - /dev/apex_0:/dev/apex_0 # passes a PCIe Coral, follow driver instructions here https://coral.ai/docs/m2/get-started/#2a-on-linux + - /dev/dri/renderD128 # for intel hwaccel, needs to be updated for your hardware + volumes: + - /etc/localtime:/etc/localtime:ro + - ./config.yml:/config/config.yml:ro + - /opt/frigate/storage:/media/frigate + - type: tmpfs # Optional: 1GB of memory, reduces SSD/SD Card wear + target: /tmp/cache + tmpfs: + size: 1000000000 + ports: + - "5000:5000" + - "1935:1935" # RTMP feeds + environment: + FRIGATE_RTSP_PASSWORD: "password" + # iHD, i965 + LIBVA_DRIVER_NAME: "iHD" + logging: + driver: "json-file" + options: + max-size: "250m" diff --git a/roles/servers/apps/home-assistant/defaults/main.yml b/roles/servers/apps/home-assistant/defaults/main.yml index cbac24e0..1cece1c7 100644 --- a/roles/servers/apps/home-assistant/defaults/main.yml +++ b/roles/servers/apps/home-assistant/defaults/main.yml @@ -21,6 +21,8 @@ home_assistant_custom_components: repo: https://github.com/twrecked/hass-virtual - name: tesla_custom repo: https://github.com/alandtse/tesla + - name: frigate + repo: https://github.com/blakeblackshear/frigate-hass-integration # - name: virtual # repo: https://github.com/twrecked/hass-virtual @@ -28,7 +30,7 @@ home_assistant_custom_lovelace_plugins: - name: 'lovelace-multiple-entity-row' entity_name: 'multiple-entity-row.js' repo: https://github.com/benct/lovelace-multiple-entity-row - # version: v4.5.0 + version: v4.5.1 - name: 'button-card' entity_name: 'button-card.js' repo: https://github.com/custom-cards/button-card @@ -38,7 +40,13 @@ home_assistant_custom_lovelace_plugins: entity_name: 'vacuum-card.js' repo: https://github.com/denysdovhan/vacuum-card release: true - version: v2.9.2 + version: v2.10.1 + - name: 'frigate-hass-card' + entity_name: 'frigate-hass-card.zip' + repo: https://github.com/dermotduffy/frigate-hass-card + release: true + version: v5.2.0 + zip_mode: true home_assistant: automations: @@ -66,6 +74,9 @@ home_assistant: - name: serwerownia - name: ogrod - name: garaz + - name: lazienka_dol + - name: przedpokoj + button: - name: dol_1 door: diff --git a/roles/servers/apps/home-assistant/tasks/custom.yml b/roles/servers/apps/home-assistant/tasks/custom.yml index d42abd19..2826b610 100644 --- a/roles/servers/apps/home-assistant/tasks/custom.yml +++ b/roles/servers/apps/home-assistant/tasks/custom.yml @@ -8,6 +8,12 @@ - "{{ install_path }}/config/www" - "{{ install_path }}/config/git" +- name: Ensure install dir exists for home_assistant_custom_lovelace_plugins + file: + path: "{{ install_path }}/config/git/{{ item.name }}" + state: directory + loop: "{{ home_assistant_custom_lovelace_plugins }}" + - name: "Pull custom components via git" git: repo: "{{ item.repo }}" @@ -22,7 +28,7 @@ # https://github.com/PiotrMachowski/lovelace-xiaomi-vacuum-map-card/releases/download/v2.2.2/xiaomi-vacuum-map-card.js - name: "Pull custom components via release" get_url: - url: "{{ item.repo }}//releases/download/{{ item.version }}/{{ item.entity_name }}" + url: "{{ item.repo }}/releases/download/{{ item.version }}/{{ item.entity_name }}" dest: "{{ install_path }}/config/git/{{ item.name }}/{{ item.entity_name }}" when: item.release is defined and item.release == true with_items: @@ -42,3 +48,12 @@ dest: "{{ install_path }}/config/www/{{ item.entity_name }}" remote_src: true loop: "{{ home_assistant_custom_lovelace_plugins }}" + when: item.zip_mode is not defined or item.zip_mode == false + +- name: Unzip www + ansible.builtin.unarchive: + src: "{{ install_path }}/config/git/{{ item.name }}/{{ item.entity_name }}" + dest: "{{ install_path }}/config/www/" + remote_src: true + loop: "{{ home_assistant_custom_lovelace_plugins }}" + when: item.zip_mode is defined and item.zip_mode == true diff --git a/roles/servers/apps/home-assistant/tasks/hacs.yml b/roles/servers/apps/home-assistant/tasks/hacs.yml new file mode 100644 index 00000000..36d9ae72 --- /dev/null +++ b/roles/servers/apps/home-assistant/tasks/hacs.yml @@ -0,0 +1,5 @@ +--- +# custom_components/hacs/ +- name: Install HACS + shell: | + docker-compose exec homeassistant /bin/bash -c "wget -O - https://get.hacs.xyz | bash -" diff --git a/roles/servers/apps/home-assistant/templates/config/configuration.yaml b/roles/servers/apps/home-assistant/templates/config/configuration.yaml index 6bc7b8b2..2174c6c6 100644 --- a/roles/servers/apps/home-assistant/templates/config/configuration.yaml +++ b/roles/servers/apps/home-assistant/templates/config/configuration.yaml @@ -41,6 +41,8 @@ lovelace: type: module - url: /local/vacuum-card.js?ver=1 type: module + - url: /local/dist/frigate-hass-card.js?ver=1 + type: module # Text to speech tts: diff --git a/roles/servers/apps/home-assistant/templates/config/dashboard-tesla.yaml b/roles/servers/apps/home-assistant/templates/config/dashboard-tesla.yaml index 4d0406b8..d52fa739 100644 --- a/roles/servers/apps/home-assistant/templates/config/dashboard-tesla.yaml +++ b/roles/servers/apps/home-assistant/templates/config/dashboard-tesla.yaml @@ -33,6 +33,14 @@ views: - entity: binary_sensor.door_state_garaz_brama name: Garaz Brama stan icon: mdi:garage-variant + # - type: custom:frigate-card + # cameras: + # - camera_entity: camera.yi_garaz + # live_provider: webrtc-card + # - type: custom:frigate-card + # cameras: + # - camera_entity: camera.yi_kuchnia + # live_provider: webrtc-card # - entity: sensor.th_temperature_ogrod # type: custom:button-card # name: Ogrod diff --git a/roles/servers/apps/home-assistant/templates/config/ui-lovelace.yaml b/roles/servers/apps/home-assistant/templates/config/ui-lovelace.yaml index 62e295a8..615eff2f 100644 --- a/roles/servers/apps/home-assistant/templates/config/ui-lovelace.yaml +++ b/roles/servers/apps/home-assistant/templates/config/ui-lovelace.yaml @@ -70,6 +70,30 @@ views: name: Wilgotnosc - entity: sensor.th_battery_percentage_sypialnia_dol name: Bateria + - entity: sensor.th_temperature_lazienka_dol + type: custom:multiple-entity-row + name: Lazienka Dol + show_state: false + secondary_info: last-changed + entities: + - entity: sensor.th_temperature_lazienka_dol + name: Temperatura + - entity: sensor.th_humidity_lazienka_dol + name: Wilgotnosc + - entity: sensor.th_battery_percentage_lazienka_dol + name: Bateria + - entity: sensor.th_temperature_przedpokoj + type: custom:multiple-entity-row + name: Przedpokoj + show_state: false + secondary_info: last-changed + entities: + - entity: sensor.th_temperature_przedpokoj + name: Temperatura + - entity: sensor.th_humidity_przedpokoj + name: Wilgotnosc + - entity: sensor.th_battery_percentage_przedpokoj + name: Bateria - type: section label: Gora - entity: sensor.th_temperature_pokoj_timi diff --git a/roles/servers/apps/llama-docker/Dockerfile b/roles/servers/apps/llama-docker/Dockerfile new file mode 100644 index 00000000..01b15f00 --- /dev/null +++ b/roles/servers/apps/llama-docker/Dockerfile @@ -0,0 +1,18 @@ +FROM + +curl -fsSL https://ollama.com/install.sh | sh +ollama run mistral + +sudo apt update && sudo apt install git g++ wget build-essential + +git clone https://github.com/ggerganov/llama.cpp +cd llama.cpp +make -j +cd models +wget https://huggingface.co/TheBloke/Mistral-7B-v0.1-GGUF/resolve/main/mistral-7b-v0.1.Q4_K_S.gguf) +cd .. +./main -m models/mistral-7b-v0.1.Q4_K_S.gguf -p "Whatsup?" -n 400 -e + +ollama serve +ollama run llama3 +ollama run llama3:8b diff --git a/roles/servers/apps/llama-docker/config/litellm/config.yaml b/roles/servers/apps/llama-docker/config/litellm/config.yaml new file mode 100644 index 00000000..13ec1945 --- /dev/null +++ b/roles/servers/apps/llama-docker/config/litellm/config.yaml @@ -0,0 +1,36 @@ +--- +model_list: + - model_name: mixtral + litellm_params: + model: ollama/mixtral:8x7b-instruct-v0.1-q5_K_M + api_base: http://ollama:11434 + stream: True + - model_name: mistral + litellm_params: + model: ollama/mistral + api_base: http://ollama:11434 + stream: True + + +# module level litellm settings - https://github.com/BerriAI/litellm/blob/main/litellm/__init__.py +litellm_settings: + + drop_params: True + max_budget: 100 + budget_duration: 30d + + cache: True # set cache responses to True, litellm defaults to using a redis cache + cache_params: # cache_params are optional + type: "redis" # The type of cache to initialize. Can be "local" or "redis". Defaults to "local". + # Optional configurations + supported_call_types: ["acompletion", "completion", "embedding", "aembedding"] # defaults to all litellm call types + +general_settings: + master_key: sk-1234 # [OPTIONAL] Only use this if you to require all calls to contain this key (Authorization: Bearer sk-1234) + # database_url: "postgresql://:@:/" # [OPTIONAL] use for token-based auth to proxy + +environment_variables: + # settings for using redis caching + # REDIS_HOST: redis-16337.c322.us-east-1-2.ec2.cloud.redislabs.com + # REDIS_PORT: "16337" + # REDIS_PASSWORD: diff --git a/roles/servers/apps/llama-docker/docker-compose copy.yml b/roles/servers/apps/llama-docker/docker-compose copy.yml new file mode 100644 index 00000000..89695b0e --- /dev/null +++ b/roles/servers/apps/llama-docker/docker-compose copy.yml @@ -0,0 +1,8 @@ +# https://github.com/open-webui/open-webui +docker run -d -p 3000:8080 --add-host=host.docker.internal:host-gateway -v open-webui:/app/backend/data --name open-webui --restart always ghcr.io/open-webui/open-webui:main + +# docker run -d -v ollama:/root/.ollama -p 11434:11434 --name ollama ollama/ollama + +# openhermes2.5-mistral:7b-q4_K_M + +# https://github.com/danny-avila/LibreChat/tree/main diff --git a/roles/servers/apps/llama-docker/docker-compose.yml b/roles/servers/apps/llama-docker/docker-compose.yml new file mode 100644 index 00000000..bf6851f4 --- /dev/null +++ b/roles/servers/apps/llama-docker/docker-compose.yml @@ -0,0 +1,112 @@ +# https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html#installation +# nvidia-ctk runtime configure --runtime=docker +# systemctl restart docker +# https://github.com/muka/ollama-docker/blob/main/docker-compose.yaml + +version: "3.9" + +networks: + ollama: + + +services: + + ollama: + image: ollama/ollama + networks: + - ollama + deploy: + resources: + reservations: + devices: + - driver: nvidia + count: 1 + capabilities: [ gpu ] + volumes: + - ./data/ollama:/root/.ollama + ports: + - 11434:11434 + + ollama-webui: + # image: ghcr.io/ollama-webui/ollama-webui:main + image: ghcr.io/open-webui/open-webui + volumes: + - ./data/ollama-webui:/app/backend/data + depends_on: + - ollama + ports: + - 3002:8080 + environment: + - 'OLLAMA_API_BASE_URL=http://ollama:11434/api' + extra_hosts: + - host.docker.internal:host-gateway + networks: + - ollama + + # litellm: + # image: ghcr.io/berriai/litellm:main-latest + # networks: + # - ollama + # volumes: + # - ./config/litellm/config.yaml:/app/config.yaml + # command: + # [ + # "--config", + # "/app/config.yaml", + # "--port", + # "8000", + # "--num_workers", + # "8" + # ] + # depends_on: + # - ollama + # - redis + # - litellm-database + # ports: + # - 8000:8000 + # environment: + # REDIS_HOST: redis + # REDIS_PORT: 6379 + # REDIS_PASSWORD: SDsdgFsfm4lmf43lfnm34lkf + + # litellm-database: + # image: ghcr.io/berriai/litellm-database:main-latest + # networks: + # - ollama + # # volumes: + # # - ./config/litellm/config.yaml:/app/config.yaml + # # command: + # # [ + # # "--config", + # # "/app/config.yaml", + # # "--port", + # # "8000", + # # "--num_workers", + # # "8" + # # ] + # # depends_on: + # # - ollama + # # - redis + # # ports: + # # - 8000:8000 + # # environment: + # # REDIS_HOST: redis + # # REDIS_PORT: 6379 + # # REDIS_PASSWORD: SDsdgFsfm4lmf43lfnm34lkf + + # # env: + # # - name: DATABASE_URL + # # value: postgresql://:@:/ + + # redis: + # image: redis:7-alpine + # command: + # - sh + # - -c # this is to evaluate the $REDIS_PASSWORD from the env + # - redis-server --appendonly yes --requirepass $$REDIS_PASSWORD ## $$ because of docker-compose + # environment: + # REDIS_PASSWORD: SDsdgFsfm4lmf43lfnm34lkf + # volumes: + # - ./data/redis:/data + # networks: + # - ollama diff --git a/roles/servers/apps/nginx/templates/docker-compose.yml b/roles/servers/apps/nginx/templates/docker-compose.yml index ee2917b2..cf1bee1c 100644 --- a/roles/servers/apps/nginx/templates/docker-compose.yml +++ b/roles/servers/apps/nginx/templates/docker-compose.yml @@ -4,7 +4,7 @@ version: '3.8' services: nginx: # https://hub.docker.com/_/nginx - image: nginx:1.23 + image: nginx:stable container_name: nginx restart: always # other option: always - if you want persistent through host reboots expose: