- hosts: localhost gather_facts: yes tasks: # ---------------------------------------------------------------------- # 1. SYSTEM INFORMATION SUMMARY # ---------------------------------------------------------------------- - name: Display Grouped System Information ansible.builtin.debug: msg: | 🖥️ System Information ------------------------- Hostname : {{ ansible_hostname }} FQDN : {{ ansible_fqdn }} OS Family : {{ ansible_os_family }} Architecture : {{ ansible_architecture }} Total Memory : {{ ansible_memtotal_mb }} MB Processor(s): {% for cpu in ansible_processor %} - {{ cpu }} {% endfor %} # ---------------------------------------------------------------------- # 2. NETWORK INFORMATION # ---------------------------------------------------------------------- - name: Show Default IPv4 Info ansible.builtin.debug: msg: | Default IPv4 Info: Address : {{ ansible_default_ipv4.address }} Interface : {{ ansible_default_ipv4.interface }} Gateway : {{ ansible_default_ipv4.gateway }} Netmask : {{ ansible_default_ipv4.netmask }} - name: Show All Network Interfaces ansible.builtin.debug: msg: | Network Interfaces: {{ ansible_interfaces | join('\n - ') }} - name: Show Details for Each Interface (Excluding Loopback) ansible.builtin.debug: var: hostvars['localhost']['ansible_' + item] loop: "{{ ansible_interfaces }}" when: hostvars['localhost']['ansible_' + item] is defined and item not in ['lo'] # ---------------------------------------------------------------------- # 3. STORAGE INFORMATION # ---------------------------------------------------------------------- - name: Display each mounted filesystem ansible.builtin.debug: msg: | 💾 Mounted Filesystem ------------------------- Mount Point : {{ item.mount }} Device : {{ item.device }} Fstype : {{ item.fstype }} {% if 'size_used' in item and 'size_total' in item and item.fstype not in ['tmpfs', 'overlay', 'squashfs'] %} Size Total : {{ (item.size_total | int // (1024 * 1024)) }} MB Size Used : {{ (item.size_used | int // (1024 * 1024)) }} MB Size Avail : {{ ((item.size_total | int - item.size_used | int) // (1024 * 1024)) }} MB {% else %} Size Info : Not Available {% endif %} loop: "{{ ansible_mounts }}" when: item.fstype != 'tmpfs' and item.fstype != 'overlay' and item.fstype != 'squashfs' # ---------------------------------------------------------------------- # 4. CURRENT USER DETAILS # ---------------------------------------------------------------------- - name: Show Connection and Effective User Details ansible.builtin.debug: msg: | Current SSH User : {{ ansible_user }} Effective Task User ID : {{ ansible_user_id }} Effective User Shell : {{ ansible_user_shell }} Effective User Home Dir : {{ ansible_user_dir }} # ---------------------------------------------------------------------- # 5. ALL SYSTEM USERS # ---------------------------------------------------------------------- - name: Gather All Users (/etc/passwd) ansible.builtin.getent: database: passwd - name: Show All Usernames ansible.builtin.debug: msg: | System Users: {% for u in getent_passwd | dict2items %} - {{ u.key }} {% endfor %}