# System Updates Report

{{ report_type.value }}, {{ report_scope.value }}, generated on {{ now().strftime('%Y-%m-%d %H:%M:%S %z') }}

{% if report_scope == report_scope.complete %}
- **Total hosts:** {{ hosts_count }}
{% elif report_scope == report_scope.filtered %}
- **Selected hosts:** {{ hosts_count }}
{% endif %}
{% if report_type == report_type.security_only %}
- **Hosts with security updates:** {{ hosts|selectattr('security_updates')|list|length }}
{% else %}
- **Hosts with updates:** {{ hosts|selectattr('updates')|list|length }}
- **Total updates:** {{ hosts|map(attribute='updates')|map('length')|sum }}
{% endif %}
{% set security_label = "Total security updates:" if report_type == report_type.security_only else "Security updates:" %}
- **{{ security_label }}** {{ hosts|map(attribute='security_updates')|map('length')|sum }}

{% for host in hosts %}
## {{ host.name }} ({{ host.ip }})

**System Information:**

    {% if host.description %}
- **Description**: {{ host.description }}
    {% endif %}
- **OS**: {{ host.os }}{% if host.flavor and host.flavor != host.os %} {{ host.flavor }}{% endif %}{% if host.version %} {{ host.version }}{% endif +%}
- **Package Manager**: {{ host.package_manager or 'N/A' }}
- **Last Refresh**: {% if host.last_refresh %}{{ host.last_refresh.astimezone().strftime('%Y-%m-%d %H:%M:%S %z') }}{% else %}Never{% endif %}{% if host.is_stale %} *(Stale, needs refresh)*{% endif +%}
{% if host.needs_reboot %}- **Reboot Pending**: Yes{% endif +%}
    {% set updates_list = host.security_updates if report_type == report_type.security_only else host.updates %}
    {% if updates_list %}

**Available Updates ({{ updates_list|length }}):**

| Package | Current Version | New Version | Sec | Source |
|---------|-----------------|-------------|-----|--------|
        {% for update in updates_list %}
| **{{ update.name }}** | {{ update.current_version or '(NEW)' }} | {{ update.new_version }} | {{ '**Yes**' if update.security else 'No' }} | {{ update.source or 'N/A' }} |
        {% endfor %}
    {% else %}

**No updates available.**
    {% endif %}

{% endfor %}
---

*Generated with [Exosphere](https://github.com/mrdaemon/exosphere) version {{ exosphere_version }}*
{# EOF +#}