Ansible check disk space of a folder

2.1k Views Asked by At

There is a module that allow me to check disk space of a folder like the command df -h /path/to/folder?
i want to avoid to use shell or command module, i can't believe there is no module for it

1

There are 1 best solutions below

0
On

I don't think there's any module for this. You would need to use something like the example below with the command or shell module.

- name: Check sufficient free space in directory
  command: "df {{ target_dir }}"
  register: space
  become: true

- set_fact:
    free_space_bytes: "{{ (space.stdout_lines[1] | split)[3] }}"