LOGBOOK

HELP

Quiz Entry - updated: 2026.12.01

Which file-management modules does ansible.builtin provide, and what is each one for?

  • copy: put a file from the control node on the host
  • fetch: bring a file from the host back to the control node
  • file: create, remove or set attributes of files, directories and links
  • lineinfile / blockinfile: edit one line or one block inside an existing file
  • stat: read a file's status without changing it

File modules grouped by direction: copy and template push to the host, fetch pulls back, file, lineinfile and blockinfile change the host in place, stat only reads

* Sort the modules by direction: push, pull, change in place, or only look. *

The modules ship with ansible-core in the ansible.builtin collection, so they are always available. A useful way to remember them is by the direction the data moves:

Module Direction Typical job
copy control node → host deploy a ready-made file; can also set owner, mode and SELinux context
fetch host → control node collect a log, a key or a config from many hosts, sorted by host name
file on the host touch, mkdir, rm, chmod, chown, symlinks, SELinux attributes
lineinfile on the host make sure one line is present, replaced or removed
blockinfile on the host manage a multi-line block between marker comments
stat on the host, read-only does it exist, what mode, what checksum?

Several of them accept the same attribute options as file (owner, group, mode, setype, ...), so "copy and set permissions" is one task, not two.

Go deeper:

From Quiz: ITIA / Ansible: Managing Files and Jinja2 Templates | Updated: Dec 01, 2026