Moved qbitclients to gluetun network

Added grafana, prometheus and snmp exporter for madrigal and node exporter for aya01

Signed-off-by: TuDatTr <tuan-dat.tran@tudattr.dev>
pull/1/head
TuDatTr 2023-05-11 15:09:52 +02:00
parent 76a5ef1781
commit b3ae5efdaa
28 changed files with 62348 additions and 198 deletions

3141
Mikrotik.mib Normal file

File diff suppressed because it is too large Load Diff

View File

@ -14,8 +14,13 @@
- power_management
- role: backblaze
tags:
- backup
- backblaze
- role: node_exporter
tags:
- node_exporter
- role: docker
tags:
- docker
- role: snmp_exporter
tags:
- snmp_exporter

View File

@ -4,8 +4,8 @@
user: tudattr
timezone: Europe/Berlin
rclone_config: "/root/.config/rclone/"
puid: 1000
pgid: 1000
puid: "1000"
pgid: "1000"
pk_path: "/media/veracrypt1/genesis"
local_domain: borg.land
@ -202,28 +202,6 @@ smb_group: "smbshare"
smb_user: "smbuser"
#
# prometheus/grafana
#
prm_user: "prometheus"
exporter_dir: "{{ docker_dir }}/exporter/"
prm_data: "{{docker_data_dir}}/prometheus/"
prm_config: "{{docker_dir}}/prometheus/"
prm_port: "9091"
e_node_port: "9100"
e_mikrotik_ip: "192.168.20.1"
e_mikrotik_version: "1.0.11"
e_mikrotik_config: "{{ exporter_dir }}/mikrotik/config/"
e_mikrotik_port: "9436"
grafana_data: "{{docker_data_dir}}/grafana/"
grafana_log: "{{docker_dir}}/grafana/logs/"
grafana_config: "{{docker_dir}}/grafana/config/"
#
# netdata
#
@ -246,6 +224,7 @@ swag_site_confs:
- "templates/mii/swag/site-confs/plex.subdomain.conf"
- "templates/mii/swag/site-confs/uptime-kuma.subdomain.conf"
- "templates/mii/swag/site-confs/tautulli.subdomain.conf"
# - "templates/mii/swag/site-confs/code-server.subdomain.conf"
# - "templates/mii/swag/site-confs/homeassistant.subdomain.conf"
# - "templates/mii/swag/site-confs/qbittorrent.subdomain.conf"
# - "templates/mii/swag/site-confs/zoneminder.subdomain.conf"
@ -332,7 +311,7 @@ bin_upload: "{{ docker_data_dir }}/{{bin_host}}/upload"
qbit_port: "8082"
qbit_host: "qbit"
qbit_config: "templates/aya01/qbittorrentvpn/config"
qbit_ovpn_config: "openvpn/ae.protonvpn.net.udp.ovpn"
qbit_ovpn_config: "openvpn/hu.protonvpn.net.udp.ovpn"
qbit_remote_config: "{{ docker_dir }}/{{ qbit_host }}/config"
qbit_downloads: "{{ arr_downloads }}"
@ -345,9 +324,9 @@ qbit_dns: "{{ aya01_ip }}, {{ pi_ip }}, 1.1.1.1"
# qbittorrentvpn - torrentleech
#
qbit_private_port: "8083"
qbit_private_host: "torrentleech"
qbit_private_remote_config: "{{ docker_dir }}/{{ qbit_private_host }}/config"
torrentleech_port: "8083"
torrentleech_host: "torrentleech"
torrentleech_remote_config: "{{ docker_dir }}/{{ torrentleech_host }}/config"
#
# Home Assistant
@ -363,3 +342,62 @@ hass_host: "hass"
tautulli_port: "8181"
tautulli_host: "tautulli"
tautulli_config: "{{ docker_dir }}/{{ tautulli_host }}/config"
#
# Code Server
#
code_port: "8443"
code_host: "code"
code_config: "{{ docker_dir }}/{{ code_host }}/config"
#
# GlueTun
#
gluetun_port: ""
gluetun_host: "gluetun"
gluetun_country: "Hungary"
gluetun_config: "{{ docker_dir }}/{{ gluetun_host }}/config"
#
# NodeExporter
#
node_exporter_port: 9100
node_exporter_host: 'node'
node_exporter_version: 'latest'
node_exporter_serve: 'localhost'
node_exporter_options: ''
node_exporter_bin_path: /usr/local/bin/node_exporter
#
# Prometheus
#
prometheus_user: "prometheus"
prometheus_host: "prometheus"
prometheus_data: "{{docker_data_dir}}/prometheus/"
prometheus_config: "{{docker_dir}}/prometheus/"
prometheus_port: "9090"
#
# Grafana
#
grafana_host: "grafana"
grafana_port: "3000"
grafana_data: "{{docker_data_dir}}/grafana/"
grafana_config: "{{docker_dir}}/grafana/config/"
grafana_logs: "{{docker_dir}}/grafana/logs/"
grafana_puid: "472"
grafana_pgid: "0"
#
# SNMP Exporter
#
snmp_exporter_port: "9116"
snmp_exporter_target: "192.168.20.1"
snmp_exporter_config: "{{ docker_dir }}/snmp_exporter/"
snmp_exporter_host: "snmp_exporter"

View File

@ -1,22 +0,0 @@
---
- name: Create qbit_torrentleech-config directory
file:
path: "{{ item }}"
owner: "{{ puid }}"
group: "{{ pgid }}"
mode: '775'
state: directory
loop:
- "{{ qbit_private_remote_config }}"
- "{{ qbit_private_remote_config }}/openvpn"
- "{{ qbit_downloads }}"
become: true
- name: Copy ovpn_torrentleech-config
template:
owner: "{{ puid }}"
group: "{{ pgid }}"
src: "{{ qbit_config }}/{{ qbit_ovpn_config }}"
dest: "{{ qbit_private_remote_config }}/{{ qbit_ovpn_config }}"
mode: '664'
become: true

View File

@ -56,13 +56,25 @@
tags:
- bin
- include_tasks: gluetun.yml
tags:
- gluetun
- include_tasks: qbit.yml
tags:
- qbit
- include_tasks: qbit_private.yml
tags:
- qbit_private
- qbit_priv
- include_tasks: prometheus.yml
tags:
- prometheus
- include_tasks: grafana.yml
tags:
- grafana
- name: Copy the compose file
template:

View File

@ -0,0 +1,11 @@
---
- name: Create gluetun-config directory
file:
path: "{{ item }}"
owner: "{{ puid }}"
group: "{{ pgid }}"
mode: '775'
state: directory
loop:
- "{{ gluetun_config}}"
become: true

View File

@ -2,21 +2,21 @@
- name: Create grafana data directory
file:
path: "{{ item }}"
owner: "{{ puid }}"
group: "{{ pgid }}"
owner: "{{ grafana_puid }}"
group: "{{ grafana_pgid }}"
mode: '755'
state: directory
loop:
- "{{ grafana_data }}"
- "{{ grafana_log }}"
- "{{ grafana_config }}"
become: true
- name: Copy grafana config
template:
owner: "{{ puid }}"
src: "templates/aya01/grafana/etc-grafana/grafana.ini"
owner: "{{ grafana_puid }}"
group: "{{ grafana_pgid }}"
src: "templates/aya01/grafana/etc-grafana/grafana.ini.j2"
dest: "{{ grafana_config }}/grafana.ini"
mode: '660'
mode: '644'
become: true

View File

@ -39,7 +39,7 @@
ansible.builtin.get_url:
url: "{{ docker_apt_gpg_key }}"
dest: /etc/apt/trusted.gpg.d/docker.asc
mode: '0644'
mode: '0664'
force: true
become: true

View File

@ -1,42 +1,19 @@
---
- name: Create prometheus dirs
file:
path: "{{ item }}"
owner: 1000
group: 1000
mode: '777'
owner: "{{ puid }}"
group: "{{ pgid}}"
mode: '775'
state: directory
loop:
- "{{ prm_config }}"
- "{{ prm_data}}"
- "{{ prometheus_config }}"
- "{{ prometheus_data }}"
- name: Place prometheus config
template:
owner: 1000
mode: '777'
src: "templates/aya01/prometheus/prometheus.yml"
dest: "{{ prm_config }}/prometheus.yml"
- name: Create prometheus exporter dir
file:
path: "{{ exporter_dir }}"
owner: 1000
group: 1000
mode: '755'
state: directory
- name: Create mikrotik exporters config dir
file:
path: "{{ e_mikrotik_config }}"
owner: 1000
group: 1000
mode: '755'
state: directory
- name: Place mikrotik exporter config
template:
owner: 1000
mode: '400'
src: "templates/aya01/prometheus/exporter/mikrotik/config/config.yml"
dest: "{{ e_mikrotik_config }}/config.yml"
owner: "{{ puid }}"
group: "{{ pgid}}"
mode: '644'
src: "templates/aya01/prometheus/prometheus.yml.j2"
dest: "{{ prometheus_config }}/prometheus.yml"

View File

@ -8,15 +8,5 @@
state: directory
loop:
- "{{ qbit_remote_config }}"
- "{{ qbit_remote_config }}/openvpn"
- "{{ qbit_downloads }}"
become: true
- name: Copy ovpn-config
template:
owner: "{{ puid }}"
group: "{{ pgid }}"
src: "{{ qbit_config }}/{{ qbit_ovpn_config }}"
dest: "{{ qbit_remote_config }}/{{ qbit_ovpn_config }}"
mode: '664'
become: true

View File

@ -0,0 +1,12 @@
---
- name: Create qbit_torrentleech-config directory
file:
path: "{{ item }}"
owner: "{{ puid }}"
group: "{{ pgid }}"
mode: '775'
state: directory
loop:
- "{{ torrentleech_remote_config }}"
- "{{ qbit_downloads }}"
become: true

View File

@ -15,6 +15,6 @@
group: "{{ pgid }}"
src: "{{ item }}"
dest: "{{ swag_remote_site_confs }}"
mode: '644'
mode: '664'
loop: "{{ swag_site_confs }}"
become: true

View File

@ -103,7 +103,6 @@ services:
- "traefik.http.routers.{{ zoneminder_host }}.rule=Host(`{{ zoneminder_host}}.{{ aya01_host }}.{{ local_domain }}`)"
- "traefik.http.services.{{ zoneminder_host }}.loadbalancer.server.port=80"
syncthing:
image: syncthing/syncthing
container_name: syncthing
@ -334,68 +333,6 @@ services:
- "traefik.http.routers.{{ bin_host }}.rule=Host(`{{ bin_host }}.{{ aya01_host }}.{{ local_domain }}`)"
- "traefik.http.services.{{ bin_host }}.loadbalancer.server.port={{ bin_port }}"
qbittorrentvpn:
image: dyonr/qbittorrentvpn
container_name: {{ qbit_host }}
restart: unless-stopped
privileged: true
depends_on:
- sonarr
- radarr
- lidarr
networks:
- net
ports:
- "{{ qbit_port }}:8080"
environment:
- PUID={{ puid }}
- PGID={{ pgid }}
- TZ={{ timezone }}
- VPN_TYPE={{ qbit_type }}
- LAN_NETWORK={{ qbit_lan }}
- NAME_SERVERS={{ qbit_dns }}
- ENABLE_SSL={{ qbit_ssl }}
- VPN_USERNAME={{ vault_qbit_vpn_user }}
- VPN_PASSWORD={{ vault_qbit_vpn_password }}
volumes:
- {{ qbit_remote_config }}:/config
- {{ qbit_downloads }}:/downloads
labels:
- "traefik.enable=true"
- "traefik.http.routers.{{ qbit_host }}.rule=Host(`{{ qbit_host }}.{{ aya01_host }}.{{ local_domain }}`)"
- "traefik.http.services.{{ qbit_host }}.loadbalancer.server.port=8080"
qbittorrentvpnprivate:
image: dyonr/qbittorrentvpn
container_name: {{ qbit_private_host }}
restart: unless-stopped
privileged: true
depends_on:
- sonarr
- radarr
- lidarr
networks:
- net
ports:
- "{{ qbit_private_port }}:8080"
environment:
- PUID={{ puid }}
- PGID={{ pgid }}
- TZ={{ timezone }}
- VPN_TYPE={{ qbit_type }}
- LAN_NETWORK={{ qbit_lan }}
- NAME_SERVERS={{ qbit_dns }}
- ENABLE_SSL={{ qbit_ssl }}
- VPN_USERNAME={{ vault_qbit_vpn_user }}
- VPN_PASSWORD={{ vault_qbit_vpn_password }}
volumes:
- {{ qbit_private_remote_config }}:/config
- {{ qbit_downloads }}:/downloads
labels:
- "traefik.enable=true"
- "traefik.http.routers.{{ qbit_private_host }}.rule=Host(`{{ qbit_private_host }}.{{ aya01_host }}.{{ local_domain }}`)"
- "traefik.http.services.{{ qbit_private_host }}.loadbalancer.server.port=8080"
tautulli:
image: lscr.io/linuxserver/tautulli:latest
container_name: tautulli
@ -417,6 +354,125 @@ services:
- "traefik.http.routers.{{ tautulli_host }}.rule=Host(`{{ tautulli_host }}.{{ aya01_host }}.{{ local_domain }}`)"
- "traefik.http.services.{{ tautulli_host }}.loadbalancer.server.port={{ tautulli_port }}"
{{ gluetun_host }}:
image: qmcgaw/gluetun
container_name: {{ gluetun_host }}
restart: unless-stopped
networks:
- net
cap_add:
- NET_ADMIN
devices:
- /dev/net/tun:/dev/net/tun
ports:
- {{ torrentleech_port }}:{{ torrentleech_port }}
- {{ qbit_port }}:{{ qbit_port }}
volumes:
- {{ gluetun_config }}:/gluetun
environment:
- PUID={{puid}}
- PGID={{pgid}}
- TZ={{ timezone }}
- VPN_SERVICE_PROVIDER=protonvpn
- UPDATER_VPN_SERVICE_PROVIDERS=protonvpn
- UPDATER_PERIOD=24h
- SERVER_COUNTRIES={{ gluetun_country }}
- OPENVPN_USER={{ vault_qbit_vpn_user }}+pmp
- OPENVPN_PASSWORD={{ vault_qbit_vpn_password }}
labels:
- "traefik.enable=true"
- "traefik.http.routers.{{ gluetun_host }}.rule=Host(`{{ gluetun_host }}.{{ aya01_host }}.{{ local_domain }}`)"
- "traefik.http.services.{{ gluetun_host }}.loadbalancer.server.port={{ gluetun_port }}"
- "traefik.http.routers.{{ torrentleech_host }}.service={{ torrentleech_host }}"
- "traefik.http.routers.{{ torrentleech_host }}.rule=Host(`{{ torrentleech_host }}.{{ aya01_host }}.{{ local_domain }}`)"
- "traefik.http.services.{{ torrentleech_host }}.loadbalancer.server.port={{ torrentleech_port }}"
- "traefik.http.routers.{{ qbit_host }}.service={{ qbit_host }}"
- "traefik.http.routers.{{ qbit_host }}.rule=Host(`{{ qbit_host }}.{{ aya01_host }}.{{ local_domain }}`)"
- "traefik.http.services.{{ qbit_host }}.loadbalancer.server.port={{ qbit_port }}"
{{ torrentleech_host }}:
image: qbittorrentofficial/qbittorrent-nox
container_name: {{ torrentleech_host }}
restart: unless-stopped
depends_on:
- gluetun
- sonarr
- radarr
- lidarr
network_mode: "container:{{ gluetun_host }}"
environment:
- PUID={{ puid }}
- PGID={{ pgid }}
- TZ={{ timezone }}
- QBT_EULA="accept"
- QBT_WEBUI_PORT="{{ torrentleech_port }}"
volumes:
- {{ torrentleech_remote_config }}:/config
- {{ qbit_downloads }}:/downloads
{{qbit_host}}:
image: qbittorrentofficial/qbittorrent-nox
container_name: {{ qbit_host }}
restart: unless-stopped
depends_on:
- gluetun
- sonarr
- radarr
- lidarr
network_mode: "container:{{ gluetun_host }}"
environment:
- PUID={{ puid }}
- PGID={{ pgid }}
- TZ={{ timezone }}
- QBT_EULA="accept"
- QBT_WEBUI_PORT="{{ qbit_port }}"
volumes:
- {{ qbit_remote_config }}:/config
- {{ qbit_downloads }}:/downloads
{{ prometheus_host }}:
image: prom/prometheus
container_name: {{ prometheus_host }}
restart: unless-stopped
depends_on:
- pihole
networks:
- net
environment:
- PUID={{ puid }}
- PGID={{ pgid}}
- TZ={{ timezone }}
volumes:
- {{ prometheus_config }}:/etc/prometheus/
ports:
- {{ prometheus_port }}:9090
labels:
- "traefik.enable=true"
- "traefik.http.routers.{{ prometheus_host }}.rule=Host(`{{ prometheus_host }}.{{ aya01_host }}.{{ local_domain }}`)"
- "traefik.http.services.{{ prometheus_host }}.loadbalancer.server.port={{ prometheus_port }}"
{{ grafana_host }}:
image: grafana/grafana-oss
container_name: {{ grafana_host }}
restart: unless-stopped
depends_on:
- {{ prometheus_host }}
networks:
- net
environment:
- PUID={{ grafana_puid }}
- PGID={{ grafana_pgid }}
- TZ={{ timezone }}
volumes:
- {{ grafana_data }}:/var/lib/grafana/
- {{ grafana_config }}:/etc/grafana/
ports:
- {{ grafana_port }}:3000
labels:
- "traefik.enable=true"
- "traefik.http.routers.{{ grafana_host }}.rule=Host(`{{ grafana_host }}.{{ aya01_host }}.{{ local_domain }}`)"
- "traefik.http.services.{{ grafana_host }}.loadbalancer.server.port={{ grafana_port }}"
networks:
zoneminder:
driver: bridge

File diff suppressed because it is too large Load Diff

View File

@ -8,37 +8,32 @@ global:
# Attach these labels to any time series or alerts when communicating with
# external systems (federation, remote storage, Alertmanager).
external_labels:
monitor: 'tudattr'
# Alertmanager configuration
alerting:
alertmanagers:
- static_configs:
- targets: ['localhost:9093']
monitor: '{{ user }}'
# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:
# - "first_rules.yml"
# - "second_rules.yml"
# A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
scrape_configs:
# The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
- job_name: 'prometheus'
# Override the global default and scrape targets from this job every 5 seconds.
- job_name: 'node'
scrape_interval: 10s
scrape_timeout: 10s
tls_config:
insecure_skip_verify: true
# metrics_path defaults to '/metrics'
# scheme defaults to 'http'.
#static_configs:
#- targets: ['localhost:9090']
- job_name: 'mikrotik'
static_configs:
- targets: ['{{ aya01_ip }}:{{node_exporter_port}}']
- job_name: Mikrotik
static_configs:
- targets:
- "{{aya01_ip}}:{{ e_mikrotik_port }}"
- {{ snmp_exporter_target }}
metrics_path: /snmp
params:
module: [mikrotik]
relabel_configs:
- source_labels: [__address__]
target_label: __param_target
- source_labels: [__param_target]
target_label: instance
- target_label: __address__
replacement: {{ aya01_ip }}:{{ snmp_exporter_port }} # The SNMP exporter's real hostname:port.

View File

@ -0,0 +1,22 @@
## Version 2023/02/05
# make sure that your code-server container is named code-server
# make sure that your dns has a cname set for code-server
server {
listen 443 ssl;
listen [::]:443 ssl;
server_name {{ code_host }}.{{ remote_domain }};
include /config/nginx/ssl.conf;
client_max_body_size 0;
location / {
include /config/nginx/proxy.conf;
include /config/nginx/resolver.conf;
proxy_pass http://{{aya01_ip}}:{{ code_port }};
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}

View File

@ -0,0 +1 @@
- include_tasks: docker.yml

View File

@ -0,0 +1,18 @@
---
- name: Determine latest GitHub release (local)
delegate_to: localhost
uri:
url: "https://api.github.com/repos/prometheus/node_exporter/releases/{{ node_exporter_version }}"
body_format: json
register: _github_release
until: _github_release.status == 200
retries: 3
- name: Set node_exporter_version
set_fact:
node_exporter_version: "{{ _github_release.json.tag_name
| regex_replace('^v?([0-9\\.]+)$', '\\1') }}"
- name: Set node_exporter_download_url
set_fact:
node_exporter_download_url: "https://github.com/prometheus/node_exporter/releases/download/v{{ node_exporter_version }}/node_exporter-{{ node_exporter_version }}.linux-{{ go_arch }}.tar.gz"

View File

@ -1,11 +1,31 @@
---
- name: Download {{ exporter_node_dl_filename }}
get_url:
url: {{ exporter_node_dl_url }}
dest: {{ exporter_node_full_path }}
mode: '0664'
- name: Extract {{ exporter_node_dl_filename }}
- name: Download/Extract "{{ node_exporter_download_url }}"
unarchive:
src: {{ exporter_node_full_path }}
dest: {{ exporter_node_dl_path }}/node_exporter
src: "{{ node_exporter_download_url }}"
dest: /tmp/
remote_src: true
mode: 755
- name: Move node_exporter into path
copy:
src: "/tmp/node_exporter-{{ node_exporter_version }}.linux-{{ go_arch }}/node_exporter"
dest: "{{ node_exporter_bin_path }}"
mode: 755
remote_src: true
become: true
- name: Create node_exporter user.
user:
name: node_exporter
shell: /sbin/nologin
state: present
become: true
- name: Copy the node_exporter systemd unit file.
template:
src: node_exporter.service.j2
dest: /etc/systemd/system/node_exporter.service
mode: 0644
register: node_exporter_service
become: true

View File

@ -1,3 +1,3 @@
- include_tasks: get_version.yml
- include_tasks: install.yml
- include_tasks: systemd.yml
- include_tasks: run.yml

View File

@ -0,0 +1,9 @@
---
- name: Ensure node_exporter is running and enabled at boot.
service:
daemon_reload: true
name: node_exporter
state: restarted
enabled: true
when: node_exporter_service is changed
become: true

View File

@ -0,0 +1,10 @@
[Unit]
Description=NodeExporter
[Service]
TimeoutStartSec=0
User=node_exporter
ExecStart={{ node_exporter_bin_path }} --web.listen-address={{ aya01_ip }}:{{ node_exporter_port }} {{ node_exporter_options }}
[Install]
WantedBy=multi-user.target

View File

@ -0,0 +1,8 @@
go_arch_map:
i386: '386'
x86_64: 'amd64'
aarch64: 'arm64'
armv7l: 'armv7'
armv6l: 'armv6'
go_arch: "{{ go_arch_map[ansible_architecture] | default(ansible_architecture) }}"

View File

@ -0,0 +1,15 @@
- name: Create snmp-exporter container
docker_container:
image: prom/snmp-exporter
name: "{{ snmp_exporter_host }}"
restart_policy: "unless-stopped"
networks:
- name: compose_net
env:
PUID: "{{ puid }}"
PGID: "{{ pgid}}"
TZ: "{{ timezone }}"
volumes:
- "{{ snmp_exporter_config }}:/etc/snmp_exporter/"
ports:
- "{{ snmp_exporter_port }}:9116"

View File

@ -0,0 +1,3 @@
---
- include_tasks: setup.yml
- include_tasks: docker.yml

View File

@ -0,0 +1,20 @@
---
- name: Create snmp_exporter directories
file:
path: "{{ item }}"
owner: "{{ puid }}"
group: "{{ pgid }}"
mode: '755'
state: directory
loop:
- "{{ snmp_exporter_config }}"
become: true
- name: Copy snmp_exporter config
template:
owner: "{{ puid }}"
group: "{{ pgid }}"
src: "snmp.yml.j2"
dest: "{{ snmp_exporter_config }}/snmp.yml"
mode: '644'
become: true

File diff suppressed because it is too large Load Diff