38 lines
1.1 KiB
YAML
38 lines
1.1 KiB
YAML
- name: Host Information
|
|
hosts: "{{ target }}"
|
|
gather_facts: False
|
|
vars:
|
|
tmpFile: "/tmp/ansible-hostinfo"
|
|
|
|
tasks:
|
|
- name: Get Host Name
|
|
register: gethostname
|
|
ansible.builtin.shell: |
|
|
echo "Hostname: $(hostname)" > {{tmpFile}}
|
|
- name: Get CPU Information
|
|
register: getcpuinfo
|
|
ansible.builtin.shell: |
|
|
CORES="$(cat /proc/cpuinfo | grep cores | head -n1 | cut -d: -f2)"
|
|
PROCS="$(cat /proc/cpuinfo | grep processor | wc -l)"
|
|
echo "CPU cores:$CORES, Processor count: $PROCS" >> {{tmpFile}}
|
|
- name: Get Uptime
|
|
register: getuptime
|
|
ansible.builtin.shell: |
|
|
echo "Uptime: $(uptime)" >> {{tmpFile}}
|
|
- name: Get Disk Space Usage
|
|
register: getdiskspaceusage
|
|
ansible.builtin.shell: |
|
|
df -h >> {{tmpFile}}
|
|
- name: Get RAM Usage
|
|
register: getramusage
|
|
ansible.builtin.shell: |
|
|
free -h >> {{tmpFile}}
|
|
- name: Print all Information
|
|
register: printall
|
|
ansible.builtin.shell: |
|
|
cat {{tmpFile}}
|
|
rm -f {{tmpFile}}
|
|
- debug:
|
|
msg:
|
|
- "{{ printall.stdout_lines }}"
|