Added btrfs

Signed-off-by: TuDatTr <tuan-dat.tran@tudattr.dev>
pull/1/head
TuDatTr 2023-06-19 22:38:07 +02:00
commit c2b68f7f64
13 changed files with 181 additions and 15 deletions

View File

@ -18,9 +18,12 @@
- role: node_exporter - role: node_exporter
tags: tags:
- node_exporter - node_exporter
- role: docker
tags:
- docker
- role: snmp_exporter - role: snmp_exporter
tags: tags:
- snmp_exporter - snmp_exporter
- role: smart_exporter
tags:
- smart_exporter
- role: docker
tags:
- docker

View File

@ -6,7 +6,7 @@ timezone: Europe/Berlin
rclone_config: "/root/.config/rclone/" rclone_config: "/root/.config/rclone/"
puid: "1000" puid: "1000"
pgid: "1000" pgid: "1000"
pk_path: "/media/veracrypt1/genesis" pk_path: "/mnt/veracrypt1/genesis"
local_domain: borg.land local_domain: borg.land
local_subdomains: "@" local_subdomains: "@"
@ -15,6 +15,20 @@ remote_subdomains: "www,plex,status,tautulli"
backup_domain: seyshiro.de backup_domain: seyshiro.de
backup_subdomains: "hass,qbit,zm," backup_subdomains: "hass,qbit,zm,"
#
# Used to download for git releases
#
go_arch_map:
i386: '386'
x86_64: 'amd64'
aarch64: 'arm64'
armv7l: 'armv7'
armv6l: 'armv6'
go_arch: "{{ go_arch_map[ansible_architecture] | default(ansible_architecture) }}"
# #
# aya01 - Disks # aya01 - Disks
# #
@ -63,6 +77,7 @@ common_packages:
- systemd-timesyncd - systemd-timesyncd
- neofetch - neofetch
- build-essential - build-essential
- btrfs-progs
# #
# Docker # Docker
@ -90,6 +105,7 @@ aya01_ip: "192.168.20.12"
# #
# mii # mii
# #
mii_host: "mii" mii_host: "mii"
mii_ip: "192.168.200.2" mii_ip: "192.168.200.2"
@ -398,7 +414,7 @@ grafana_data: "{{docker_data_dir}}/grafana/"
grafana_config: "{{docker_dir}}/grafana/config/" grafana_config: "{{docker_dir}}/grafana/config/"
grafana_logs: "{{docker_dir}}/grafana/logs/" grafana_logs: "{{docker_dir}}/grafana/logs/"
grafana_puid: "472" grafana_puid: "472"
grafana_pgid: "0" grafana_pgid: "472"
# #
# SNMP Exporter # SNMP Exporter
@ -408,3 +424,33 @@ snmp_exporter_port: "9116"
snmp_exporter_target: "192.168.20.1" snmp_exporter_target: "192.168.20.1"
snmp_exporter_config: "{{ docker_dir }}/snmp_exporter/" snmp_exporter_config: "{{ docker_dir }}/snmp_exporter/"
snmp_exporter_host: "snmp_exporter" snmp_exporter_host: "snmp_exporter"
#
# Gitlab
#
gitlab:
host: "gitlab"
restart: "unless-stopped"
puid: 998
pgid: 998
paths:
config: "{{ docker_dir }}/gitlab/config/"
logs: "{{ docker_data_dir }}/gitlab/logs/"
data: "{{ docker_data_dir }}/gitlab/data/"
ports:
ssh:
local: 22
remote: 23232
http:
local: 80
remote: 8084
#
# SMART Exporter
#
smart_exporter:
port: 9633
version: 'latest'
options: '--web.listen-address=9633'
bin_path: /usr/local/bin/smart_exporter

View File

@ -75,3 +75,7 @@
- include_tasks: grafana.yml - include_tasks: grafana.yml
tags: tags:
- grafana - grafana
- include_tasks: gitlab.yml
tags:
- gitlab

View File

@ -0,0 +1,14 @@
---
- name: Create gitlab-config
file:
path: "{{ item }}"
owner: "{{ gitlab.puid }}"
group: "{{ gitlab.pgid }}"
mode: '755'
state: directory
become: yes
loop:
- "{{ gitlab.paths.config }}"
- "{{ gitlab.paths.logs }}"
- "{{ gitlab.paths.data }}"

View File

@ -13,12 +13,12 @@
tags: tags:
- reload_compose - reload_compose
- name: Update Docker Images - name: Update docker Images
shell: shell:
cmd: "docker compose pull" cmd: "docker compose pull"
chdir: "{{ docker_compose_dir }}" chdir: "{{ docker_compose_dir }}"
- name: Restart Docker - name: Rebuilding docker images
shell: shell:
cmd: "docker compose up -d --build" cmd: "docker compose up -d --build"
chdir: "{{ docker_compose_dir }}" chdir: "{{ docker_compose_dir }}"

View File

@ -456,6 +456,7 @@ services:
image: grafana/grafana-oss image: grafana/grafana-oss
container_name: {{ grafana_host }} container_name: {{ grafana_host }}
restart: unless-stopped restart: unless-stopped
user: "0:0"
depends_on: depends_on:
- {{ prometheus_host }} - {{ prometheus_host }}
networks: networks:
@ -474,6 +475,29 @@ services:
- "traefik.http.routers.{{ grafana_host }}.rule=Host(`{{ grafana_host }}.{{ aya01_host }}.{{ local_domain }}`)" - "traefik.http.routers.{{ grafana_host }}.rule=Host(`{{ grafana_host }}.{{ aya01_host }}.{{ local_domain }}`)"
- "traefik.http.services.{{ grafana_host }}.loadbalancer.server.port={{ grafana_port }}" - "traefik.http.services.{{ grafana_host }}.loadbalancer.server.port={{ grafana_port }}"
{{ gitlab.host }}:
image: gitlab/gitlab-ce:latest
container_name: {{ gitlab.host }}
restart: {{ gitlab.restart }}
depends_on:
- {{ pihole_host }}
networks:
- net
environment:
- TZ={{ timezone }}
volumes:
- {{ gitlab.paths.config }}:/etc/gitlab/
- {{ gitlab.paths.logs}}:/var/log/gitlab/
- {{ gitlab.paths.data}}:/var/opt/gitlab/
ports:
- {{ gitlab.ports.ssh.remote }}:{{ gitlab.ports.ssh.local }}
- {{ gitlab.ports.http.remote }}:{{ gitlab.ports.http.local }}
shm_size: '256m'
labels:
- "traefik.enable=true"
- "traefik.http.routers.{{ gitlab.host }}.rule=Host(`{{ gitlab.host }}.{{ aya01_host }}.{{ local_domain }}`)"
- "traefik.http.services.{{ gitlab.host }}.loadbalancer.server.port={{ gitlab.ports.http.local }}"
networks: networks:
zoneminder: zoneminder:
driver: bridge driver: bridge

View File

@ -39,3 +39,6 @@ scrape_configs:
target_label: instance target_label: instance
- target_label: __address__ - target_label: __address__
replacement: {{ aya01_ip }}:{{ snmp_exporter_port }} # The SNMP exporter's real hostname:port. replacement: {{ aya01_ip }}:{{ snmp_exporter_port }} # The SNMP exporter's real hostname:port.
- job_name: 'smart'
static_configs:
- targets: ['{{ aya01_ip }}:{{smart_exporter.port}}']

View File

@ -1,8 +0,0 @@
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,18 @@
---
- name: Determine latest GitHub release (local)
delegate_to: localhost
uri:
url: "https://api.github.com/repos/prometheus-community/smartctl_exporter/releases/{{ smart_exporter.version }}"
body_format: json
register: _github_release
until: _github_release.status == 200
retries: 3
- name: Set smart_exporter_version
set_fact:
smart_exporter_version: "{{ _github_release.json.tag_name
| regex_replace('^v?([0-9\\.]+)$', '\\1') }}"
- name: Set smart_exporter_download_url
set_fact:
smart_exporter_download_url: "https://github.com/prometheus-community/smartctl_exporter/releases/download/v{{ smart_exporter_version }}/smartctl_exporter-{{ smart_exporter_version }}.linux-{{ go_arch }}.tar.gz"

View File

@ -0,0 +1,30 @@
---
- name: Download/Extract "{{ smart_exporter_download_url }}"
unarchive:
src: "{{ smart_exporter_download_url }}"
dest: /tmp/
remote_src: true
mode: 755
- name: Move smart_exporter into path
copy:
src: "/tmp/smartctl_exporter-{{ smart_exporter_version }}.linux-{{ go_arch }}/smartctl_exporter"
dest: "{{ smart_exporter.bin_path }}"
mode: 755
remote_src: true
become: true
- name: Create smart_exporter user.
user:
name: smart_exporter
shell: /sbin/nologin
state: present
become: true
- name: Copy the smart_exporter systemd unit file.
template:
src: smart_exporter.service.j2
dest: /etc/systemd/system/smart_exporter.service
mode: 0644
register: smart_exporter_service
become: true

View File

@ -0,0 +1,4 @@
---
- include_tasks: get_version.yml
- include_tasks: install.yml
- include_tasks: systemd.yml

View File

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

View File

@ -0,0 +1,19 @@
[Unit]
Description=smartctl exporter service
After=network-online.target
[Service]
Type=simple
PIDFile=/run/smartctl_exporter.pid
ExecStart={{ smart_exporter.bin_path }}
User=root
Group=root
SyslogIdentifier=smartctl_exporter
Restart=on-failure
RemainAfterExit=no
RestartSec=100ms
StandardOutput=journal
StandardError=journal
[Install]
WantedBy=multi-user.target