Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • infrastruktur/ansible-warpzone
  • specki/ansible-warpzone
2 results
Show changes
Commits on Source (1209)
Showing
with 275 additions and 248 deletions
[submodule "functions"]
path = functions
url = ssh://git@gitlab.warpzone.ms:444/infrastruktur/ansible-functions.git
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.1.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files
- id: detect-private-key
- id: fix-encoding-pragma
- id: mixed-line-ending
- repo: https://github.com/ansible/ansible-lint.git
rev: v5.4.0
hooks:
- id: ansible-lint
files: \.(yaml|yml)$
- repo: https://github.com/markdownlint/markdownlint
rev: v0.11.0
hooks:
- id: markdownlint
# Warpzone Infrastruktur Konfiguration
# Warpzone Infrastruktur Konfiguration
Die Infrastruktur der Warpzone wird nach und nach durch das Konfigurationstool Ansible aufgebaut.
Diese Konfiguration wird von den verschiedenen Teams gemeinschaftlich genutzt und soll als zentrale Dokumentation dienen.
Die Infrastruktur der Warpzone wird nach und nach durch das Konfigurationstool Ansible aufgebaut.
Diese Konfiguration soll als zentrale Dokumentation dienen.
## Aktueller Status
# Aktueller Status
Alle Server sind erfasst
## Vorraussetzungen
Installiertes ansible
Ausführen von
```
ansible-galaxy collection install community.docker
```
## Benutzung
Ausführen von Rollen per
```
ansible-playbook -i hosts.yml site.yml -l webserver -t hackmd
```
mit -l wird der hosts eingeschränkt mit -t der tag bzw die Rolle, alle tags stehen in der site.yml
Aktuell ist nur der neue Websserver in der Konfiguration erfasst.
Weitere Dienste (wie z.B. der bestehende Webserver und die interne Infrastruktur) sind noch nicht abgebildet.
rem Vagrant VM für Ansible Arbeitsumgebung
rem Unter Windows müssen die folgenden Git-Einstellungen
rem gesetzt werden damit die Dateien lokal mit LF als Dateiendungen
rem vorliegen:
rem $ git config core.eol lf
rem $ git config core.autocrlf input
rem Vagrant VM Starten
vagrant up
rem SSH Verbindung über PuTTY mit https://github.com/nickryand/vagrant-multi-putty
vagrant putty -- -l vagrant -pw vagrant
pause
rem Vagrant VM Stoppen
vagrant halt
Vagrant.configure(2) do |config|
# Debian Jessie + VirtualBox Addons
config.vm.box = "debian/contrib-jessie64"
# Hostname
config.vm.hostname = "box"
# Customize
config.vm.provider "virtualbox" do |vb|
vb.memory = "512"
vb.cpus = 2
vb.linked_clone = true
end
# Enable Agent forwarding
config.ssh.forward_agent = true
config.vm.provision "shell", inline: <<-SHELL
echo "######################################################"
echo "Setup Debian Testing ..."
echo "######################################################"
echo "deb http://httpredir.debian.org/debian testing main contrib non-free" > /etc/apt/sources.list
echo "deb http://security.debian.org/ testing/updates main contrib non-free" >> /etc/apt/sources.list
sudo apt-get update
# Avoid service sestart question if libc is upgraded
echo 'libc6 libraries/restart-without-asking boolean true' | sudo debconf-set-selections
echo "######################################################"
echo "Installing Vim ..."
echo "######################################################"
sudo apt-get install -y vim
echo "######################################################"
echo "Installing Git ..."
echo "######################################################"
sudo apt-get install -y git
echo "######################################################"
echo "Installing Fish Shell ..."
echo "######################################################"
sudo apt-get install -y fish
# Set FiSH Shell as default Login Shell
sudo chsh -s /usr/bin/fish vagrant
# Create a FiSH base config
mkdir -p -v /home/vagrant/.config/fish/
curl https://raw.githubusercontent.com/elberfeld/fish/master/config.fish > /home/vagrant/.config/fish/config.fish
chown vagrant:vagrant -v -R /home/vagrant/.config
# Change to /vagrant/ directory on Login
echo "cd /vagrant/" >> /home/vagrant/.config/fish/config.fish
echo "######################################################"
echo "Installing Ansible ..."
echo "######################################################"
sudo apt-get install -y python python-pip python-dev libffi6 libffi-dev libssl-dev sshpass
sudo pip install ansible markupsafe netaddr
echo " StrictHostKeyChecking no" >> /etc/ssh/ssh_config
echo "[defaults]" > /home/vagrant/.ansible.cfg
echo "inventory = /vagrant/hosts" >> /home/vagrant/.ansible.cfg
echo "######################################################"
echo "DONE"
echo "######################################################"
SHELL
end
......@@ -4,44 +4,58 @@
- name: create motd file
template: src=motd.j2 dest=/etc/motd
- name: install apt-transport-https packages before adding sources
- name: install apt-transport-https packages before adding sources
apt:
pkg: "{{ item }}"
update_cache: yes
state: installed
with_items:
- apt-transport-https
name: "{{ packages }}"
update_cache: no
state: present
vars:
packages:
- apt-transport-https
- ca-certificates
- curl
- gnupg2
- software-properties-common
- name: add debian repo keys (id)
apt_key:
id: "{{ item }}"
state: present
with_items: "{{ debian_keys_id }}"
when: debian_keys_id
- name: add debian repo keys
- name: add debian repo keys (url)
apt_key:
url: "{{ item }}"
state: present
with_items: "{{ debian_keys }}"
when: debian_keys
with_items: "{{ debian_keys_url }}"
when: debian_keys_url
- name: set debian repos
template: src=sources.list.j2 dest=/etc/apt/sources.list
- name: set debian repos
template: src=sources.list.j2 dest=/etc/apt/sources.list
- name: install common packages
apt:
pkg: "{{ item }}"
name: "{{ packages }}"
update_cache: yes
state: installed
with_items:
- vim
- wget
- psmisc
- tree
- name: deploy sshd config
template: src=sshd_config.j2 dest=/etc/ssh/sshd_config
notify: restart sshd
state: present
vars:
packages:
- vim
- wget
- psmisc
- tree
- tmux
- mosh
- name: deploy sshd config
template: src=sshd_config.j2 dest=/etc/ssh/sshd_config
notify: restart sshd
- name: add sshkeys for server
authorized_key:
user: root
key: "{{ lookup('file', '../keyfiles/' + item + '.pub') }}"
authorized_key:
user: root
key: "{{ lookup('file', 'keyfiles/' + item + '.pub') }}"
with_items: "{{ administratorenteam }}"
when: administratorenteam
notify: restart sshd
notify: restart sshd
......@@ -16,7 +16,6 @@ Port {{ port }}
Protocol 2
# HostKeys for protocol version 2
HostKey /etc/ssh/ssh_host_rsa_key
HostKey /etc/ssh/ssh_host_dsa_key
HostKey /etc/ssh/ssh_host_ecdsa_key
HostKey /etc/ssh/ssh_host_ed25519_key
#Privilege Separation is turned on for security
......@@ -34,7 +33,7 @@ LogLevel INFO
# Authentication:
LoginGraceTime 120
PermitRootLogin without-password
PermitRootLogin prohibit-password
StrictModes yes
RSAAuthentication yes
......
---
# Globale Konfiguration für alle Server
- hosts: all
remote_user: root
roles:
- { role: hostname, tags: common }
- { role: common, tags: common }
- name: Ensure mount directories exist for non-root drives
ansible.builtin.file:
path: "{{ item.value.path }}"
state: directory
mode: '0755'
loop: "{{ lookup('dict', drives) }}"
when: drives is defined and item.value.fstype != "swap" and item.value.path != "/"
- name: Mount all drives (excluding swap)
ansible.builtin.mount:
path: "{{ item.value.path }}"
src: "UUID={{ item.value.uuid }}"
fstype: "{{ item.value.fstype }}"
state: mounted
loop: "{{ lookup('dict', drives) }}"
when: drives is defined and item.value.fstype != "swap"
- name: Ensure swap entry is present in /etc/fstab
ansible.builtin.lineinfile:
path: /etc/fstab
state: present
line: "UUID={{ item.value.uuid }} none swap sw 0 0"
loop: "{{ lookup('dict', drives) }}"
when: drives is defined and item.value.fstype == "swap"
- name: Enable swap partition
ansible.builtin.command:
cmd: "swapon UUID={{ item.value.uuid }}"
loop: "{{ lookup('dict', drives) }}"
when: drives is defined and item.value.fstype == "swap"
\ No newline at end of file
---
# set general sysctl.conf settings
# the module will reload the setting so they are applied without reboot
# minimize usage of swap
- sysctl:
name: vm.swappiness
value: '1'
state: present
when: (host_type == "physical") or (host_type == "vm")
[defaults]
# some default values for ansible
inventory = hosts.yml
interpreter_python = /usr/bin/python3
......@@ -2,25 +2,29 @@
# Pakete installieren
- name: pakete installieren
apt:
pkg: "{{ item }}"
name: "{{ packages }}"
update_cache: yes
state: installed
with_items:
state: present
vars:
packages:
- borgbackup
- logrotate
- moreutils
- openssl
- name: create directory
- name: create directories 1
file:
path: "/srv/borgbackup/"
path: "{{ item }}"
state: "directory"
with_items:
- /srv/borgbackup
- /var/log/borgbackup
- name: create directories
- name: create directories 2
file:
path: "/srv/borgbackup/{{ item }}"
path: "/srv/borgbackup/{{ item.key }}"
state: "directory"
with_items: "{{ borgbackup_repos }}"
with_dict: "{{ borgbackup_repos }}"
- name: generate new repo_passphrase (check)
stat:
......@@ -53,23 +57,61 @@
# BorgBackup Scripte erstellen
- name: BorgBackup Scripte erstellen
template: src={{ item }} dest=/srv/borgbackup/{{ item }} mode=o+x
with_items:
- "borgbackup-check.sh"
- "borgbackup-create.sh"
- "borgbackup-delete.sh"
- "borgbackup-info.sh"
- "borgbackup-init.sh"
- "borgbackup-list.sh"
- "borgbackup-mount.sh"
- "borgbackup-prometheus.sh"
- name: BorgBackup log folder erstellen
file:
path: "/var/log/borgbackup"
state: "directory"
- name: BorgBackup Scripte erstellen (check)
template:
src: borgbackup-check.sh
dest: /srv/borgbackup/{{ item.key }}/borgbackup-check.sh
mode: u+x
with_dict: "{{ borgbackup_repos }}"
- name: BorgBackup Scripte erstellen (create)
template:
src: borgbackup-create.sh
dest: /srv/borgbackup/{{ item.key }}/borgbackup-create.sh
mode: u+x
with_dict: "{{ borgbackup_repos }}"
- name: BorgBackup Scripte erstellen (delete)
template:
src: borgbackup-delete.sh
dest: /srv/borgbackup/{{ item.key }}/borgbackup-delete.sh
mode: u+x
with_dict: "{{ borgbackup_repos }}"
- name: BorgBackup Scripte erstellen (init)
template:
src: borgbackup-init.sh
dest: /srv/borgbackup/{{ item.key }}/borgbackup-init.sh
mode: u+x
with_dict: "{{ borgbackup_repos }}"
- name: BorgBackup Scripte erstellen (info)
template:
src: borgbackup-info.sh
dest: /srv/borgbackup/{{ item.key }}/borgbackup-info.sh
mode: u+x
with_dict: "{{ borgbackup_repos }}"
- name: BorgBackup Scripte erstellen (list)
template:
src: borgbackup-list.sh
dest: /srv/borgbackup/{{ item.key }}/borgbackup-list.sh
mode: u+x
with_dict: "{{ borgbackup_repos }}"
- name: BorgBackup Scripte erstellen (mount)
template:
src: borgbackup-mount.sh
dest: /srv/borgbackup/{{ item.key }}/borgbackup-mount.sh
mode: u+x
with_dict: "{{ borgbackup_repos }}"
- name: BorgBackup Scripte erstellen (prometheus)
template:
src: borgbackup-prometheus.sh
dest: /srv/borgbackup/borgbackup-prometheus.sh
mode: u+x
- name: BorgBackup LogRotate config erstellen
template:
src: logrotate
......@@ -81,8 +123,9 @@
state: absent
- name: Cronjob für BorgBackup Backup
cron: name="borgbackup-create" weekday="{{borgbackup_weekday}}" hour="{{borgbackup_hour}}" minute="{{borgbackup_minute}}" job="/srv/borgbackup/borgbackup-create.sh 2>&1 | ts '[\\%Y-\\%m-\\%d \\%H:\\%M:\\%S]' >> /var/log/borgbackup/borgbackup.log"
cron: name="borgbackup-{{ item.key }}" weekday="{{ item.value.weekday }}" hour="{{ item.value.hour }}" minute="{{ item.value.minute }}" job="/srv/borgbackup/{{ item.key }}/borgbackup-create.sh 2>&1 | ts '[\\%Y-\\%m-\\%d \\%H:\\%M:\\%S]' >> /var/log/borgbackup/{{ item.key }}.log"
with_dict: "{{ borgbackup_repos }}"
- name: Cronjob für BorgBackup Prometheus export
cron: name="borgbackup-prom" weekday="*" hour="*" minute="0" job="/srv/borgbackup/borgbackup-prometheus.sh 2>&1 | ts '[\\%Y-\\%m-\\%d \\%H:\%M:\\%S]' >> /var/log/borgbackup/borgbackup.log"
cron: name="borgbackup-prom" weekday="*" hour="*" minute="0" job="/srv/borgbackup/borgbackup-prometheus.sh 2>&1 | ts '[\\%Y-\\%m-\\%d \\%H:\%M:\\%S]' >> /var/log/borgbackup/borgbackup-prometheus.log"
......@@ -5,10 +5,6 @@
export BORG_PASSPHRASE="{{repo_passphrase}}"
export BORG_RSH="ssh -i /srv/borgbackup/repo_sshkey"
echo "===[ Check Repo: {{ item.value.repo }} ]==="
borg check $1 $2 $3 --info --show-rc {{ item.value.options }} {{ item.value.repo }}
{% for repo_url in borgbackup_repos %}
echo "===[ Check Repo: {{repo_url}} ]============================================================"
borg check $1 $2 $3 --info --show-rc --remote-path borg1 {{repo_url}}
{% endfor %}
\ No newline at end of file
......@@ -3,25 +3,42 @@
export BORG_PASSPHRASE="{{repo_passphrase}}"
export BORG_RSH="ssh -i /srv/borgbackup/repo_sshkey"
export BACKUP_DATE=`date +%Y-%m-%d_%H_%M`
export LAST_BACKUPS_PROM="/var/lib/prometheus/node-exporter/lastbackup.prom"
# Ausführung der Backups
# anschließend Bereinigung
# abschließend Integritätscheck
{% for repo_url in borgbackup_repos %}
echo "===[ Create Backup: {{repo_url}} ]============================================================"
borg create $1 $2 $3 --info --show-rc --remote-path borg1 --stats --compression lzma,2 {{repo_url}}::$BACKUP_DATE \
echo "===[ Create Backup: {{ item.value.repo }} ]===" \
&& \
borg create $1 $2 $3 --info --show-rc --stats --exclude *lost+found --compression {{ item.value.compression }} {{ item.value.options }} {{ item.value.repo }}::$BACKUP_DATE \
{% for directory in borgbackup_directories %}
{{ directory }} \
{% endfor %}
{% endfor %} \
{% if item.value.directories is defined %}
{% for directory in item.value.directories %}
{{ directory }} \
{% endfor %} \
{% endif %}
&& \
borg prune $1 $2 $3 --info --show-rc --list {{repo_url}} \
{% for prune in borgbackup_prune %}
{{ prune }} \
{% endfor %}
echo "===[ Prune old Backups: {{ item.value.repo }} ]===" \
&& \
borg check $1 $2 $3 --info --show-rc {{repo_url}}
{% endfor %}
borg prune $1 $2 $3 --info --show-rc --list {{ item.value.prune }} {{ item.value.options }} {{ item.value.repo }} \
&& \
echo "===[ Check Repo: {{ item.value.repo }} ]===" \
&& \
borg check $1 $2 $3 --info --show-rc {{ item.value.options }} {{ item.value.repo }} \
&& \
echo "===[ write: /srv/rsyncbackup/{{ item.key }}/lastbackup ]===" \
&& \
date > "/srv/borgbackup/{{ item.key }}/lastbackup" \
&& \
echo "===[ add value to: $LAST_BACKUPS_PROM ]===" \
&& \
touch $LAST_BACKUPS_PROM \
&& \
sed -i '/borgbackup_lastbackup{repo="{{ item.key }}"}/d' $LAST_BACKUPS_PROM \
&& \
echo "borgbackup_lastbackup{repo=\"{{ item.key }}\"} $(date +%s)" >> $LAST_BACKUPS_PROM \
&& \
echo "===[ DONE ]==="
......@@ -5,20 +5,11 @@ export BORG_RSH="ssh -i /srv/borgbackup/repo_sshkey"
# Löschen eines Backups
echo "Available Repos: "
{% for repo_url in borgbackup_repos %}
echo "{{repo_url}}"
{% endfor %}
echo "RepoName, followed by [ENTER]:"
read repo_url
echo "Available Backups: "
borg list $1 $2 $3 --info --show-rc --remote-path borg1 $repo_url
borg list $1 $2 $3 --info --show-rc {{ item.value.options }} {{ item.value.repo }}
echo "BackupName, followed by [ENTER]:"
read target
borg delete $1 $2 $3 --info --show-rc --remote-path borg1 $repo_url::$target
borg delete $1 $2 $3 --info --show-rc {{ item.value.options }} {{ item.value.repo }}::$target
......@@ -5,12 +5,11 @@ export BORG_RSH="ssh -i /srv/borgbackup/repo_sshkey"
# Anzeige des Inhaltes in den Borg Backup Archiven
{% for repo_url in borgbackup_repos %}
echo "============================================="
echo "Backups Repo Info: {{ item.key }} "
BACKUPS=$(borg list $1 $2 $3 --info --show-rc --remote-path borg1 {{repo_url}})
BACKUPS=$(borg list $1 $2 $3 --info --show-rc {{ item.value.options }} {{ item.value.repo }})
echo "============================================="
echo "Backups List "
echo "$BACKUPS"
BACKUPS_LIST=$(echo "$BACKUPS" | awk '{print $1}')
......@@ -19,11 +18,10 @@ for BACKUP in $BACKUPS_LIST; do
echo "============================================="
borg info $1 $2 $3 --info --show-rc --remote-path borg1 {{repo_url}}::$BACKUP
borg info $1 $2 $3 --info --show-rc {{ item.value.options }} {{ item.value.repo }}::$BACKUP
done
echo "============================================="
{% endfor %}
......@@ -6,18 +6,15 @@
export BORG_PASSPHRASE="{{repo_passphrase}}"
export BORG_RSH="ssh -i /srv/borgbackup/repo_sshkey"
{% for repo_url in borgbackup_repos %}
if [ ! -e "/srv/borgbackup/{{ item.key }}/initialized" ]; then
if [ ! -e "{{repo_url}}.initialized" ]; then
echo "Initialize Repo: {{ item.key }}"
date > "/srv/borgbackup/{{ item.key }}/initialized"
echo "Initialize Repo: {{repo_url}}"
date > "{{repo_url}}.initialized"
borg init $1 $2 $3 --info --show-rc --remote-path borg1 --encryption=repokey {{repo_url}}
borg init $1 $2 $3 --info --show-rc --encryption=repokey {{ item.value.options }} {{ item.value.repo }}
else
echo "Repo already initialized: {{repo_url}}"
echo "Repo already initialized: {{ item.key }}"
fi
{% endfor %}
......@@ -5,10 +5,7 @@ export BORG_RSH="ssh -i /srv/borgbackup/repo_sshkey"
# Anzeige des Inhaltes in den Borg Backup Archiven
{% for repo_url in borgbackup_repos %}
echo "===[ List Repo: {{ item.key }} ]==="
borg list $1 $2 $3 --info --show-rc {{ item.value.options }} {{ item.value.repo }}
echo "===[ List Repo: {{repo_url}} ]============================================================"
borg list $1 $2 $3 --info --show-rc --remote-path borg1 {{repo_url}}
{% endfor %}
......@@ -5,17 +5,8 @@ export BORG_RSH="ssh -i /srv/borgbackup/repo_sshkey"
# Einhängen der Repos in /mnt/
echo "Available Repos: "
echo "Directory to mount, followed by [ENTER]:"
read target
{% for repo_url in borgbackup_repos %}
echo "{{repo_url}}"
{% endfor %}
echo "RepoName, followed by [ENTER]:"
read repo_url
echo -n 'Mounting to: /mnt'
mkdir /mnt/
borg mount $1 $2 $3 --info --show-rc --remote-path borg1 $repo_url /mnt/
borg mount $1 $2 $3 --info --show-rc {{ item.value.options }} {{ item.value.repo }} $target
......@@ -3,6 +3,9 @@
export BORG_PASSPHRASE="{{repo_passphrase}}"
export BORG_RSH="ssh -i /srv/borgbackup/repo_sshkey"
# Force locale for correct formatting
LANG=en_US.UTF-8
# Metrics output file in the prometheus node-exporter directory
PROM_FILE="/var/lib/prometheus/node-exporter/borgbackup.prom"
......@@ -28,11 +31,14 @@ function calc_bytes {
esac
}
echo "borgbackup_repos_count {{borgbackup_repos|length}}" > $TMP_FILE
# create temp file
TMP_FILE=$(mktemp)
echo "borgbackup_repos_count {{ borgbackup_repos|length }}" > $TMP_FILE
{% for repo_url in borgbackup_repos %}
{% for repo in borgbackup_repos %}
BACKUPS=$(borg list --remote-path borg1 {{repo_url}})
BACKUPS=$(borg list {{ borgbackup_repos[repo].options }} {{ borgbackup_repos[repo].repo }})
BACKUPS_LIST=$(echo "$BACKUPS" | awk '{print $1}')
COUNTER=0
......@@ -42,15 +48,12 @@ for BACKUP in $BACKUPS_LIST; do
done
BORG_INFO=$(borg info --remote-path borg1 {{repo_url}}::$BACKUP)
# create temp file
TMP_FILE=$(mktemp)
BORG_INFO=$(borg info {{ borgbackup_repos[repo].options }} {{ borgbackup_repos[repo].repo }}::$BACKUP)
echo "borgbackup_count{repo="{{ repo_url }}"} $COUNTER" > $TMP_FILE
echo "borgbackup_files{repo="{{ repo_url }}"} $(echo "$BORG_INFO" | grep "Number of files" | awk '{print $4}')" >> $TMP_FILE
echo "borgbackup_chunks_unique{repo="{{ repo_url }}"} $(echo "$BORG_INFO" | grep "Chunk index" | awk '{print $3}')" >> $TMP_FILE
echo "borgbackup_chunks_total{repo="{{ repo_url }}"} $(echo "$BORG_INFO" | grep "Chunk index" | awk '{print $4}')" >> $TMP_FILE
echo "borgbackup_count{repo=\"{{ repo }}\"} $COUNTER" >> $TMP_FILE
echo "borgbackup_files{repo=\"{{ repo }}\"} $(echo "$BORG_INFO" | grep "Number of files" | awk '{print $4}')" >> $TMP_FILE
echo "borgbackup_chunks_unique{repo=\"{{ repo }}\"} $(echo "$BORG_INFO" | grep "Chunk index" | awk '{print $3}')" >> $TMP_FILE
echo "borgbackup_chunks_total{repo=\"{{ repo }}\"} $(echo "$BORG_INFO" | grep "Chunk index" | awk '{print $4}')" >> $TMP_FILE
# byte size calculation
LAST_SIZE=$(calc_bytes $(echo "$BORG_INFO" |grep "This archive" |awk '{print $3}') $(echo "$BORG_INFO" |grep "This archive" |awk '{print $4}'))
......@@ -60,12 +63,12 @@ TOTAL_SIZE=$(calc_bytes $(echo "$BORG_INFO" |grep "All archives" |awk '{print $3
TOTAL_SIZE_COMPRESSED=$(calc_bytes $(echo "$BORG_INFO" |grep "All archives" |awk '{print $5}') $(echo "$BORG_INFO" |grep "All archives" |awk '{print $6}'))
TOTAL_SIZE_DEDUP=$(calc_bytes $(echo "$BORG_INFO" |grep "All archives" |awk '{print $7}') $(echo "$BORG_INFO" |grep "All archives" |awk '{print $8}'))
echo "borgbackup_last_size{repo="{{ repo_url }}"} $LAST_SIZE" >> $TMP_FILE
echo "borgbackup_last_size_compressed{repo="{{ repo_url }}"} $LAST_SIZE_COMPRESSED" >> $TMP_FILE
echo "borgbackup_last_size_dedup{repo="{{ repo_url }}"} $LAST_SIZE_DEDUP" >> $TMP_FILE
echo "borgbackup_total_size{repo="{{ repo_url }}"} $TOTAL_SIZE" >> $TMP_FILE
echo "borgbackup_total_size_compressed{repo="{{ repo_url }}"} $TOTAL_SIZE_COMPRESSED" >> $TMP_FILE
echo "borgbackup_total_size_dedup{repo="{{ repo_url }}"} $TOTAL_SIZE_DEDUP" >> $TMP_FILE
echo "borgbackup_last_size{repo=\"{{ repo }}\"} $LAST_SIZE" >> $TMP_FILE
echo "borgbackup_last_size_compressed{repo=\"{{ repo }}\"} $LAST_SIZE_COMPRESSED" >> $TMP_FILE
echo "borgbackup_last_size_dedup{repo=\"{{ repo }}\"} $LAST_SIZE_DEDUP" >> $TMP_FILE
echo "borgbackup_total_size{repo=\"{{ repo }}\"} $TOTAL_SIZE" >> $TMP_FILE
echo "borgbackup_total_size_compressed{repo=\"{{ repo }}\"} $TOTAL_SIZE_COMPRESSED" >> $TMP_FILE
echo "borgbackup_total_size_dedup{repo=\"{{ repo }}\"} $TOTAL_SIZE_DEDUP" >> $TMP_FILE
{% endfor %}
......@@ -73,5 +76,5 @@ echo "borgbackup_total_size_dedup{repo="{{ repo_url }}"} $TOTAL_SIZE_DEDUP" >> $
mv $TMP_FILE $PROM_FILE
chown prometheus:prometheus $PROM_FILE
echo "created BorgBackup statistic for $COUNTER backups in $PROM_FILE"
echo "created BorgBackup statistic for {{ borgbackup_repos|length }} repos: $PROM_FILE"