--- # Statistics aggregation and export tasks - name: Set collection timestamp set_fact: system_info_timestamp: "{{ ansible_date_time.iso8601 }}" system_info_timestamp_epoch: "{{ ansible_date_time.epoch }}" tags: [export, statistics] - name: Aggregate all system information set_fact: system_info_complete: collection_info: timestamp: "{{ system_info_timestamp }}" timestamp_epoch: "{{ system_info_timestamp_epoch }}" collected_by: "ansible" role_version: "{{ system_info_role_version }}" ansible_version: "{{ ansible_version.full }}" host_info: hostname: "{{ system_info_hostname }}" fqdn: "{{ system_info_fqdn }}" uptime: "{{ system_info_uptime }}" boot_time: "{{ system_info_boot_time }}" system: "{{ system_info_os | default({}) }}" kernel: "{{ system_info_kernel | default({}) }}" hardware: "{{ system_info_hardware | default({}) }}" security: selinux: "{{ system_info_selinux_status | default('N/A') }}" apparmor: "{{ system_info_apparmor_status | default('N/A') }}" cpu: "{{ system_info_cpu | default({}) }}" gpu: "{{ system_info_gpu | default({}) }}" memory: "{{ system_info_memory | default({}) }}" swap: "{{ system_info_swap | default({}) }}" disk: "{{ system_info_disk | default({}) }}" network: "{{ system_info_network | default({}) }}" hypervisor: "{{ system_info_hypervisor | default({}) }}" tags: [export, statistics] - name: Create JSON statistics file on control node copy: content: "{{ system_info_complete | to_nice_json(indent=system_info_json_indent) }}" dest: "{{ system_info_stats_dir }}/system_info.json" mode: '0644' delegate_to: localhost become: false tags: [export, statistics] - name: Create timestamped JSON backup copy: content: "{{ system_info_complete | to_nice_json(indent=system_info_json_indent) }}" dest: "{{ system_info_stats_dir }}/system_info_{{ system_info_timestamp_epoch }}.json" mode: '0644' delegate_to: localhost become: false tags: [export, statistics, backup] - name: Create human-readable summary file template: src: summary.txt.j2 dest: "{{ system_info_stats_dir }}/summary.txt" mode: '0644' delegate_to: localhost become: false tags: [export, statistics, summary] - name: Display statistics file location debug: msg: - "System information collected successfully" - "Statistics saved to: {{ system_info_stats_dir }}/system_info.json" - "Summary saved to: {{ system_info_stats_dir }}/summary.txt" - "Timestamped backup: {{ system_info_stats_dir }}/system_info_{{ system_info_timestamp_epoch }}.json" tags: [export, statistics]