Skip to content

Commit

Permalink
Merge pull request #29 from adfinis/feat/playbooks/calculate_quota
Browse files Browse the repository at this point in the history
feat(playbooks): playbook to calculate Bareos Pool quota
  • Loading branch information
adf-patrickha authored Dec 12, 2024
2 parents 698900f + 235f677 commit e2470c1
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions playbooks/calculate_pool_quota.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---

- name: Loop over all pools and calculate maximum disk quota
hosts: localhost
become: false
gather_facts: false
check_mode: true
tasks:
- name: Make sure necessary Pool values are set
ansible.builtin.assert:
quiet: true
that:
- item is defined
- item is iterable
- item.maximum_volume_bytes is defined
- item.maximum_volumes is defined
success_msg: Necessary variables are set.
fail_msg: >-
It looks like no limits are defined for the pool {{ item.name}}!
Make sure maximum_volume_bytes and maximum_volumes are set.
loop: "{{ bareos_dir_pools }}"

- name: Loop over pools to calculta quota
ansible.builtin.set_fact:
_quota: "{{ _quota | default(0) | int + item.maximum_volume_bytes | int * item.maximum_volumes | int }}"
loop: "{{ bareos_dir_pools }}"

- name: Print total customer quota
ansible.builtin.debug:
msg: >-
Total Pool quota is {{ ( _quota | int / 1024 / 1024 / 1024 ) | int }} GB.

0 comments on commit e2470c1

Please sign in to comment.