ansible check uname disk usage fdisk

[root@localhost ~]# cat uname.yml
---
  - name: Check the remote host Hostname, Version, Distribution with UNAME , df -h disk type
    hosts: localhost
    tasks:
      - name: Execute the UNAME command
        register: unameout
        command: "uname -a"

      - debug:
          var: unameout.stdout_lines
      - name: Execute the df command
        register: dfout
        command: "df -h"

      - debug:
          var: dfout.stdout_lines
      - name: Execute the df command
        register: duout
        command: "du -h"

      - debug:
          var: duout.stdout_lines
      - name: Execute the df command
        register: fdiskout
        command: "fdisk -l"

      - debug:
          var: fdiskout.stdout_lines
[root@localhost ~]#

[root@localhost ~]# ansible-playbook uname.yml 

PLAY [Check the remote host Hostname, Version, Distribution with UNAME] ********

TASK [Gathering Facts] *********************************************************
ok: [localhost]

TASK [Execute the UNAME command] ***********************************************
changed: [localhost]

TASK [debug] *******************************************************************
ok: [localhost] => {
    "unameout.stdout_lines": [
        "Linux checkmk 3.10.0-862.el7.x86_64 #1 SMP Fri Apr 20 16:44:24 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux"
    ]
}

TASK [Execute the df command] **************************************************
changed: [localhost]

TASK [debug] *******************************************************************
ok: [localhost] => {
    "dfout.stdout_lines": [
        "Filesystem               Size  Used Avail Use% Mounted on", 
        "/dev/mapper/centos-root   26G  7.1G   19G  27% /", 
        "devtmpfs                 895M     0  895M   0% /dev", 
        "tmpfs                    911M  5.3M  906M   1% /dev/shm", 
        "tmpfs                    911M   35M  877M   4% /run", 
        "tmpfs                    911M     0  911M   0% /sys/fs/cgroup", 
        "/dev/sda1               1014M  170M  845M  17% /boot", 
        "tmpfs                    183M   40K  183M   1% /run/user/0", 
        "tmpfs                    183M  4.0K  183M   1% /run/user/42", 
        "/dev/sr0                 4.2G  4.2G     0 100% /run/media/root/CentOS 7 x86_64", 
        "tmpfs                    911M  5.4M  906M   1% /opt/omd/sites/sandbox/tmp"
    ]
}

TASK [Execute the df command] **************************************************
changed: [localhost]

TASK [debug] *******************************************************************
ok: [localhost] => {
    "duout.stdout_lines": [
        "4.0K\t./.cache/dconf", 
        "8.0K\t./.cache/abrt", 
        "8.0K\t./.cache/imsettings", 
        "0\t./.cache/libgweather", 
        "0\t./.cache/evolution/addressbook/trash", 
        "0\t./.cache/evolution/addressbook", 
        "0\t./.cache/evolution/calendar/trash", 
        "0\t./.cache/evolution/calendar", 
        "0\t./.cache/evolution/mail/trash", 
        "0\t./.cache/evolution/mail", 
        "0\t./.cache/evolution/memos/trash", 
        "0\t./.cache/evolution/memos", 
        "0\t./.cache/evolution/sources/trash", 
        "0\t./.cache/evolution/sources", 
        "0\t./.cache/evolution/tasks/trash", 
        "0\t./.cache/evolution/tasks", 
        "0\t./.cache/evolution", 
        "3.3M\t./.cache/tracker", 
        "0\t./.cache/gnome-shell", 
        "0\t./.cache/gnome-software/3.22/flatpak/installation-tmp/repo/objects", 
        "0\t./.cache/gnome-software/3.22/flatpak/installation-tmp/repo/tmp/cache", 
        "0\t./.cache/gnome-software/3.22/flatpak/installation-tmp/repo/tmp", 
        "0\t./.cache/gnome-software/3.22/flatpak/installation-tmp/repo/extensions", 
        "0\t./.cache/gnome-software/3.22/flatpak/installation-tmp/repo/state", 
        "0\t./.cache/gnome-software/3.22/flatpak/installation-tmp/repo/refs/heads", 
        "0\t./.cache/gnome-software/3.22/flatpak/installation-tmp/repo/refs/remotes", 
        "0\t./.cache/gnome-software/3.22/flatpak/installation-tmp/repo/refs", 
        "4.0K\t./.cache/gnome-software/3.22/flatpak/installation-tmp/repo", 
        "4.0K\t./.cache/gnome-software/3.22/flatpak/installation-tmp", 
        "4.0K\t./.cache/gnome-software/3.22/flatpak", 
        "492K\t./.cache/gnome-software/3.22/ratings", 
        "708K\t./.cache/gnome-software/3.22/extensions", 
        "1.2M\t./.cache/gnome-software/3.22", 
        "1.2M\t./.cache/gnome-software", 
        "488K\t./.cache/gstreamer-1.0", 
        "0\t./.cache/media-art", 
        "0\t./.cache/yelp/WebKitCache/Version 11/Blobs", 
        "4.0K\t./.cache/yelp/WebKitCache/Version 11", 
        "4.0K\t./.cache/yelp/WebKitCache", 
        "4.0K\t./.cache/yelp", 
        "1.5M\t./.cache/mozilla/firefox/pav3vp0y.default/startupCache", 
        "44M\t./.cache/mozilla/firefox/pav3vp0y.default/cache2/entries", 
        "0\t./.cache/mozilla/firefox/pav3vp0y.default/cache2/doomed", 
        "44M\t./.cache/mozilla/firefox/pav3vp0y.default/cache2", 
        "0\t./.cache/mozilla/firefox/pav3vp0y.default/thumbnails", 
        "256K\t./.cache/mozilla/firefox/pav3vp0y.default/OfflineCache", 
        "536K\t./.cache/mozilla/firefox/pav3vp0y.default/safebrowsing", 
        "46M\t./.cache/mozilla/firefox/pav3vp0y.default", 
        "46M\t./.cache/mozilla/firefox", 
        "46M\t./.cache/mozilla", 
        "51M\t./.cache", 
        "8.0K\t./.dbus/session-bus", 
        "8.0K\t./.dbus", 
        "4.0K\t./.config/ibus/bus", 
        "4.0K\t./.config/ibus", 
        "0\t./.config/abrt", 
        "0\t./.config/imsettings", 
        "0\t./.config/gnome-session/saved-session", 
        "0\t./.config/gnome-session", 
        "8.0K\t./.config/dconf", 
        "4.0K\t./.config/evolution/sources", 
        "4.0K\t./.config/evolution", 
        "0\t./.config/goa-1.0", 
        "68K\t./.config/pulse", 
        "0\t./.config/gconf", 
        "4.0K\t./.config/gtk-3.0", 
        "4.0K\t./.config/nautilus", 
        "4.0K\t./.config/yelp", 
        "108K\t./.config", 
        "8.0K\t./.local/share/gnome-shell", 
        "8.0K\t./.local/share/telepathy/mission-control", 
        "8.0K\t./.local/share/telepathy", 
        "0\t./.local/share/evolution/addressbook/trash", 
        "0\t./.local/share/evolution/addressbook/system/photos", 
        "24K\t./.local/share/evolution/addressbook/system", 
        "24K\t./.local/share/evolution/addressbook", 
        "0\t./.local/share/evolution/calendar/trash", 
        "4.0K\t./.local/share/evolution/calendar/system", 
        "4.0K\t./.local/share/evolution/calendar", 
        "0\t./.local/share/evolution/mail/trash", 
        "0\t./.local/share/evolution/mail", 
        "0\t./.local/share/evolution/memos/trash", 
        "0\t./.local/share/evolution/memos", 
        "0\t./.local/share/evolution/tasks/trash", 
        "0\t./.local/share/evolution/tasks", 
        "28K\t./.local/share/evolution", 
        "0\t./.local/share/sounds", 
        "0\t./.local/share/applications", 
        "0\t./.local/share/icc", 
        "0\t./.local/share/gnome-settings-daemon", 
        "268K\t./.local/share/tracker/data", 
        "268K\t./.local/share/tracker", 
        "4.0K\t./.local/share/flatpak/db", 
        "0\t./.local/share/flatpak/repo/objects", 
        "0\t./.local/share/flatpak/repo/tmp/cache", 
        "0\t./.local/share/flatpak/repo/tmp", 
        "0\t./.local/share/flatpak/repo/extensions", 
        "0\t./.local/share/flatpak/repo/state", 
        "0\t./.local/share/flatpak/repo/refs/heads", 
        "0\t./.local/share/flatpak/repo/refs/remotes", 
        "0\t./.local/share/flatpak/repo/refs", 
        "4.0K\t./.local/share/flatpak/repo", 
        "8.0K\t./.local/share/flatpak", 
        "0\t./.local/share/nautilus/scripts", 
        "0\t./.local/share/nautilus", 
        "72K\t./.local/share/gvfs-metadata", 
        "0\t./.local/share/webkitgtk/localstorage", 
        "0\t./.local/share/webkitgtk", 
        "1.1M\t./.local/share/app-info/xmls", 
        "1.1M\t./.local/share/app-info", 
        "8.0K\t./.local/share/keyrings", 
        "1.5M\t./.local/share", 
        "1.5M\t./.local", 
        "0\t./Desktop", 
        "0\t./Downloads", 
        "0\t./Templates", 
        "0\t./Public", 
        "0\t./Documents", 
        "0\t./Music", 
        "272K\t./Pictures", 
        "0\t./Videos", 
        "248K\t./.ansible/tmp/ansible-local-93078MJErCv/ansiballz_cache", 
        "248K\t./.ansible/tmp/ansible-local-93078MJErCv", 
        "68K\t./.ansible/tmp/ansible-tmp-1571042437.77-140568080749771", 
        "316K\t./.ansible/tmp", 
        "0\t./.ansible/cp", 
        "316K\t./.ansible", 
        "8.0K\t./.govmomi/sessions", 
        "8.0K\t./.govmomi", 
        "12K\t./.ssh", 
        "0\t./.pki/nssdb", 
        "0\t./.pki", 
        "0\t./.mozilla/extensions/{ec8030f7-c20a-464f-9b0e-13a3a9e97384}", 
        "0\t./.mozilla/extensions", 
        "0\t./.mozilla/firefox/pav3vp0y.default/gmp", 
        "4.0K\t./.mozilla/firefox/pav3vp0y.default/bookmarkbackups", 
        "0\t./.mozilla/firefox/pav3vp0y.default/storage/permanent/chrome/idb/2918063365piupsah.files", 
        "48K\t./.mozilla/firefox/pav3vp0y.default/storage/permanent/chrome/idb", 
        "56K\t./.mozilla/firefox/pav3vp0y.default/storage/permanent/chrome", 
        "56K\t./.mozilla/firefox/pav3vp0y.default/storage/permanent", 
        "56K\t./.mozilla/firefox/pav3vp0y.default/storage", 
        "108K\t./.mozilla/firefox/pav3vp0y.default/sessionstore-backups", 
        "8.0K\t./.mozilla/firefox/pav3vp0y.default/datareporting/archived/2019-10", 
        "8.0K\t./.mozilla/firefox/pav3vp0y.default/datareporting/archived", 
        "28K\t./.mozilla/firefox/pav3vp0y.default/datareporting", 
        "1.4M\t./.mozilla/firefox/pav3vp0y.default/gmp-gmpopenh264/1.6", 
        "1.4M\t./.mozilla/firefox/pav3vp0y.default/gmp-gmpopenh264", 
        "17M\t./.mozilla/firefox/pav3vp0y.default", 
        "17M\t./.mozilla/firefox", 
        "17M\t./.mozilla", 
        "70M\t."
    ]
}

TASK [Execute the df command] **************************************************
changed: [localhost]

TASK [debug] *******************************************************************
ok: [localhost] => {
    "fdiskout.stdout_lines": [
        "", 
        "Disk /dev/sda: 32.2 GB, 32212254720 bytes, 62914560 sectors", 
        "Units = sectors of 1 * 512 = 512 bytes", 
        "Sector size (logical/physical): 512 bytes / 512 bytes", 
        "I/O size (minimum/optimal): 512 bytes / 512 bytes", 
        "Disk label type: dos", 
        "Disk identifier: 0x00099ab3", 
        "", 
        "   Device Boot      Start         End      Blocks   Id  System", 
        "/dev/sda1   *        2048     2099199     1048576   83  Linux", 
        "/dev/sda2         2099200    62914559    30407680   8e  Linux LVM", 
        "", 
        "Disk /dev/mapper/centos-root: 27.9 GB, 27913093120 bytes, 54517760 sectors", 
        "Units = sectors of 1 * 512 = 512 bytes", 
        "Sector size (logical/physical): 512 bytes / 512 bytes", 
        "I/O size (minimum/optimal): 512 bytes / 512 bytes", 
        "", 
        "", 
        "Disk /dev/mapper/centos-swap: 3221 MB, 3221225472 bytes, 6291456 sectors", 
        "Units = sectors of 1 * 512 = 512 bytes", 
        "Sector size (logical/physical): 512 bytes / 512 bytes", 
        "I/O size (minimum/optimal): 512 bytes / 512 bytes"
    ]
}

PLAY RECAP *********************************************************************
localhost                  : ok=9    changed=4    unreachable=0    failed=0  

Comments