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 hostfetch: bring a file from the host back to the control nodefile: create, remove or set attributes of files, directories and linkslineinfile/blockinfile: edit one line or one block inside an existing filestat: read a file's status without changing it
* 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:
ansible.builtin.file module (official docs) — the attribute options the other file modules share.