| 1234567891011121314151617181920212223242526272829303132333435363738 |
- ---
- # 系统信息检查
- - name: System Information
- hosts: "{{ target_hosts | default('all') }}"
- gather_facts: yes
-
- tasks:
- - name: Display OS info
- debug:
- msg: "OS: {{ ansible_facts['distribution'] }} {{ ansible_facts['distribution_version'] }}"
-
- - name: Display hostname
- debug:
- msg: "Hostname: {{ ansible_facts['hostname'] }}"
-
- - name: Display IP addresses
- debug:
- msg: "IP: {{ ansible_facts['default_ipv4']['address'] }}"
-
- - name: Display memory info
- debug:
- msg: "Memory: {{ (ansible_facts['memtotal_mb'] / 1024) | round(2) }} GB"
-
- - name: Display CPU info
- debug:
- msg: "CPU: {{ ansible_facts['processor_vcpus'] }} vCPUs"
-
- - name: Display disk space
- debug:
- msg: "Disk: {{ ansible_facts['mounts'][0]['size_total'] | default(0) | int / 1024 / 1024 / 1024 | round(2) }} GB"
-
- - name: Uptime
- command: uptime -s
- register: uptime
-
- - name: Show uptime
- debug:
- msg: "Uptime since: {{ uptime.stdout }}"
|