Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: creating reports on ZFS datasets #3

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions inventory.production.ini
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
# Declare all servers here with their configuration variables
# Please sort it alphabetically

[all:vars]
[monitoring]
monitoring-01 ansible_ssh_host=34.1.5.157

[ovh]
ovh1 ansible_ssh_host=146.59.148.140
ovh2 ansible_ssh_host=51.210.154.203
ovh3 ansible_ssh_host=51.210.32.79

[free]
off1 ansible_ssh_host=213.36.253.206
off2 ansible_ssh_host=213.36.253.208

# servers that are configured using this repository
[ops_installed:children]
monitoring

[ops_installed:vars]
ansible_ssh_user=debian
host_domain=infra.openfoodfacts.org
ansible_host='{{ inventory_hostname }}.{{ host_domain }}'

[monitoring]
monitoring-01 ansible_ssh_host=34.1.5.157
4 changes: 3 additions & 1 deletion jobs/configure.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
- name: Common configuration
hosts: all
# limit to host that were configured using this role
hosts:
- ops_installed
gather_facts: true
become: true
roles:
Expand Down
12 changes: 12 additions & 0 deletions jobs/reporting.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
# The goal of this job is to generate a reports
# of the current state of the servers
# than can either serve as documentation of the architecture
# or as a mean to check some requirements are met
# (like number of backups replications)
- name: Generate servers reports
hosts: all
gather_facts: true
become: true
roles:
- role: zfs_report
5 changes: 5 additions & 0 deletions roles/zfs_report/tasks/display_dataset.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
- ansible.builtin.debug:
msg: "{{ zpool_name }}"
- ansible.builtin.debug:
msg: "- {{ item.name }}"
loop: "{{ datasets }}"
22 changes: 22 additions & 0 deletions roles/zfs_report/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
- name: "Get all ZFS pools"
community.general.zpool_facts:
parsable: true

- name: "Get all ZFS datasets"
community.general.zfs_facts:
name: "{{ item.name }}"
parsable: true
recurse: true
type: volume
with_items: "{{ ansible_zfs_pools }}"
register: zfs_data

- ansible.builtin.include_tasks:
file: display_dataset.yml
apply:
vars:
datasets: "{{ zfs_data_item.ansible_facts.ansible_zfs_datasets }}"
zpool_name: "{{ zfs_data_item.name }}"
with_items: "{{ zfs_data.results }}"
loop_control:
loop_var: zfs_data_item
Loading