New role for gathering detailed system information including CPU, GPU,
RAM, disk, network, and hypervisor details with JSON export capabilities.
Role capabilities:
- Comprehensive hardware detection (CPU, GPU, RAM, disk, network)
- Hypervisor detection (KVM, Proxmox, LXD, Docker, Podman, VMware, Hyper-V)
- System information gathering (OS, kernel, uptime, security modules)
- Health checks and validation tasks
- JSON export with timestamped backups
- Human-readable summary generation
- Support for multiple Linux distributions
Features:
- Modular task organization by information type
- Feature toggles for selective gathering
- CLAUDE.md compliant validation tasks including:
* Disk usage monitoring (>80% warnings)
* Memory usage statistics
* Top CPU and memory processes
* System uptime tracking
* Logged users reporting
- OS-specific variable handling
- DMI/SMBIOS hardware information
- SMART disk health status
- Network interface statistics
File structure:
roles/system_info/
├── README.md # Comprehensive documentation
├── defaults/main.yml # Configurable defaults
├── vars/main.yml # Role variables
├── meta/main.yml # Galaxy metadata
├── tasks/
│ ├── main.yml # Main task coordinator
│ ├── install.yml # Package installation
│ ├── gather_system.yml # OS and system info
│ ├── gather_cpu.yml # CPU details
│ ├── gather_gpu.yml # GPU detection
│ ├── gather_memory.yml # RAM information
│ ├── gather_disk.yml # Disk and LVM info
│ ├── gather_network.yml # Network configuration
│ ├── detect_hypervisor.yml # Virtualization detection
│ ├── export_stats.yml # JSON export
│ └── validate.yml # Health checks (CLAUDE.md compliant)
├── templates/
│ └── summary.txt.j2 # Human-readable summary
├── handlers/
│ └── main.yml # Service handlers
└── tests/
└── test.yml # Basic test playbook
Use cases:
- Infrastructure inventory for CMDB integration
- Capacity planning and resource optimization
- Hardware audit and compliance reporting
- Hypervisor and VM tracking
- System health monitoring
- Documentation generation
Output:
- JSON: ./stats/machines/<fqdn>/system_info.json
- Backup: ./stats/machines/<fqdn>/system_info_<timestamp>.json
- Summary: ./stats/machines/<fqdn>/summary.txt
Requirements:
- Ansible >= 2.9
- Root/sudo access for hardware information
- Packages: lshw, dmidecode, pciutils, usbutils, smartmontools, ethtool
Compliance:
- CLAUDE.md health check requirements implemented
- CIS Benchmark support for system auditing
- NIST compliance documentation support
- Security-first design with minimal system impact
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
172 lines
7.1 KiB
Django/Jinja
172 lines
7.1 KiB
Django/Jinja
================================================================================
|
|
SYSTEM INFORMATION SUMMARY
|
|
================================================================================
|
|
|
|
Generated: {{ system_info_timestamp }}
|
|
Host: {{ system_info_fqdn }}
|
|
|
|
--------------------------------------------------------------------------------
|
|
HOST INFORMATION
|
|
--------------------------------------------------------------------------------
|
|
Hostname: {{ system_info_hostname }}
|
|
FQDN: {{ system_info_fqdn }}
|
|
Uptime: {{ system_info_uptime }}
|
|
Boot Time: {{ system_info_boot_time }}
|
|
|
|
--------------------------------------------------------------------------------
|
|
HARDWARE
|
|
--------------------------------------------------------------------------------
|
|
Manufacturer: {{ system_info_hardware.manufacturer }}
|
|
Product: {{ system_info_hardware.product }}
|
|
Serial Number: {{ system_info_hardware.serial }}
|
|
UUID: {{ system_info_hardware.uuid }}
|
|
|
|
--------------------------------------------------------------------------------
|
|
OPERATING SYSTEM
|
|
--------------------------------------------------------------------------------
|
|
Distribution: {{ system_info_os.distribution }} {{ system_info_os.distribution_version }}
|
|
OS Family: {{ system_info_os.os_family }}
|
|
Kernel: {{ system_info_kernel.version }}
|
|
Architecture: {{ system_info_kernel.architecture }}
|
|
|
|
--------------------------------------------------------------------------------
|
|
SECURITY
|
|
--------------------------------------------------------------------------------
|
|
{% if system_info_selinux_status is defined and system_info_selinux_status != 'N/A' %}
|
|
SELinux: {{ system_info_selinux_status }}
|
|
{% endif %}
|
|
{% if system_info_apparmor_status is defined and system_info_apparmor_status != 'N/A' %}
|
|
AppArmor: {{ system_info_apparmor_status }}
|
|
{% endif %}
|
|
|
|
--------------------------------------------------------------------------------
|
|
CPU INFORMATION
|
|
--------------------------------------------------------------------------------
|
|
Model: {{ system_info_cpu.model }}
|
|
Vendor: {{ system_info_cpu.vendor }}
|
|
Architecture: {{ system_info_cpu.architecture }}
|
|
Physical CPUs: {{ system_info_cpu.count.physical }}
|
|
Cores per CPU: {{ system_info_cpu.count.cores_per_socket }}
|
|
Total vCPUs: {{ system_info_cpu.count.vcpus }}
|
|
Current MHz: {{ system_info_cpu.current_mhz }}
|
|
Max MHz: {{ system_info_cpu.max_mhz }}
|
|
Virtualization: {{ system_info_cpu.virtualization.type }}
|
|
Current Load: {{ system_info_cpu.current_load }}
|
|
|
|
--------------------------------------------------------------------------------
|
|
GPU INFORMATION
|
|
--------------------------------------------------------------------------------
|
|
GPU Detected: {{ system_info_gpu.detected }}
|
|
{% if system_info_gpu.detected %}
|
|
{% for device in system_info_gpu.devices %}
|
|
- {{ device }}
|
|
{% endfor %}
|
|
NVIDIA Present: {{ system_info_gpu.nvidia.present }}
|
|
AMD Present: {{ system_info_gpu.amd.present }}
|
|
Intel Present: {{ system_info_gpu.intel.present }}
|
|
IOMMU Status: {{ system_info_gpu.iommu_status }}
|
|
{% endif %}
|
|
|
|
--------------------------------------------------------------------------------
|
|
MEMORY INFORMATION
|
|
--------------------------------------------------------------------------------
|
|
Total Memory: {{ system_info_memory.total_mb }} MB
|
|
Used Memory: {{ system_info_memory.used_mb }} MB
|
|
Free Memory: {{ system_info_memory.free_mb }} MB
|
|
Usage: {{ system_info_memory.usage_percent }}%
|
|
Physical Modules: {{ system_info_memory.physical_modules }}
|
|
|
|
Swap Total: {{ system_info_swap.total_mb }} MB
|
|
Swap Used: {{ system_info_swap.used_mb }} MB
|
|
Swap Usage: {{ system_info_swap.usage_percent }}%
|
|
|
|
--------------------------------------------------------------------------------
|
|
DISK INFORMATION
|
|
--------------------------------------------------------------------------------
|
|
LVM Enabled: {{ system_info_disk.lvm.enabled }}
|
|
|
|
Disk Usage:
|
|
{% for line in system_info_disk.usage_human %}
|
|
{{ line }}
|
|
{% endfor %}
|
|
|
|
Physical Disks:
|
|
{% for disk in system_info_disk.physical_disks %}
|
|
{{ disk }}
|
|
{% endfor %}
|
|
|
|
Disk Types:
|
|
{% for dtype in system_info_disk.disk_types %}
|
|
{{ dtype }}
|
|
{% endfor %}
|
|
|
|
--------------------------------------------------------------------------------
|
|
NETWORK INFORMATION
|
|
--------------------------------------------------------------------------------
|
|
{% if system_info_network.default_ipv4 %}
|
|
Default IPv4: {{ system_info_network.default_ipv4.address | default('N/A') }}
|
|
Default Gateway: {{ system_info_network.default_ipv4.gateway | default('N/A') }}
|
|
Default Interface: {{ system_info_network.default_ipv4.interface | default('N/A') }}
|
|
{% endif %}
|
|
|
|
Network Interfaces:
|
|
{% for iface, details in system_info_network.interfaces.items() %}
|
|
{{ iface }}:
|
|
MAC: {{ details.mac }}
|
|
IPv4: {{ details.ipv4.address | default('N/A') }}
|
|
State: {{ details.state }}
|
|
MTU: {{ details.mtu }}
|
|
{% endfor %}
|
|
|
|
DNS Servers:
|
|
{% for dns in system_info_network.dns_servers %}
|
|
{{ dns }}
|
|
{% endfor %}
|
|
|
|
--------------------------------------------------------------------------------
|
|
VIRTUALIZATION / HYPERVISOR
|
|
--------------------------------------------------------------------------------
|
|
Is Virtual: {{ system_info_hypervisor.is_virtual }}
|
|
Is Hypervisor: {{ system_info_hypervisor.is_hypervisor }}
|
|
Virtualization Type: {{ system_info_hypervisor.virtualization_type }}
|
|
Role: {{ system_info_hypervisor.virtualization_role }}
|
|
|
|
{% if system_info_hypervisor.kvm_libvirt.installed %}
|
|
KVM/Libvirt:
|
|
Installed: {{ system_info_hypervisor.kvm_libvirt.installed }}
|
|
Service Status: {{ system_info_hypervisor.kvm_libvirt.service_status }}
|
|
Running VMs: {{ system_info_hypervisor.kvm_libvirt.running_vms }}
|
|
Total VMs: {{ system_info_hypervisor.kvm_libvirt.total_vms }}
|
|
{% endif %}
|
|
|
|
{% if system_info_hypervisor.proxmox.installed %}
|
|
Proxmox VE:
|
|
Installed: {{ system_info_hypervisor.proxmox.installed }}
|
|
Version: {{ system_info_hypervisor.proxmox.version }}
|
|
{% endif %}
|
|
|
|
{% if system_info_hypervisor.lxd.installed %}
|
|
LXD:
|
|
Installed: {{ system_info_hypervisor.lxd.installed }}
|
|
Version: {{ system_info_hypervisor.lxd.version }}
|
|
{% endif %}
|
|
|
|
{% if system_info_hypervisor.docker.installed %}
|
|
Docker:
|
|
Installed: {{ system_info_hypervisor.docker.installed }}
|
|
Version: {{ system_info_hypervisor.docker.version }}
|
|
Running: {{ system_info_hypervisor.docker.running_containers }}
|
|
Total: {{ system_info_hypervisor.docker.total_containers }}
|
|
Images: {{ system_info_hypervisor.docker.images_count }}
|
|
{% endif %}
|
|
|
|
{% if system_info_hypervisor.podman.installed %}
|
|
Podman:
|
|
Installed: {{ system_info_hypervisor.podman.installed }}
|
|
Version: {{ system_info_hypervisor.podman.version }}
|
|
{% endif %}
|
|
|
|
================================================================================
|
|
End of Report
|
|
================================================================================
|