Playbook that runs du
Here's a playbook I wrote for my Ops team. Apparently they're impressed by the simplest things.
---
# Filename: du.yml
# Author: bgstack15
# Startdate: 2018-07-24
# Title: Book that Runs du
# Purpose: Run du with elevated privileges, primarily for auditing /home
# History:
# Usage:
# In ansible tower.
# Variables:
# path=/home What location to check
# max_depth=1 How many directories to read in to
# tail=5 How many to show
# Reference:
# Improve:
# Documentation:
- name: book that runs du
hosts: all
become: yes
become_user: root
become_method: sudo
tasks:
- name: du
shell: /usr/bin/du -xBM --max-depth "{{ max_depth | default('1') }}" "{{ path | default('/home') }}" | sort -n | tail -n "{{ tail | default('5') }}" | sed -r -e 's/[[:space:]]+/ /g;'
args:
warn: no
register: du
- debug:
msg: "{{ du.stdout_lines }}"
Comments