-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from Mikroways/feature/better-prometheus-exporter
Feature/better prometheus exporter
- Loading branch information
Showing
30 changed files
with
540 additions
and
365 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
layout pyenv 3.9.9 | ||
use asdf | ||
layout python | ||
export PY_COLORS=1 | ||
export ANSIBLE_FORCE_COLOR=1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,51 @@ | ||
--- | ||
# defaults file for skeleton | ||
restic_url: '{{ restic_url_default }}' | ||
restic_version: '0.12.0' | ||
restic_version: '0.16.0' | ||
restic_download_path: '/opt/restic' | ||
restic_install_path: '/usr/bin' | ||
restic_cache_dir: /var/cache/restic | ||
restic_verify_pgp_url: https://restic.net/gpg-key-alex.asc | ||
restic_verify_dir: '{{ restic_cache_dir }}/.verify' | ||
restic_script_dir: '{{ restic_download_path }}/scripts' | ||
restic_repos: {} | ||
restic_backups: [] | ||
restic_prune_repositories: [] | ||
restic_prune_enabled: false | ||
restic_create_systemd_timer: false | ||
restic_skip_handlers: false | ||
restic_skip_checksum_verify: true | ||
|
||
restic_dir_owner: '{{ ansible_user | default(ansible_user_id) }}' | ||
restic_dir_group: '{{ ansible_user | default(ansible_user_id) }}' | ||
restic_dir_owner: 'root' | ||
restic_dir_group: 'root' | ||
|
||
restic_access_template: restic_access.j2 | ||
restic_backup_template: restic_backup.j2 | ||
restic_prune_template: restic_prune.j2 | ||
restic_forget_template: restic_forget.j2 | ||
restic_stats_template: restic_stats.j2 | ||
restic_systemd_timer_template: systemd_timer.unit.j2 | ||
restic_systemd_forget_service_template: systemd_forget.unit.j2 | ||
restic_systemd_forget_timer_template: systemd_forget.timer.j2 | ||
restic_systemd_prune_service_template: systemd_forget.unit.j2 | ||
restic_systemd_prune_timer_template: systemd_forget.timer.j2 | ||
restic_systemd_service_template: systemd_service.unit.j2 | ||
restic_systemd_failure_service_template: systemd_failure.unit.j2 | ||
restic_systemd_failure_service_name: '[email protected]' | ||
|
||
restic_prometehus_exporter_enabled: false | ||
restic_prometehus_exporter_template: restic_prometehus_exporter.j2 | ||
restic_prometehus_exporter_script: '{{ restic_script_dir }}/restic_prometehus_exporter.sh' | ||
restic_prometehus_exporter_metrics_basedir: /var/lib/node-exporter | ||
|
||
restic_prometheus_exporter_enabled: false | ||
restic_prometheus_exporter_template: restic_prometheus_exporter.j2 | ||
restic_prometheus_exporter_script: '{{ restic_script_dir }}/restic-prometheus-exporter' | ||
restic_prometheus_exporter_metrics_basedir: /var/lib/node_exporter | ||
restic_prometheus_exporter_repositories: [] | ||
restic_systemd_prometheus_service_template: restic-prometheus-service.unit.j2 | ||
restic_systemd_prometheus_service_prefix_name: 'restic-prometheus_exporter@' | ||
restic_systemd_prometheus_service_name: '{{ restic_systemd_prometheus_service_prefix_name}}.service' | ||
restic_systemd_prometheus_timer_template: restic-prometheus-timer.unit.j2 | ||
restic_prune_template: restic-prune.j2 | ||
restic_systemd_prune_service_template: restic-prune-service.unit.j2 | ||
restic_systemd_prune_service_prefix_name: 'restic-prune@' | ||
restic_systemd_prune_service_name: '{{ restic_systemd_prune_service_prefix_name}}.service' | ||
restic_systemd_prune_timer_template: restic-prune-timer.unit.j2 | ||
restic_failure_template: restic_failure_unit.j2 | ||
restic_failure_script: '{{ restic_script_dir }}/unit-failure' | ||
restic_failure_mail_to: "root" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
jmespath | ||
urllib3<2 | ||
tox==4.0.0b2 | ||
ansible==5.* | ||
molecule[docker] | ||
molecule-plugins[docker] | ||
docker == 5.* | ||
ansible-lint == 5.* | ||
yamllint == 1.26.* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
--- | ||
- name: Install dependencies | ||
block: | ||
- name: update apt cache | ||
ansible.builtin.apt: | ||
update_cache: yes | ||
when: ansible_pkg_mgr == "apt" | ||
- name: update yum cache | ||
ansible.builtin.yum: | ||
update_cache: yes | ||
when: ansible_pkg_mgr == "yum" | ||
- name: update dnf cache | ||
ansible.builtin.dnf: | ||
update_cache: yes | ||
when: ansible_pkg_mgr == "dnf" | ||
- name: install jq | ||
ansible.builtin.package: | ||
name: jq | ||
|
||
- name: Ensure prometehus metrics file can be created | ||
file: | ||
state: 'directory' | ||
path: '{{ restic_prometheus_exporter_metrics_basedir }}' | ||
mode: '0755' | ||
owner: 'root' | ||
group: 'root' | ||
|
||
- name: Configure prometehus exporter script | ||
template: | ||
src: '{{ restic_prometheus_exporter_template }}' | ||
dest: '{{ restic_prometheus_exporter_script }}' | ||
mode: '0700' | ||
owner: '{{ _restic_user }}' | ||
group: '{{ _restic_group }}' | ||
|
||
- name: Create dummy_list of restic_credentials | ||
set_fact: | ||
exporters_repos: > | ||
{{ exporters_repos | default([]) + | ||
[ item | combine({"repo": item.name, "src": '/'}) ] }} | ||
with_items: '{{ restic_prometheus_exporter_repositories }}' | ||
|
||
- name: Create restic access credentials | ||
template: | ||
src: '{{ restic_access_template }}' | ||
dest: '{{ restic_script_dir }}/access-prometheus-{{ item.name }}.sh' | ||
mode: '0400' | ||
owner: '{{ _restic_user }}' | ||
group: '{{ _restic_group }}' | ||
# no_log: true | ||
with_items: '{{ exporters_repos }}' | ||
|
||
- name: "Add systemd service restic-prometheus" | ||
template: | ||
src: "{{ restic_systemd_prometheus_service_template }}" | ||
dest: "/etc/systemd/system/{{ restic_systemd_prometheus_service_name }}" | ||
mode: "0644" | ||
owner: root | ||
group: root | ||
notify: | ||
- Reload systemd | ||
|
||
- name: "Add systemd timer restic-prometheus {{ item.name }}" | ||
template: | ||
src: "{{ restic_systemd_prometheus_timer_template }}" | ||
dest: "/etc/systemd/system/{{ restic_systemd_prometheus_service_prefix_name }}{{ item.name}}.timer" | ||
mode: "0644" | ||
owner: root | ||
group: root | ||
notify: | ||
- Reload systemd | ||
when: | ||
- item.schedules is defined | ||
- item.schedules | length > 0 | ||
with_items: "{{ restic_prometheus_exporter_repositories }}" | ||
|
||
- name: "Enable systemd restic exporter for {{ item.name }} timer" | ||
ansible.builtin.systemd: | ||
name: "{{ restic_systemd_prometheus_service_prefix_name }}{{ item.name }}.timer" | ||
enabled: true | ||
state: "restarted" | ||
when: | ||
- item.schedules is defined | ||
- item.schedules | length > 0 | ||
with_items: "{{ restic_prometheus_exporter_repositories }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
--- | ||
- name: Create dummy_list of restic_credentials for restic_prune_repositories | ||
set_fact: | ||
prune_repos: > | ||
{{ prune_repos | default([]) + | ||
[ item | combine({"repo": item.name, "src": '/'}) ] }} | ||
with_items: '{{ restic_prune_repositories }}' | ||
|
||
- name: Create restic access credentials | ||
template: | ||
src: '{{ restic_access_template }}' | ||
dest: '{{ restic_script_dir }}/access-prune-{{ item.name }}.sh' | ||
mode: '0400' | ||
owner: '{{ _restic_user }}' | ||
group: '{{ _restic_group }}' | ||
no_log: true | ||
with_items: '{{ prune_repos }}' | ||
|
||
- name: Configure restic prune script | ||
template: | ||
src: '{{ restic_prune_template }}' | ||
dest: '{{ restic_script_dir }}/backup-prune-{{ item.name }}.sh' | ||
mode: '0700' | ||
owner: '{{ _restic_user }}' | ||
group: '{{ _restic_group }}' | ||
with_items: '{{ prune_repos }}' | ||
when: | ||
- item.name is defined | ||
- item.repo in restic_repos | ||
|
||
- name: "Add systemd service restic-prune" | ||
template: | ||
src: "{{ restic_systemd_prune_service_template }}" | ||
dest: "/etc/systemd/system/{{ restic_systemd_prune_service_name }}" | ||
mode: "0644" | ||
owner: root | ||
group: root | ||
notify: | ||
- Reload systemd | ||
|
||
- name: "Add systemd timer restic-prune {{ item.name }}" | ||
template: | ||
src: "{{ restic_systemd_prune_timer_template }}" | ||
dest: "/etc/systemd/system/{{ restic_systemd_prune_service_prefix_name }}{{ item.name}}.timer" | ||
mode: "0644" | ||
owner: root | ||
group: root | ||
notify: | ||
- Reload systemd | ||
when: | ||
- item.schedules is defined | ||
- item.schedules | length > 0 | ||
with_items: "{{ restic_prune_repositories }}" | ||
|
||
- name: "Enable systemd restic-prune for {{ item.name }} timer" | ||
ansible.builtin.systemd: | ||
name: "{{ restic_systemd_prune_service_prefix_name }}{{ item.name }}.timer" | ||
enabled: true | ||
state: "restarted" | ||
when: | ||
- item.schedules is defined | ||
- item.schedules | length > 0 | ||
with_items: "{{ restic_prune_repositories }}" |
Oops, something went wrong.